From d0c415d8d33d624a2a3a60408e8e4b771e04bc61 Mon Sep 17 00:00:00 2001 From: drfaust92 Date: Fri, 2 Feb 2024 16:32:34 +0200 Subject: [PATCH 1/2] add setting traefik version Signed-off-by: drfaust92 --- cmd/rollouts-controller/main.go | 6 ++++++ rollout/trafficrouting/traefik/traefik.go | 6 +++--- utils/defaults/defaults.go | 18 ++++++++++++++++++ utils/defaults/defaults_test.go | 10 ++++++++++ 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/cmd/rollouts-controller/main.go b/cmd/rollouts-controller/main.go index 99afcef49e..b144defca4 100644 --- a/cmd/rollouts-controller/main.go +++ b/cmd/rollouts-controller/main.go @@ -66,6 +66,8 @@ func newCommand() *cobra.Command { ingressThreads int istioVersion string trafficSplitVersion string + traefikAPIGroup string + traefikVersion string ambassadorVersion string ingressVersion string appmeshCRDVersion string @@ -102,6 +104,8 @@ func newCommand() *cobra.Command { defaults.SetAmbassadorAPIVersion(ambassadorVersion) defaults.SetSMIAPIVersion(trafficSplitVersion) defaults.SetAppMeshCRDVersion(appmeshCRDVersion) + defaults.SetTraefikAPIGroup(traefikAPIGroup) + defaults.SetTraefikVersion(traefikVersion) config, err := clientConfig.ClientConfig() checkError(err) @@ -279,6 +283,8 @@ func newCommand() *cobra.Command { command.Flags().StringVar(&istioVersion, "istio-api-version", defaults.DefaultIstioVersion, "Set the default Istio apiVersion that controller should look when manipulating VirtualServices.") command.Flags().StringVar(&ambassadorVersion, "ambassador-api-version", defaults.DefaultAmbassadorVersion, "Set the Ambassador apiVersion that controller should look when manipulating Ambassador Mappings.") command.Flags().StringVar(&trafficSplitVersion, "traffic-split-api-version", defaults.DefaultSMITrafficSplitVersion, "Set the default TrafficSplit apiVersion that controller uses when creating TrafficSplits.") + command.Flags().StringVar(&traefikAPIGroup, "traefik-api-group", defaults.DefaultTraefikAPIGroup, "Set the default Traerfik apiGroup that controller uses.") + command.Flags().StringVar(&traefikVersion, "traefik-api-version", defaults.DefaultTraefikVersion, "Set the default Traerfik apiVersion that controller uses.") command.Flags().StringVar(&ingressVersion, "ingress-api-version", "", "Set the Ingress apiVersion that the controller should use.") command.Flags().StringVar(&appmeshCRDVersion, "appmesh-crd-version", defaults.DefaultAppMeshCRDVersion, "Set the default AppMesh CRD Version that controller uses when manipulating resources.") command.Flags().StringArrayVar(&albIngressClasses, "alb-ingress-classes", defaultALBIngressClass, "Defines all the ingress class annotations that the alb ingress controller operates on. Defaults to alb") diff --git a/rollout/trafficrouting/traefik/traefik.go b/rollout/trafficrouting/traefik/traefik.go index 5840bf4a42..8b5cfb7312 100644 --- a/rollout/trafficrouting/traefik/traefik.go +++ b/rollout/trafficrouting/traefik/traefik.go @@ -25,7 +25,7 @@ const TraefikServiceUpdateError = "TraefikServiceUpdateError" var ( apiGroupToResource = map[string]string{ - defaults.DefaultTraefikAPIGroup: traefikServices, + defaults.GetTraefikAPIGroup(): traefikServices, } ) @@ -68,8 +68,8 @@ func NewDynamicClient(di dynamic.Interface, namespace string) dynamic.ResourceIn } func GetMappingGVR() schema.GroupVersionResource { - group := defaults.DefaultTraefikAPIGroup - parts := strings.Split(defaults.DefaultTraefikVersion, "/") + group := defaults.GetTraefikAPIGroup() + parts := strings.Split(defaults.GetTraefikVersion(), "/") version := parts[len(parts)-1] resourceName := apiGroupToResource[group] return schema.GroupVersionResource{ diff --git a/utils/defaults/defaults.go b/utils/defaults/defaults.go index 8c1c171219..f1c38dcef1 100644 --- a/utils/defaults/defaults.go +++ b/utils/defaults/defaults.go @@ -67,6 +67,8 @@ const ( var ( defaultVerifyTargetGroup = false + traefikAPIGroup = DefaultTraefikAPIGroup + traefikVersion = DefaultTraefikVersion istioAPIVersion = DefaultIstioVersion ambassadorAPIVersion = DefaultAmbassadorVersion smiAPIVersion = DefaultSMITrafficSplitVersion @@ -305,6 +307,22 @@ func GetSMIAPIVersion() string { return smiAPIVersion } +func SetTraefikVersion(apiVersion string) { + traefikVersion = apiVersion +} + +func GetTraefikVersion() string { + return traefikVersion +} + +func SetTraefikAPIGroup(apiGroup string) { + traefikAPIGroup = apiGroup +} + +func GetTraefikAPIGroup() string { + return traefikAPIGroup +} + func SetTargetGroupBindingAPIVersion(apiVersion string) { targetGroupBindingAPIVersion = apiVersion } diff --git a/utils/defaults/defaults_test.go b/utils/defaults/defaults_test.go index 1d981731c2..edd144d1f7 100644 --- a/utils/defaults/defaults_test.go +++ b/utils/defaults/defaults_test.go @@ -398,6 +398,16 @@ func TestSetDefaults(t *testing.T) { SetSMIAPIVersion(DefaultSMITrafficSplitVersion) assert.Equal(t, DefaultSMITrafficSplitVersion, GetSMIAPIVersion()) + SetTraefikAPIGroup("traefik.containo.us") + assert.Equal(t, "traefik.containo.us", GetTraefikAPIGroup()) + SetTraefikAPIGroup(DefaultTraefikAPIGroup) + assert.Equal(t, DefaultTraefikAPIGroup, GetTraefikAPIGroup()) + + SetTraefikVersion("traefik.containo.us/v1alpha1") + assert.Equal(t, "traefik.containo.us/v1alpha1", GetTraefikVersion()) + SetTraefikVersion(DefaultTraefikVersion) + assert.Equal(t, DefaultTraefikVersion, GetTraefikVersion()) + SetTargetGroupBindingAPIVersion("v1alpha9") assert.Equal(t, "v1alpha9", GetTargetGroupBindingAPIVersion()) SetTargetGroupBindingAPIVersion(DefaultTargetGroupBindingAPIVersion) From c23ab553d86a53282c17efacd7c838411f010138 Mon Sep 17 00:00:00 2001 From: drfaust92 Date: Mon, 5 Feb 2024 00:41:18 +0200 Subject: [PATCH 2/2] add new traefik api to manifests Signed-off-by: drfaust92 --- manifests/install.yaml | 1 + manifests/namespace-install.yaml | 1 + manifests/role/argo-rollouts-clusterrole.yaml | 1 + 3 files changed, 3 insertions(+) diff --git a/manifests/install.yaml b/manifests/install.yaml index 082042a0ca..335974305f 100755 --- a/manifests/install.yaml +++ b/manifests/install.yaml @@ -15825,6 +15825,7 @@ rules: - patch - apiGroups: - traefik.containo.us + - traefik.io resources: - traefikservices verbs: diff --git a/manifests/namespace-install.yaml b/manifests/namespace-install.yaml index 97847970ee..08637705cb 100644 --- a/manifests/namespace-install.yaml +++ b/manifests/namespace-install.yaml @@ -217,6 +217,7 @@ rules: - patch - apiGroups: - traefik.containo.us + - traefik.io resources: - traefikservices verbs: diff --git a/manifests/role/argo-rollouts-clusterrole.yaml b/manifests/role/argo-rollouts-clusterrole.yaml index 95cc82004d..aab253e5ea 100644 --- a/manifests/role/argo-rollouts-clusterrole.yaml +++ b/manifests/role/argo-rollouts-clusterrole.yaml @@ -224,6 +224,7 @@ rules: - patch - apiGroups: - traefik.containo.us + - traefik.io resources: - traefikservices verbs: