Skip to content

feat: support apisix global rule #163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Jun 12, 2025
Merged

feat: support apisix global rule #163

merged 15 commits into from
Jun 12, 2025

Conversation

ronething
Copy link
Contributor

@ronething ronething commented Jun 10, 2025

Signed-off-by: ashing [email protected]

support apisix global rule

Signed-off-by: ashing <[email protected]>
Signed-off-by: ashing <[email protected]>
Signed-off-by: ashing <[email protected]>
@ronething ronething changed the title (WIP)feat: support apisix global rule feat: support apisix global rule Jun 11, 2025
Copy link

github-actions bot commented Jun 11, 2025

conformance test report

apiVersion: gateway.networking.k8s.io/v1
date: "2025-06-12T09:38:26Z"
gatewayAPIChannel: standard
gatewayAPIVersion: v1.2.0
implementation:
  contact: null
  organization: APISIX
  project: apisix-ingress-controller
  url: https://github.com/apache/apisix-ingress-controller.git
  version: v2.0.0
kind: ConformanceReport
mode: default
profiles:
- core:
    failedTests:
    - HTTPRouteCrossNamespace
    - HTTPRouteMatchingAcrossRoutes
    result: failure
    skippedTests:
    - HTTPRouteHTTPSListener
    statistics:
      Failed: 2
      Passed: 30
      Skipped: 1
  name: GATEWAY-HTTP
  summary: Core tests failed with 2 test failures.

Copy link

github-actions bot commented Jun 11, 2025

conformance test report

apiVersion: gateway.networking.k8s.io/v1
date: "2025-06-12T09:37:49Z"
gatewayAPIChannel: standard
gatewayAPIVersion: v1.2.0
implementation:
  contact: null
  organization: APISIX
  project: apisix-ingress-controller
  url: https://github.com/apache/apisix-ingress-controller.git
  version: v2.0.0
kind: ConformanceReport
mode: default
profiles:
- core:
    failedTests:
    - HTTPRouteCrossNamespace
    result: failure
    skippedTests:
    - HTTPRouteHTTPSListener
    statistics:
      Failed: 1
      Passed: 31
      Skipped: 1
  name: GATEWAY-HTTP
  summary: Core tests failed with 1 test failures.

Signed-off-by: ashing <[email protected]>
Signed-off-by: ashing <[email protected]>
@ronething ronething requested a review from Copilot June 12, 2025 02:22
@api7 api7 deleted a comment from github-actions bot Jun 12, 2025
Copilot

This comment was marked as outdated.

Comment on lines +365 to +366
secretRef := gatewayProxy.Spec.Provider.ControlPlane.Auth.AdminKey.ValueFrom.SecretKeyRef
secret := &corev1.Secret{}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有个问题想问下,gatewayproxy 引用的 secret 发生了变化,会触发 apisixglobalrule 的 Reconcile 吗?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently not, the previous implementations should not have considered this either.
ref: #109

Signed-off-by: ashing <[email protected]>
Signed-off-by: ashing <[email protected]>
Signed-off-by: ashing <[email protected]>
Signed-off-by: ashing <[email protected]>
Signed-off-by: ashing <[email protected]>
@ronething ronething requested review from Copilot and dspo June 12, 2025 09:07
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for the Apisix Global Rule by extending the ADC provider, cache interface, controllers, CRDs, and associated APIs. It introduces new methods for managing global rules in cache, a new ApisixGlobalRuleReconciler implementation, and updates to configuration samples and CRD definitions.

  • Added global rule methods to the cache and provider interfaces.
  • Integrated ApisixGlobalRule handling in the ADC client and created a new controller.
  • Updated CRD defaults, API types, and configuration samples to support global rule functionality.

Reviewed Changes

Copilot reviewed 29 out of 29 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/provider/adc/cache/cache.go Added new global rule methods to the Cache interface.
internal/provider/adc/adc.go Extended ADC client logic to process ApisixGlobalRule resources.
internal/controller/apisixglobalrule_controller.go Implemented the ApisixGlobalRuleReconciler with comprehensive reconciliation, status updates, and event filtering.
config/samples/config.yaml Changed the secure_metrics configuration from an empty string to a boolean.
Other CRD and API files Updated relevant CRD definitions and API types to incorporate global rule support.
Comments suppressed due to low confidence (1)

config/samples/config.yaml:28

  • Verify that changing 'secure_metrics' from an empty string to a boolean does not break existing configurations, and update the related documentation accordingly.
secure_metrics: false

Comment on lines 187 to 191
if obj.GetObjectKind().GroupVersionKind().Group == "apisix.apache.org" &&
obj.GetObjectKind().GroupVersionKind().Version == "v2" {
log.Debugw("api version is v2, skip sync", zap.Any("obj", obj))
return nil
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if obj.GetObjectKind().GroupVersionKind().Group == "apisix.apache.org" &&
obj.GetObjectKind().GroupVersionKind().Version == "v2" {
log.Debugw("api version is v2, skip sync", zap.Any("obj", obj))
return nil
}
if obj.GetObjectKind().GroupVersionKind().GroupVersion() == apiv2.GroupVersion {
log.Debugw("api version is v2, skip sync", zap.Any("obj", obj))
return nil
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Signed-off-by: ashing <[email protected]>
tctx.ResourceParentRefs[globalRuleKind] = append(tctx.ResourceParentRefs[globalRuleKind], ingressClassKind)

// check if the provider field references a secret
if gatewayProxy.Spec.Provider != nil && gatewayProxy.Spec.Provider.Type == v1alpha1.ProviderTypeControlPlane {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v2 API 会有 gatewayProxy.Spec.Provider.Type == v1alpha1.ProviderTypeControlPlane 的情况吗?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, there is only this type. we can consider whether it is necessary to differentiate.

@ronething ronething merged commit 0ca0a72 into release-v2-dev Jun 12, 2025
15 of 17 checks passed
@ronething ronething deleted the refactor/xxxxx branch June 12, 2025 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants