Skip to content

Commit 4d7831f

Browse files
committed
Merge remote-tracking branch 'origin/release-v2-dev' into feat/support_apisixtls
Signed-off-by: ashing <axingfly@gmail.com>
2 parents 3ac66ff + f3476e2 commit 4d7831f

15 files changed

Lines changed: 560 additions & 59 deletions

File tree

Dockerfile.dev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ WORKDIR /app
88

99
RUN apt update \
1010
&& apt install -y git \
11-
&& git clone --branch main https://github.com/api7/adc.git \
11+
&& git clone --depth 1 --branch main https://github.com/api7/adc.git \
1212
&& cd adc \
1313
&& corepack enable pnpm \
1414
&& pnpm install \

api/adc/types.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@ type ConsumerGroup struct {
128128

129129
// +k8s:deepcopy-gen=true
130130
type Consumer struct {
131-
Credentials []Credential `json:"credentials,omitempty" yaml:"credentials,omitempty"`
132-
Description string `json:"description,omitempty" yaml:"description,omitempty"`
133-
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
134-
Plugins Plugins `json:"plugins,omitempty" yaml:"plugins,omitempty"`
135-
Username string `json:"username" yaml:"username"`
131+
Metadata `json:",inline" yaml:",inline"`
132+
133+
Credentials []Credential `json:"credentials,omitempty" yaml:"credentials,omitempty"`
134+
Plugins Plugins `json:"plugins,omitempty" yaml:"plugins,omitempty"`
135+
Username string `json:"username" yaml:"username"`
136136
}
137137

138138
// +k8s:deepcopy-gen=true

api/adc/zz_generated.deepcopy.go

Lines changed: 1 addition & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v2/apisixupstream_types.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,19 @@ type ApisixUpstreamSpec struct {
3636
PortLevelSettings []PortLevelSettings `json:"portLevelSettings,omitempty" yaml:"portLevelSettings,omitempty"`
3737
}
3838

39+
// ApisixUpstreamStatus defines the observed state of ApisixUpstream.
40+
type ApisixUpstreamStatus = ApisixStatus
41+
3942
// +kubebuilder:object:root=true
43+
// +kubebuilder:subresource:status
4044

4145
// ApisixUpstream is the Schema for the apisixupstreams API.
4246
type ApisixUpstream struct {
4347
metav1.TypeMeta `json:",inline"`
4448
metav1.ObjectMeta `json:"metadata,omitempty"`
4549

46-
Spec ApisixUpstreamSpec `json:"spec,omitempty"`
50+
Spec ApisixUpstreamSpec `json:"spec,omitempty"`
51+
Status ApisixUpstreamStatus `json:"status,omitempty"`
4752
}
4853

4954
// +kubebuilder:object:root=true

api/v2/zz_generated.deepcopy.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/apisix.apache.org_apisixupstreams.yaml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,68 @@ spec:
490490
the pass_host is set to rewrite
491491
type: string
492492
type: object
493+
status:
494+
description: ApisixStatus is the status report for Apisix ingress Resources
495+
properties:
496+
conditions:
497+
items:
498+
description: Condition contains details for one aspect of the current
499+
state of this API Resource.
500+
properties:
501+
lastTransitionTime:
502+
description: |-
503+
lastTransitionTime is the last time the condition transitioned from one status to another.
504+
This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
505+
format: date-time
506+
type: string
507+
message:
508+
description: |-
509+
message is a human readable message indicating details about the transition.
510+
This may be an empty string.
511+
maxLength: 32768
512+
type: string
513+
observedGeneration:
514+
description: |-
515+
observedGeneration represents the .metadata.generation that the condition was set based upon.
516+
For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date
517+
with respect to the current state of the instance.
518+
format: int64
519+
minimum: 0
520+
type: integer
521+
reason:
522+
description: |-
523+
reason contains a programmatic identifier indicating the reason for the condition's last transition.
524+
Producers of specific condition types may define expected values and meanings for this field,
525+
and whether the values are considered a guaranteed API.
526+
The value should be a CamelCase string.
527+
This field may not be empty.
528+
maxLength: 1024
529+
minLength: 1
530+
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
531+
type: string
532+
status:
533+
description: status of the condition, one of True, False, Unknown.
534+
enum:
535+
- "True"
536+
- "False"
537+
- Unknown
538+
type: string
539+
type:
540+
description: type of condition in CamelCase or in foo.example.com/CamelCase.
541+
maxLength: 316
542+
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
543+
type: string
544+
required:
545+
- lastTransitionTime
546+
- message
547+
- reason
548+
- status
549+
- type
550+
type: object
551+
type: array
552+
type: object
493553
type: object
494554
served: true
495555
storage: true
556+
subresources:
557+
status: {}

docs/crd/api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,6 +1300,8 @@ _Appears in:_
13001300

13011301

13021302

1303+
1304+
13031305
#### ApisixTlsSpec
13041306

13051307

internal/controller/apisixpluginconfig_controller.go

Lines changed: 8 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import (
3030
"github.com/apache/apisix-ingress-controller/api/v1alpha1"
3131
apiv2 "github.com/apache/apisix-ingress-controller/api/v2"
3232
"github.com/apache/apisix-ingress-controller/internal/controller/status"
33-
"github.com/apache/apisix-ingress-controller/internal/provider"
3433
"github.com/apache/apisix-ingress-controller/internal/utils"
3534
)
3635

@@ -46,11 +45,7 @@ type ApisixPluginConfigReconciler struct {
4645
func (r *ApisixPluginConfigReconciler) SetupWithManager(mgr ctrl.Manager) error {
4746
return ctrl.NewControllerManagedBy(mgr).
4847
For(&apiv2.ApisixPluginConfig{}).
49-
WithEventFilter(
50-
predicate.Or(
51-
predicate.GenerationChangedPredicate{},
52-
),
53-
).
48+
WithEventFilter(predicate.GenerationChangedPredicate{}).
5449
Watches(&networkingv1.IngressClass{},
5550
handler.EnqueueRequestsFromMapFunc(r.listApisixPluginConfigForIngressClass),
5651
builder.WithPredicates(
@@ -67,23 +62,12 @@ func (r *ApisixPluginConfigReconciler) SetupWithManager(mgr ctrl.Manager) error
6762
func (r *ApisixPluginConfigReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
6863
var pc apiv2.ApisixPluginConfig
6964
if err := r.Get(ctx, req.NamespacedName, &pc); err != nil {
70-
if client.IgnoreNotFound(err) == nil {
71-
pc.Namespace = req.Namespace
72-
pc.Name = req.Name
73-
pc.TypeMeta = metav1.TypeMeta{
74-
Kind: KindApisixPluginConfig,
75-
APIVersion: apiv2.GroupVersion.String(),
76-
}
77-
78-
return ctrl.Result{}, nil
79-
}
80-
return ctrl.Result{}, err
65+
return ctrl.Result{}, client.IgnoreNotFound(err)
8166
}
8267

8368
var (
84-
tctx = provider.NewDefaultTranslateContext(ctx)
85-
ic *networkingv1.IngressClass
86-
err error
69+
ic *networkingv1.IngressClass
70+
err error
8771
)
8872
defer func() {
8973
r.updateStatus(&pc, err)
@@ -92,7 +76,7 @@ func (r *ApisixPluginConfigReconciler) Reconcile(ctx context.Context, req ctrl.R
9276
if ic, err = r.getIngressClass(&pc); err != nil {
9377
return ctrl.Result{}, err
9478
}
95-
if err = r.processIngressClassParameters(ctx, tctx, &pc, ic); err != nil {
79+
if err = r.processIngressClassParameters(ctx, &pc, ic); err != nil {
9680
return ctrl.Result{}, err
9781
}
9882
return ctrl.Result{}, nil
@@ -174,15 +158,13 @@ func (r *ApisixPluginConfigReconciler) getDefaultIngressClass() (*networkingv1.I
174158
}
175159

176160
// processIngressClassParameters processes the IngressClass parameters that reference GatewayProxy
177-
func (r *ApisixPluginConfigReconciler) processIngressClassParameters(ctx context.Context, tc *provider.TranslateContext, pc *apiv2.ApisixPluginConfig, ingressClass *networkingv1.IngressClass) error {
161+
func (r *ApisixPluginConfigReconciler) processIngressClassParameters(ctx context.Context, pc *apiv2.ApisixPluginConfig, ingressClass *networkingv1.IngressClass) error {
178162
if ingressClass == nil || ingressClass.Spec.Parameters == nil {
179163
return nil
180164
}
181165

182166
var (
183-
ingressClassKind = utils.NamespacedNameKind(ingressClass)
184-
pcKind = utils.NamespacedNameKind(pc)
185-
parameters = ingressClass.Spec.Parameters
167+
parameters = ingressClass.Spec.Parameters
186168
)
187169
if parameters.APIGroup == nil || *parameters.APIGroup != v1alpha1.GroupVersion.Group || parameters.Kind != KindGatewayProxy {
188170
return nil
@@ -197,15 +179,7 @@ func (r *ApisixPluginConfigReconciler) processIngressClassParameters(ctx context
197179
ns = &pc.Namespace
198180
}
199181

200-
if err := r.Get(ctx, client.ObjectKey{Namespace: *ns, Name: parameters.Name}, &gatewayProxy); err != nil {
201-
r.Log.Error(err, "failed to get GatewayProxy", "namespace", *ns, "name", parameters.Name)
202-
return err
203-
}
204-
205-
tc.GatewayProxies[ingressClassKind] = gatewayProxy
206-
tc.ResourceParentRefs[pcKind] = append(tc.ResourceParentRefs[pcKind], ingressClassKind)
207-
208-
return nil
182+
return r.Get(ctx, client.ObjectKey{Namespace: *ns, Name: parameters.Name}, &gatewayProxy)
209183
}
210184

211185
func (r *ApisixPluginConfigReconciler) updateStatus(pc *apiv2.ApisixPluginConfig, err error) {

0 commit comments

Comments
 (0)