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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions api/adc/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ func (g *GlobalRule) DeepCopy() GlobalRule {
return GlobalRule(copied)
}

// +k8s:deepcopy-gen=true
type GlobalRuleItem struct {
Metadata `json:",inline" yaml:",inline"`

Plugins Plugins `json:"plugins" yaml:"plugins"`
}

type PluginMetadata Plugins

func (p *PluginMetadata) DeepCopy() PluginMetadata {
Expand Down
17 changes: 17 additions & 0 deletions api/adc/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions api/v2/apisixroute_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,13 @@ type ApisixRoutePlugin struct {
// The plugin name.
Name string `json:"name" yaml:"name"`
// Whether this plugin is in use, default is true.
// +kubebuilder:default=true
Enable bool `json:"enable" yaml:"enable"`
// Plugin configuration.
// +kubebuilder:validation:Optional
Config ApisixRoutePluginConfig `json:"config" yaml:"config"`
// Plugin configuration secretRef.
// +kubebuilder:validation:Optional
SecretRef string `json:"secretRef" yaml:"secretRef"`
}

Expand Down
19 changes: 19 additions & 0 deletions api/v2/reason.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package v2

type Reason string

const (
ReasonSyncFailed Reason = "SyncFailed"
)
3 changes: 1 addition & 2 deletions config/crd/bases/apisix.apache.org_apisixglobalrules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ spec:
description: Plugin configuration.
type: object
enable:
default: true
description: Whether this plugin is in use, default is true.
type: boolean
name:
Expand All @@ -64,10 +65,8 @@ spec:
description: Plugin configuration secretRef.
type: string
required:
- config
- enable
- name
- secretRef
type: object
type: array
required:
Expand Down
3 changes: 1 addition & 2 deletions config/crd/bases/apisix.apache.org_apisixpluginconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ spec:
description: Plugin configuration.
type: object
enable:
default: true
description: Whether this plugin is in use, default is true.
type: boolean
name:
Expand All @@ -65,10 +66,8 @@ spec:
description: Plugin configuration secretRef.
type: string
required:
- config
- enable
- name
- secretRef
type: object
type: array
required:
Expand Down
6 changes: 2 additions & 4 deletions config/crd/bases/apisix.apache.org_apisixroutes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ spec:
description: Plugin configuration.
type: object
enable:
default: true
description: Whether this plugin is in use, default is
true.
type: boolean
Expand All @@ -265,10 +266,8 @@ spec:
description: Plugin configuration secretRef.
type: string
required:
- config
- enable
- name
- secretRef
type: object
type: array
priority:
Expand Down Expand Up @@ -374,6 +373,7 @@ spec:
description: Plugin configuration.
type: object
enable:
default: true
description: Whether this plugin is in use, default is
true.
type: boolean
Expand All @@ -384,10 +384,8 @@ spec:
description: Plugin configuration secretRef.
type: string
required:
- config
- enable
- name
- secretRef
type: object
type: array
protocol:
Expand Down
38 changes: 0 additions & 38 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,44 +54,6 @@ rules:
verbs:
- get
- update
- apiGroups:
- apisix.apache.org.github.com
resources:
- apisixconsumers
- apisixglobalrules
- apisixroutes
- apisixtls
- apisixupstreams
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- apisix.apache.org.github.com
resources:
- apisixconsumers/finalizers
- apisixglobalrules/finalizers
- apisixroutes/finalizers
- apisixtls/finalizers
- apisixupstreams/finalizers
verbs:
- update
- apiGroups:
- apisix.apache.org.github.com
resources:
- apisixconsumers/status
- apisixglobalrules/status
- apisixroutes/status
- apisixtls/status
- apisixupstreams/status
verbs:
- get
- patch
- update
- apiGroups:
- coordination.k8s.io
resources:
Expand Down
2 changes: 1 addition & 1 deletion config/samples/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ enable_http2: false # Whether to enable HTTP/2 for the serve
probe_addr: ":8081" # The address the probe endpoint binds to.
# The default value is ":8081".

secure_metrics: "" # The secure metrics configuration.
secure_metrics: false # The secure metrics configuration.
# The default value is "" (empty).

exec_adc_timeout: 15s # The timeout for the ADC to execute.
Expand Down
2 changes: 2 additions & 0 deletions docs/crd/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1632,6 +1632,8 @@ them if they are set on the port level.
_Appears in:_
- [ApisixUpstreamSpec](#apisixupstreamspec)



#### UpstreamTimeout


Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ require (
go.uber.org/zap v1.27.0
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56
golang.org/x/net v0.28.0
google.golang.org/protobuf v1.34.2
gopkg.in/yaml.v3 v3.0.1
helm.sh/helm/v3 v3.15.4
k8s.io/api v0.31.1
Expand Down Expand Up @@ -202,6 +201,7 @@ require (
google.golang.org/genproto/googleapis/api v0.0.0-20240604185151-ef581f913117 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect
google.golang.org/grpc v1.66.2 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/fsnotify.v1 v1.4.7 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
Expand Down
4 changes: 0 additions & 4 deletions internal/controller/apisixconsumer_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ type ApisixConsumerReconciler struct {
Log logr.Logger
}

// +kubebuilder:rbac:groups=apisix.apache.org.github.com,resources=apisixconsumers,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=apisix.apache.org.github.com,resources=apisixconsumers/status,verbs=get;update;patch
// +kubebuilder:rbac:groups=apisix.apache.org.github.com,resources=apisixconsumers/finalizers,verbs=update

// Reconcile FIXME: implement the reconcile logic (For now, it dose nothing other than directly accepting)
func (r *ApisixConsumerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
r.Log.Info("reconcile", "request", req.NamespacedName)
Expand Down
Loading
Loading