Skip to content

Commit c2d8862

Browse files
committed
feat: Add v2 API support for Apisix resources and update controller logic
1 parent 75ae919 commit c2d8862

File tree

56 files changed

+5254
-200
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+5254
-200
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ GOLANGCI_LINT = $(LOCALBIN)/golangci-lint
288288

289289
## Tool Versions
290290
KUSTOMIZE_VERSION ?= v5.4.2
291-
CONTROLLER_TOOLS_VERSION ?= v0.15.0
291+
CONTROLLER_TOOLS_VERSION ?= v0.17.2
292292
ENVTEST_VERSION ?= release-0.18
293293
GOLANGCI_LINT_VERSION ?= v2.1.5
294294

PROJECT

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,57 @@ resources:
3434
kind: HTTPRoutePolicy
3535
path: github.com/apache/apisix-ingress-controller/api/v1alpha1
3636
version: v1alpha1
37+
- api:
38+
crdVersion: v1
39+
namespaced: true
40+
controller: true
41+
domain: github.com
42+
group: apisix.apache.org
43+
kind: ApisixRoute
44+
path: github.com/apache/apisix-ingress-controller/api/v2
45+
version: v2
46+
- api:
47+
crdVersion: v1
48+
namespaced: true
49+
controller: true
50+
domain: github.com
51+
group: apisix.apache.org
52+
kind: ApisixConsumer
53+
path: github.com/apache/apisix-ingress-controller/api/v2
54+
version: v2
55+
- api:
56+
crdVersion: v1
57+
namespaced: true
58+
controller: true
59+
domain: github.com
60+
group: apisix.apache.org
61+
kind: ApisixGlobalRule
62+
path: github.com/apache/apisix-ingress-controller/api/v2
63+
version: v2
64+
- api:
65+
crdVersion: v1
66+
namespaced: true
67+
controller: true
68+
domain: github.com
69+
group: apisix.apache.org
70+
kind: ApisixTls
71+
path: github.com/apache/apisix-ingress-controller/api/v2
72+
version: v2
73+
- api:
74+
crdVersion: v1
75+
namespaced: true
76+
controller: true
77+
domain: github.com
78+
group: apisix.apache.org
79+
kind: ApisixUpstream
80+
path: github.com/apache/apisix-ingress-controller/api/v2
81+
version: v2
82+
- api:
83+
crdVersion: v1
84+
namespaced: true
85+
domain: github.com
86+
group: apisix.apache.org
87+
kind: ApisixPluginConfig
88+
path: github.com/apache/apisix-ingress-controller/api/v2
89+
version: v2
3790
version: "3"

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v2/apisixconsumer_types.go

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
// Licensed under the Apache License, Version 2.0 (the "License");
2+
// you may not use this file except in compliance with the License.
3+
// You may obtain a copy of the License at
4+
//
5+
// http://www.apache.org/licenses/LICENSE-2.0
6+
//
7+
// Unless required by applicable law or agreed to in writing, software
8+
// distributed under the License is distributed on an "AS IS" BASIS,
9+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
// See the License for the specific language governing permissions and
11+
// limitations under the License.
12+
13+
package v2
14+
15+
import (
16+
corev1 "k8s.io/api/core/v1"
17+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
18+
)
19+
20+
// ApisixConsumerSpec defines the desired state of ApisixConsumer.
21+
type ApisixConsumerSpec struct {
22+
// IngressClassName is the name of an IngressClass cluster resource.
23+
// controller implementations use this field to know whether they should be
24+
// serving this ApisixConsumer resource, by a transitive connection
25+
// (controller -> IngressClass -> ApisixConsumer resource).
26+
IngressClassName string `json:"ingressClassName,omitempty" yaml:"ingressClassName,omitempty"`
27+
28+
AuthParameter ApisixConsumerAuthParameter `json:"authParameter" yaml:"authParameter"`
29+
}
30+
31+
// ApisixConsumerStatus defines the observed state of ApisixConsumer.
32+
// +kubebuilder:deepcopy:generate=true
33+
type ApisixConsumerStatus = ApisixStatus
34+
35+
// +kubebuilder:object:root=true
36+
// +kubebuilder:subresource:status
37+
38+
// ApisixConsumer is the Schema for the apisixconsumers API.
39+
type ApisixConsumer struct {
40+
metav1.TypeMeta `json:",inline"`
41+
metav1.ObjectMeta `json:"metadata,omitempty"`
42+
43+
Spec ApisixConsumerSpec `json:"spec,omitempty"`
44+
Status ApisixConsumerStatus `json:"status,omitempty"`
45+
}
46+
47+
// +kubebuilder:object:root=true
48+
49+
// ApisixConsumerList contains a list of ApisixConsumer.
50+
type ApisixConsumerList struct {
51+
metav1.TypeMeta `json:",inline"`
52+
metav1.ListMeta `json:"metadata,omitempty"`
53+
Items []ApisixConsumer `json:"items"`
54+
}
55+
56+
type ApisixConsumerAuthParameter struct {
57+
BasicAuth *ApisixConsumerBasicAuth `json:"basicAuth,omitempty" yaml:"basicAuth"`
58+
KeyAuth *ApisixConsumerKeyAuth `json:"keyAuth,omitempty" yaml:"keyAuth"`
59+
WolfRBAC *ApisixConsumerWolfRBAC `json:"wolfRBAC,omitempty" yaml:"wolfRBAC"`
60+
JwtAuth *ApisixConsumerJwtAuth `json:"jwtAuth,omitempty" yaml:"jwtAuth"`
61+
HMACAuth *ApisixConsumerHMACAuth `json:"hmacAuth,omitempty" yaml:"hmacAuth"`
62+
LDAPAuth *ApisixConsumerLDAPAuth `json:"ldapAuth,omitempty" yaml:"ldapAuth"`
63+
}
64+
65+
// ApisixConsumerBasicAuth defines the configuration for basic auth.
66+
type ApisixConsumerBasicAuth struct {
67+
SecretRef *corev1.LocalObjectReference `json:"secretRef,omitempty" yaml:"secretRef,omitempty"`
68+
Value *ApisixConsumerBasicAuthValue `json:"value,omitempty" yaml:"value,omitempty"`
69+
}
70+
71+
// ApisixConsumerBasicAuthValue defines the in-place username and password configuration for basic auth.
72+
type ApisixConsumerBasicAuthValue struct {
73+
Username string `json:"username" yaml:"username"`
74+
Password string `json:"password" yaml:"password"`
75+
}
76+
77+
// ApisixConsumerKeyAuth defines the configuration for the key auth.
78+
type ApisixConsumerKeyAuth struct {
79+
SecretRef *corev1.LocalObjectReference `json:"secretRef,omitempty" yaml:"secretRef,omitempty"`
80+
Value *ApisixConsumerKeyAuthValue `json:"value,omitempty" yaml:"value,omitempty"`
81+
}
82+
83+
// ApisixConsumerKeyAuthValue defines the in-place configuration for basic auth.
84+
type ApisixConsumerKeyAuthValue struct {
85+
Key string `json:"key" yaml:"key"`
86+
}
87+
88+
// ApisixConsumerWolfRBAC defines the configuration for the wolf-rbac auth.
89+
type ApisixConsumerWolfRBAC struct {
90+
SecretRef *corev1.LocalObjectReference `json:"secretRef,omitempty" yaml:"secretRef,omitempty"`
91+
Value *ApisixConsumerWolfRBACValue `json:"value,omitempty" yaml:"value,omitempty"`
92+
}
93+
94+
// ApisixConsumerWolfRBAC defines the in-place server and appid and header_prefix configuration for wolf-rbac auth.
95+
type ApisixConsumerWolfRBACValue struct {
96+
Server string `json:"server,omitempty" yaml:"server,omitempty"`
97+
Appid string `json:"appid,omitempty" yaml:"appid,omitempty"`
98+
HeaderPrefix string `json:"header_prefix,omitempty" yaml:"header_prefix,omitempty"`
99+
}
100+
101+
// ApisixConsumerJwtAuth defines the configuration for the jwt auth.
102+
type ApisixConsumerJwtAuth struct {
103+
SecretRef *corev1.LocalObjectReference `json:"secretRef,omitempty" yaml:"secretRef,omitempty"`
104+
Value *ApisixConsumerJwtAuthValue `json:"value,omitempty" yaml:"value,omitempty"`
105+
}
106+
107+
// ApisixConsumerJwtAuthValue defines the in-place configuration for jwt auth.
108+
type ApisixConsumerJwtAuthValue struct {
109+
Key string `json:"key" yaml:"key"`
110+
Secret string `json:"secret,omitempty" yaml:"secret,omitempty"`
111+
PublicKey string `json:"public_key,omitempty" yaml:"public_key,omitempty"`
112+
PrivateKey string `json:"private_key" yaml:"private_key,omitempty"`
113+
Algorithm string `json:"algorithm,omitempty" yaml:"algorithm,omitempty"`
114+
Exp int64 `json:"exp,omitempty" yaml:"exp,omitempty"`
115+
Base64Secret bool `json:"base64_secret,omitempty" yaml:"base64_secret,omitempty"`
116+
LifetimeGracePeriod int64 `json:"lifetime_grace_period,omitempty" yaml:"lifetime_grace_period,omitempty"`
117+
}
118+
119+
// ApisixConsumerHMACAuth defines the configuration for the hmac auth.
120+
type ApisixConsumerHMACAuth struct {
121+
SecretRef *corev1.LocalObjectReference `json:"secretRef,omitempty" yaml:"secretRef,omitempty"`
122+
Value *ApisixConsumerHMACAuthValue `json:"value,omitempty" yaml:"value,omitempty"`
123+
}
124+
125+
// ApisixConsumerHMACAuthValue defines the in-place configuration for hmac auth.
126+
type ApisixConsumerHMACAuthValue struct {
127+
AccessKey string `json:"access_key" yaml:"access_key"`
128+
SecretKey string `json:"secret_key" yaml:"secret_key"`
129+
Algorithm string `json:"algorithm,omitempty" yaml:"algorithm,omitempty"`
130+
ClockSkew int64 `json:"clock_skew,omitempty" yaml:"clock_skew,omitempty"`
131+
SignedHeaders []string `json:"signed_headers,omitempty" yaml:"signed_headers,omitempty"`
132+
KeepHeaders bool `json:"keep_headers,omitempty" yaml:"keep_headers,omitempty"`
133+
EncodeURIParams bool `json:"encode_uri_params,omitempty" yaml:"encode_uri_params,omitempty"`
134+
ValidateRequestBody bool `json:"validate_request_body,omitempty" yaml:"validate_request_body,omitempty"`
135+
MaxReqBody int64 `json:"max_req_body,omitempty" yaml:"max_req_body,omitempty"`
136+
}
137+
138+
// ApisixConsumerLDAPAuth defines the configuration for the ldap auth.
139+
type ApisixConsumerLDAPAuth struct {
140+
SecretRef *corev1.LocalObjectReference `json:"secretRef" yaml:"secret"`
141+
Value *ApisixConsumerLDAPAuthValue `json:"value,omitempty" yaml:"value,omitempty"`
142+
}
143+
144+
// ApisixConsumerLDAPAuthValue defines the in-place configuration for ldap auth.
145+
type ApisixConsumerLDAPAuthValue struct {
146+
UserDN string `json:"user_dn" yaml:"user_dn"`
147+
}
148+
149+
func init() {
150+
SchemeBuilder.Register(&ApisixConsumer{}, &ApisixConsumerList{})
151+
}

api/v2/apisixglobalrule_types.go

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Licensed under the Apache License, Version 2.0 (the "License");
2+
// you may not use this file except in compliance with the License.
3+
// You may obtain a copy of the License at
4+
//
5+
// http://www.apache.org/licenses/LICENSE-2.0
6+
//
7+
// Unless required by applicable law or agreed to in writing, software
8+
// distributed under the License is distributed on an "AS IS" BASIS,
9+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
// See the License for the specific language governing permissions and
11+
// limitations under the License.
12+
13+
package v2
14+
15+
import (
16+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
17+
)
18+
19+
// ApisixGlobalRuleSpec defines the desired state of ApisixGlobalRule.
20+
type ApisixGlobalRuleSpec struct {
21+
// IngressClassName is the name of an IngressClass cluster resource.
22+
// The controller uses this field to decide whether the resource should be managed or not.
23+
IngressClassName string `json:"ingressClassName,omitempty" yaml:"ingressClassName,omitempty"`
24+
// Plugins contains a list of ApisixRoutePlugin
25+
// +kubebuilder:validation:Required
26+
Plugins []ApisixRoutePlugin `json:"plugins" yaml:"plugins"`
27+
}
28+
29+
// ApisixGlobalRuleStatus defines the observed state of ApisixGlobalRule.
30+
// +kubebuilder:deepcopy:generate=true
31+
type ApisixGlobalRuleStatus struct {
32+
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
33+
// Important: Run "make" to regenerate code after modifying this file
34+
}
35+
36+
// +kubebuilder:object:root=true
37+
// +kubebuilder:subresource:status
38+
39+
// ApisixGlobalRule is the Schema for the apisixglobalrules API.
40+
type ApisixGlobalRule struct {
41+
metav1.TypeMeta `json:",inline"`
42+
metav1.ObjectMeta `json:"metadata,omitempty"`
43+
44+
Spec ApisixGlobalRuleSpec `json:"spec,omitempty"`
45+
Status ApisixGlobalRuleStatus `json:"status,omitempty"`
46+
}
47+
48+
// +kubebuilder:object:root=true
49+
50+
// ApisixGlobalRuleList contains a list of ApisixGlobalRule.
51+
type ApisixGlobalRuleList struct {
52+
metav1.TypeMeta `json:",inline"`
53+
metav1.ListMeta `json:"metadata,omitempty"`
54+
Items []ApisixGlobalRule `json:"items"`
55+
}
56+
57+
func init() {
58+
SchemeBuilder.Register(&ApisixGlobalRule{}, &ApisixGlobalRuleList{})
59+
}

api/v2/apisixpluginconfig_types.go

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Licensed under the Apache License, Version 2.0 (the "License");
2+
// you may not use this file except in compliance with the License.
3+
// You may obtain a copy of the License at
4+
//
5+
// http://www.apache.org/licenses/LICENSE-2.0
6+
//
7+
// Unless required by applicable law or agreed to in writing, software
8+
// distributed under the License is distributed on an "AS IS" BASIS,
9+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
// See the License for the specific language governing permissions and
11+
// limitations under the License.
12+
13+
package v2
14+
15+
import (
16+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
17+
)
18+
19+
// ApisixPluginConfigSpec defines the desired state of ApisixPluginConfigSpec.
20+
type ApisixPluginConfigSpec struct {
21+
// IngressClassName is the name of an IngressClass cluster resource.
22+
// The controller uses this field to decide whether the resource should be managed or not.
23+
// +kubebuilder:validation:Optional
24+
IngressClassName string `json:"ingressClassName,omitempty" yaml:"ingressClassName,omitempty"`
25+
// Plugins contain a list of ApisixRoutePlugin
26+
// +kubebuilder:validation:Required
27+
Plugins []ApisixRoutePlugin `json:"plugins" yaml:"plugins"`
28+
}
29+
30+
// ApisixPluginConfigStatus defines the observed state of ApisixPluginConfig.
31+
// +kubebuilder:deepcopy:generate=true
32+
type ApisixPluginConfigStatus ApisixStatus
33+
34+
// +kubebuilder:object:root=true
35+
// +kubebuilder:subresource:status
36+
37+
// ApisixPluginConfig is the Schema for the apisixpluginconfigs API.
38+
type ApisixPluginConfig struct {
39+
metav1.TypeMeta `json:",inline"`
40+
metav1.ObjectMeta `json:"metadata,omitempty"`
41+
42+
Spec ApisixPluginConfigSpec `json:"spec,omitempty"`
43+
Status ApisixPluginConfigStatus `json:"status,omitempty"`
44+
}
45+
46+
// +kubebuilder:object:root=true
47+
48+
// ApisixPluginConfigList contains a list of ApisixPluginConfig.
49+
type ApisixPluginConfigList struct {
50+
metav1.TypeMeta `json:",inline"`
51+
metav1.ListMeta `json:"metadata,omitempty"`
52+
Items []ApisixPluginConfig `json:"items"`
53+
}
54+
55+
func init() {
56+
SchemeBuilder.Register(&ApisixPluginConfig{}, &ApisixPluginConfigList{})
57+
}

0 commit comments

Comments
 (0)