Skip to content
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

feat: allow setting traefik versions #3348

Merged
merged 2 commits into from
Feb 13, 2024
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
6 changes: 6 additions & 0 deletions cmd/rollouts-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ func newCommand() *cobra.Command {
ingressThreads int
istioVersion string
trafficSplitVersion string
traefikAPIGroup string
traefikVersion string
ambassadorVersion string
ingressVersion string
appmeshCRDVersion string
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions manifests/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15825,6 +15825,7 @@ rules:
- patch
- apiGroups:
- traefik.containo.us
- traefik.io
resources:
- traefikservices
verbs:
Expand Down
1 change: 1 addition & 0 deletions manifests/namespace-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ rules:
- patch
- apiGroups:
- traefik.containo.us
- traefik.io
resources:
- traefikservices
verbs:
Expand Down
1 change: 1 addition & 0 deletions manifests/role/argo-rollouts-clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ rules:
- patch
- apiGroups:
- traefik.containo.us
- traefik.io
resources:
- traefikservices
verbs:
Expand Down
6 changes: 3 additions & 3 deletions rollout/trafficrouting/traefik/traefik.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const TraefikServiceUpdateError = "TraefikServiceUpdateError"

var (
apiGroupToResource = map[string]string{
defaults.DefaultTraefikAPIGroup: traefikServices,
defaults.GetTraefikAPIGroup(): traefikServices,
}
)

Expand Down Expand Up @@ -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{
Expand Down
18 changes: 18 additions & 0 deletions utils/defaults/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ const (

var (
defaultVerifyTargetGroup = false
traefikAPIGroup = DefaultTraefikAPIGroup
traefikVersion = DefaultTraefikVersion
istioAPIVersion = DefaultIstioVersion
ambassadorAPIVersion = DefaultAmbassadorVersion
smiAPIVersion = DefaultSMITrafficSplitVersion
Expand Down Expand Up @@ -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
}
Expand Down
10 changes: 10 additions & 0 deletions utils/defaults/defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading