Skip to content

Commit 76c1e79

Browse files
committed
support k8s < v1.19 & watch-ingress-without-class
1 parent 418a9a1 commit 76c1e79

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

deploy/addons/ingress/ingress-deploy.yaml.tmpl

+2-2
Original file line numberDiff line numberDiff line change
@@ -365,12 +365,12 @@ spec:
365365
- --election-id=ingress-controller-leader
366366
{{- if eq .IngressAPIVersion "v1"}}
367367
- --controller-class=k8s.io/ingress-nginx
368+
- --watch-ingress-without-class=true
368369
{{- end}}
369370
{{- if eq .IngressAPIVersion "v1beta1"}}
370371
- --ingress-class=nginx
371-
- --watch-ingress-without-class=true
372-
- --publish-status-address=localhost
373372
{{- end}}
373+
- --publish-status-address=localhost
374374
- --configmap=$(POD_NAMESPACE)/ingress-nginx-controller
375375
- --report-node-internal-ip-address
376376
- --tcp-services-configmap=$(POD_NAMESPACE)/tcp-services

pkg/addons/addons.go

+10-15
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,13 @@ func EnableOrDisableAddon(cc *config.ClusterConfig, name string, val string) err
179179
exit.Error(reason.GuestCpConfig, "Error getting primary control plane", err)
180180
}
181181

182+
// maintain backwards compatibility for ingress with k8s < v1.19
183+
if strings.HasPrefix(name, "ingress") && enable {
184+
if err := supportLegacyIngress(addon, *cc); err != nil {
185+
return err
186+
}
187+
}
188+
182189
// Persist images even if the machine is running so starting gets the correct images.
183190
images, customRegistries, err := assets.SelectAndPersistImages(addon, cc)
184191
if err != nil {
@@ -229,9 +236,6 @@ func addonSpecificChecks(cc *config.ClusterConfig, name string, enable bool, run
229236
out.Styled(style.Tip, `After the addon is enabled, please run "minikube tunnel" and your ingress resources would be available at "127.0.0.1"`)
230237
}
231238
}
232-
if err := supportLegacyIngress(cc); err != nil {
233-
return false, err
234-
}
235239
}
236240

237241
if strings.HasPrefix(name, "istio") && enable {
@@ -290,29 +294,20 @@ func isAddonAlreadySet(cc *config.ClusterConfig, addon *assets.Addon, enable boo
290294
return false
291295
}
292296

293-
// maintain backwards compatibility with k8s < v1.19
294-
// by replacing images with old versions if custom ones are not already provided
295-
func supportLegacyIngress(cc *config.ClusterConfig) error {
297+
// maintain backwards compatibility for ingress with k8s < v1.19 by replacing default addon images with older versions
298+
func supportLegacyIngress(addon *assets.Addon, cc config.ClusterConfig) error {
296299
v, err := util.ParseKubernetesVersion(cc.KubernetesConfig.KubernetesVersion)
297300
if err != nil {
298301
return errors.Wrap(err, "parsing Kubernetes version")
299302
}
300303
if semver.MustParseRange("<1.19.0")(v) {
301-
imgs := map[string]string{
304+
addon.Images = map[string]string{
302305
// https://github.com/kubernetes/ingress-nginx/blob/0a2ec01eb4ec0e1b29c4b96eb838a2e7bfe0e9f6/deploy/static/provider/kind/deploy.yaml#L328
303306
"IngressController": "ingress-nginx/controller:v0.49.3@sha256:35fe394c82164efa8f47f3ed0be981b3f23da77175bbb8268a9ae438851c8324",
304307
// issues: https://github.com/kubernetes/ingress-nginx/issues/7418 and https://github.com/jet/kube-webhook-certgen/issues/30
305308
"KubeWebhookCertgenCreate": "docker.io/jettech/kube-webhook-certgen:v1.5.1@sha256:950833e19ade18cd389d647efb88992a7cc077abedef343fa59e012d376d79b7",
306309
"KubeWebhookCertgenPatch": "docker.io/jettech/kube-webhook-certgen:v1.5.1@sha256:950833e19ade18cd389d647efb88992a7cc077abedef343fa59e012d376d79b7",
307310
}
308-
if cc.CustomAddonImages == nil {
309-
cc.CustomAddonImages = map[string]string{}
310-
}
311-
for name, path := range imgs {
312-
if _, exists := cc.CustomAddonImages[name]; !exists {
313-
cc.CustomAddonImages[name] = path
314-
}
315-
}
316311
}
317312
return nil
318313
}

0 commit comments

Comments
 (0)