diff --git a/cmd/minikube/cmd/config/enable.go b/cmd/minikube/cmd/config/enable.go index d16597f4bd2e..14a833cd1434 100644 --- a/cmd/minikube/cmd/config/enable.go +++ b/cmd/minikube/cmd/config/enable.go @@ -20,7 +20,9 @@ import ( "fmt" "github.com/spf13/cobra" + "github.com/spf13/viper" "k8s.io/minikube/pkg/addons" + "k8s.io/minikube/pkg/minikube/config" "k8s.io/minikube/pkg/minikube/constants" "k8s.io/minikube/pkg/minikube/exit" "k8s.io/minikube/pkg/minikube/out" @@ -29,9 +31,10 @@ import ( ) var addonsEnableCmd = &cobra.Command{ - Use: "enable ADDON_NAME", - Short: "Enables the addon w/ADDON_NAME within minikube (example: minikube addons enable dashboard). For a list of available addons use: minikube addons list ", - Long: "Enables the addon w/ADDON_NAME within minikube (example: minikube addons enable dashboard). For a list of available addons use: minikube addons list ", + Use: "enable ADDON_NAME", + Short: "Enables the addon w/ADDON_NAME within minikube. For a list of available addons use: minikube addons list ", + Long: "Enables the addon w/ADDON_NAME within minikube. For a list of available addons use: minikube addons list ", + Example: "minikube addons enable dashboard", Run: func(cmd *cobra.Command, args []string) { if len(args) != 1 { exit.Message(reason.Usage, "usage: minikube addons enable ADDON_NAME") @@ -42,6 +45,8 @@ var addonsEnableCmd = &cobra.Command{ out.Step(style.Waiting, "enable metrics-server addon instead of heapster addon because heapster is deprecated") addon = "metrics-server" } + viper.Set(config.AddonImages, images) + viper.Set(config.AddonRegistries, registries) err := addons.SetAndSave(ClusterFlagValue(), addon, "true") if err != nil { exit.Error(reason.InternalEnable, "enable failed", err) @@ -63,6 +68,13 @@ var addonsEnableCmd = &cobra.Command{ }, } +var ( + images string + registries string +) + func init() { + addonsEnableCmd.Flags().StringVar(&images, "images", "", "Images used by this addon. Separated by commas.") + addonsEnableCmd.Flags().StringVar(®istries, "registries", "", "Registries used by this addon. Separated by commas.") AddonsCmd.AddCommand(addonsEnableCmd) } diff --git a/cmd/minikube/cmd/config/images.go b/cmd/minikube/cmd/config/images.go new file mode 100644 index 000000000000..c18ab35d7c85 --- /dev/null +++ b/cmd/minikube/cmd/config/images.go @@ -0,0 +1,70 @@ +/* +Copyright 2016 The Kubernetes Authors All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package config + +import ( + "os" + + "github.com/olekukonko/tablewriter" + "github.com/spf13/cobra" + "k8s.io/minikube/pkg/minikube/assets" + "k8s.io/minikube/pkg/minikube/exit" + "k8s.io/minikube/pkg/minikube/out" + "k8s.io/minikube/pkg/minikube/reason" +) + +var addonsImagesCmd = &cobra.Command{ + Use: "images ADDON_NAME", + Short: "List image names the addon w/ADDON_NAME used. For a list of available addons use: minikube addons list", + Long: "List image names the addon w/ADDON_NAME used. For a list of available addons use: minikube addons list", + Example: "minikube addons images ingress", + Run: func(cmd *cobra.Command, args []string) { + if len(args) != 1 { + exit.Message(reason.Usage, "usage: minikube addons images ADDON_NAME") + } + + addon := args[0] + // allows for additional prompting of information when enabling addons + if conf, ok := assets.Addons[addon]; ok { + if conf.Images != nil { + out.Infof("{{.name}} has following images:", out.V{"name": addon}) + + var tData [][]string + table := tablewriter.NewWriter(os.Stdout) + table.SetHeader([]string{"Image Name", "Default Image", "Default Registry"}) + table.SetAutoFormatHeaders(true) + table.SetBorders(tablewriter.Border{Left: true, Top: true, Right: true, Bottom: true}) + table.SetCenterSeparator("|") + + for imageName, defaultImage := range conf.Images { + tData = append(tData, []string{imageName, defaultImage, conf.Registries[imageName]}) + } + + table.AppendBulk(tData) + table.Render() + } else { + out.Infof("{{.name}} doesn't have images.", out.V{"name": addon}) + } + } else { + out.FailureT("No such addon {{.name}}", out.V{"name": addon}) + } + }, +} + +func init() { + AddonsCmd.AddCommand(addonsImagesCmd) +} diff --git a/deploy/addons/ambassador/ambassador-operator.yaml.tmpl b/deploy/addons/ambassador/ambassador-operator.yaml.tmpl index be939dd31bb1..be939fef2ab4 100644 --- a/deploy/addons/ambassador/ambassador-operator.yaml.tmpl +++ b/deploy/addons/ambassador/ambassador-operator.yaml.tmpl @@ -180,10 +180,10 @@ spec: containers: - name: ambassador-operator # Replace this with the built image name - image: {{default "quay.io/datawire" .ImageRepository}}/ambassador-operator:v1.2.3 + image: {{.CustomRegistries.AmbassadorOperator | default .ImageRepository | default .Registries.AmbassadorOperator }}{{.Images.AmbassadorOperator}} command: - ambassador-operator - imagePullPolicy: Always + imagePullPolicy: IfNotPresent env: - name: WATCH_NAMESPACE valueFrom: diff --git a/deploy/addons/csi-hostpath-driver/deploy/csi-hostpath-attacher.yaml.tmpl b/deploy/addons/csi-hostpath-driver/deploy/csi-hostpath-attacher.yaml.tmpl index d9642f7d1d62..6f3026544d48 100644 --- a/deploy/addons/csi-hostpath-driver/deploy/csi-hostpath-attacher.yaml.tmpl +++ b/deploy/addons/csi-hostpath-driver/deploy/csi-hostpath-attacher.yaml.tmpl @@ -57,7 +57,7 @@ spec: serviceAccountName: csi-attacher containers: - name: csi-attacher - image: {{default "quay.io/k8scsi" .ImageRepository}}/csi-attacher:v3.0.0-rc1 + image: {{.CustomRegistries.Attacher | default .ImageRepository | default .Registries.Attacher }}{{.Images.Attacher}} args: - --v=5 - --csi-address=/csi/csi.sock diff --git a/deploy/addons/csi-hostpath-driver/deploy/csi-hostpath-plugin.yaml.tmpl b/deploy/addons/csi-hostpath-driver/deploy/csi-hostpath-plugin.yaml.tmpl index fe73c8ff17d3..ed884880dcc0 100644 --- a/deploy/addons/csi-hostpath-driver/deploy/csi-hostpath-plugin.yaml.tmpl +++ b/deploy/addons/csi-hostpath-driver/deploy/csi-hostpath-plugin.yaml.tmpl @@ -53,7 +53,7 @@ spec: spec: containers: - name: node-driver-registrar - image: {{default "quay.io/k8scsi" .ImageRepository}}/csi-node-driver-registrar:v1.3.0 + image: {{.CustomRegistries.NodeDriverRegistrar | default .ImageRepository | default .Registries.NodeDriverRegistrar }}{{.Images.NodeDriverRegistrar}} args: - --v=5 - --csi-address=/csi/csi.sock @@ -78,7 +78,7 @@ spec: name: csi-data-dir - name: hostpath - image: {{default "quay.io/k8scsi" .ImageRepository}}/hostpathplugin:v1.4.0-rc2 + image: {{.CustomRegistries.HostPathPlugin | default .ImageRepository | default .Registries.HostPathPlugin }}{{.Images.HostPathPlugin}} args: - "--drivername=hostpath.csi.k8s.io" - "--v=5" @@ -123,7 +123,7 @@ spec: volumeMounts: - mountPath: /csi name: socket-dir - image: {{default "quay.io/k8scsi" .ImageRepository}}/livenessprobe:v1.1.0 + image: {{.CustomRegistries.LivenessProbe | default .ImageRepository | default .Registries.LivenessProbe }}{{.Images.LivenessProbe}} args: - --csi-address=/csi/csi.sock - --health-port=9898 diff --git a/deploy/addons/csi-hostpath-driver/deploy/csi-hostpath-provisioner.yaml.tmpl b/deploy/addons/csi-hostpath-driver/deploy/csi-hostpath-provisioner.yaml.tmpl index 245f6e19ae6e..b974204eb8bc 100644 --- a/deploy/addons/csi-hostpath-driver/deploy/csi-hostpath-provisioner.yaml.tmpl +++ b/deploy/addons/csi-hostpath-driver/deploy/csi-hostpath-provisioner.yaml.tmpl @@ -57,7 +57,7 @@ spec: serviceAccountName: csi-provisioner containers: - name: csi-provisioner - image: {{default "gcr.io/k8s-staging-sig-storage" .ImageRepository}}/csi-provisioner:v2.0.0-rc2 + image: {{.CustomRegistries.Provisioner | default .ImageRepository | default .Registries.Provisioner }}{{.Images.Provisioner}} args: - -v=5 - --csi-address=/csi/csi.sock diff --git a/deploy/addons/csi-hostpath-driver/deploy/csi-hostpath-resizer.yaml.tmpl b/deploy/addons/csi-hostpath-driver/deploy/csi-hostpath-resizer.yaml.tmpl index 24a09099cc3a..1d881293ee54 100644 --- a/deploy/addons/csi-hostpath-driver/deploy/csi-hostpath-resizer.yaml.tmpl +++ b/deploy/addons/csi-hostpath-driver/deploy/csi-hostpath-resizer.yaml.tmpl @@ -57,7 +57,7 @@ spec: serviceAccountName: csi-resizer containers: - name: csi-resizer - image: {{default "quay.io/k8scsi" .ImageRepository}}/csi-resizer:v0.6.0-rc1 + image: {{.CustomRegistries.Resizer | default .ImageRepository | default .Registries.Resizer }}{{.Images.Resizer}} args: - -v=5 - -csi-address=/csi/csi.sock diff --git a/deploy/addons/csi-hostpath-driver/deploy/csi-hostpath-snapshotter.yaml.tmpl b/deploy/addons/csi-hostpath-driver/deploy/csi-hostpath-snapshotter.yaml.tmpl index dcceec8d7d79..1da7e3fa9350 100644 --- a/deploy/addons/csi-hostpath-driver/deploy/csi-hostpath-snapshotter.yaml.tmpl +++ b/deploy/addons/csi-hostpath-driver/deploy/csi-hostpath-snapshotter.yaml.tmpl @@ -57,7 +57,7 @@ spec: serviceAccount: csi-snapshotter containers: - name: csi-snapshotter - image: {{default "quay.io/k8scsi" .ImageRepository}}/csi-snapshotter:v2.1.0 + image: {{.CustomRegistries.Snapshotter | default .ImageRepository | default .Registries.Snapshotter }}{{.Images.Snapshotter}} args: - -v=5 - --csi-address=/csi/csi.sock diff --git a/deploy/addons/dashboard/dashboard-dp.yaml.tmpl b/deploy/addons/dashboard/dashboard-dp.yaml.tmpl index 2a3fb09f726b..ef76cdd6ad04 100644 --- a/deploy/addons/dashboard/dashboard-dp.yaml.tmpl +++ b/deploy/addons/dashboard/dashboard-dp.yaml.tmpl @@ -36,7 +36,7 @@ spec: spec: containers: - name: dashboard-metrics-scraper - image: {{default "kubernetesui" .ImageRepository}}/metrics-scraper:v1.0.4 + image: {{.CustomRegistries.MetricsScraper | default .ImageRepository | default .Registries.MetricsScraper }}{{.Images.MetricsScraper}} ports: - containerPort: 8000 protocol: TCP @@ -91,7 +91,7 @@ spec: containers: - name: kubernetes-dashboard # WARNING: This must match pkg/minikube/bootstrapper/images/images.go - image: {{default "kubernetesui" .ImageRepository}}/dashboard:v2.1.0 + image: {{.CustomRegistries.Dashboard | default .ImageRepository | default .Registries.Dashboard }}{{.Images.Dashboard}} ports: - containerPort: 9090 protocol: TCP diff --git a/deploy/addons/efk/elasticsearch-rc.yaml.tmpl b/deploy/addons/efk/elasticsearch-rc.yaml.tmpl index 096c4b3390c1..466891219f87 100644 --- a/deploy/addons/efk/elasticsearch-rc.yaml.tmpl +++ b/deploy/addons/efk/elasticsearch-rc.yaml.tmpl @@ -34,7 +34,7 @@ spec: spec: containers: - name: elasticsearch-logging - image: {{default "k8s.gcr.io" .ImageRepository}}/elasticsearch:v5.6.2 + image: {{.CustomRegistries.Elasticsearch | default .ImageRepository | default .Registries.Elasticsearch }}{{.Images.Elasticsearch}} resources: limits: cpu: 500m @@ -62,7 +62,7 @@ spec: - name: ES_JAVA_OPTS value: "-Xms1024m -Xmx1024m" initContainers: - - image: {{default "registry.hub.docker.com/library" .ImageRepository}}/alpine:3.6 + - image: {{.CustomRegistries.Alpine | default .ImageRepository | default .Registries.Alpine }}{{.Images.Alpine}} command: ["/sbin/sysctl", "-w", "vm.max_map_count=262144"] name: elasticsearch-logging-init securityContext: diff --git a/deploy/addons/efk/fluentd-es-rc.yaml.tmpl b/deploy/addons/efk/fluentd-es-rc.yaml.tmpl index 75e38698417c..d43282982c5e 100644 --- a/deploy/addons/efk/fluentd-es-rc.yaml.tmpl +++ b/deploy/addons/efk/fluentd-es-rc.yaml.tmpl @@ -31,7 +31,7 @@ spec: spec: containers: - name: fluentd-es - image: {{default "k8s.gcr.io" .ImageRepository}}/fluentd-elasticsearch:v2.0.2 + image: {{.CustomRegistries.FluentdElasticsearch | default .ImageRepository | default .Registries.FluentdElasticsearch }}{{.Images.FluentdElasticsearch}} env: - name: FLUENTD_ARGS value: --no-supervisor -q diff --git a/deploy/addons/efk/kibana-rc.yaml.tmpl b/deploy/addons/efk/kibana-rc.yaml.tmpl index 07305a65ae76..ed541e49b08f 100644 --- a/deploy/addons/efk/kibana-rc.yaml.tmpl +++ b/deploy/addons/efk/kibana-rc.yaml.tmpl @@ -34,7 +34,7 @@ spec: spec: containers: - name: kibana-logging - image: {{default "docker.elastic.co/kibana" .ImageRepository}}/kibana:5.6.2 + image: {{.CustomRegistries.Kibana | default .ImageRepository | default .Registries.Kibana }}{{.Images.Kibana}} resources: limits: cpu: 500m diff --git a/deploy/addons/freshpod/freshpod-rc.yaml.tmpl b/deploy/addons/freshpod/freshpod-rc.yaml.tmpl index 6d2b9ba5b764..70e380794017 100644 --- a/deploy/addons/freshpod/freshpod-rc.yaml.tmpl +++ b/deploy/addons/freshpod/freshpod-rc.yaml.tmpl @@ -34,7 +34,7 @@ spec: spec: containers: - name: freshpod - image: {{default "gcr.io/google-samples" .ImageRepository}}/freshpod:v0.0.1 + image: {{.CustomRegistries.FreshPod | default .ImageRepository | default .Registries.FreshPod }}{{.Images.FreshPod}} imagePullPolicy: IfNotPresent volumeMounts: - name: docker diff --git a/deploy/addons/gcp-auth/gcp-auth-webhook.yaml.tmpl.tmpl b/deploy/addons/gcp-auth/gcp-auth-webhook.yaml.tmpl.tmpl index b6dd98f60e57..149a84a7887c 100644 --- a/deploy/addons/gcp-auth/gcp-auth-webhook.yaml.tmpl.tmpl +++ b/deploy/addons/gcp-auth/gcp-auth-webhook.yaml.tmpl.tmpl @@ -68,7 +68,7 @@ spec: serviceAccountName: minikube-gcp-auth-certs containers: - name: create - image: {{default "jettech" .ImageRepository}}/kube-webhook-certgen:v1.3.0 + image: {{.CustomRegistries.KubeWebhookCertgen | default .ImageRepository | default .Registries.KubeWebhookCertgen }}{{.Images.KubeWebhookCertgen}} imagePullPolicy: IfNotPresent args: - create @@ -94,7 +94,7 @@ spec: spec: containers: - name: gcp-auth - image: {{default "gcr.io/k8s-minikube" .ImageRepository}}/gcp-auth-webhook:v0.0.3 + image: {{.CustomRegistries.GCPAuthWebhook | default .ImageRepository | default .Registries.GCPAuthWebhook }}{{.Images.GCPAuthWebhook}} imagePullPolicy: IfNotPresent ports: - containerPort: 8443 @@ -127,7 +127,7 @@ spec: serviceAccountName: minikube-gcp-auth-certs containers: - name: patch - image: {{default "jettech" .ImageRepository}}/kube-webhook-certgen:v1.3.0 + image: {{.CustomRegistries.KubeWebhookCertgen | default .ImageRepository | default .Registries.KubeWebhookCertgen }}{{.Images.KubeWebhookCertgen}} imagePullPolicy: IfNotPresent args: - patch diff --git a/deploy/addons/gpu/nvidia-driver-installer.yaml.tmpl b/deploy/addons/gpu/nvidia-driver-installer.yaml.tmpl index 231f82bc687c..0c4978a82685 100644 --- a/deploy/addons/gpu/nvidia-driver-installer.yaml.tmpl +++ b/deploy/addons/gpu/nvidia-driver-installer.yaml.tmpl @@ -50,7 +50,7 @@ spec: hostPath: path: / initContainers: - - image: {{default "k8s.gcr.io" .ImageRepository}}/minikube-nvidia-driver-installer:e2d9b43228decf5d6f7dce3f0a85d390f138fa01 + - image: {{.CustomRegistries.NvidiaDriverInstaller | default .ImageRepository | default .Registries.NvidiaDriverInstaller }}{{.Images.NvidiaDriverInstaller}} name: nvidia-driver-installer resources: requests: @@ -72,5 +72,5 @@ spec: - name: root-mount mountPath: /root containers: - - image: "{{default "k8s.gcr.io" .ImageRepository}}/pause:2.0" + - image: "{{default "k8s.gcr.io" .ImageRepository}}/{{.Images.Pause}}" name: pause diff --git a/deploy/addons/gpu/nvidia-gpu-device-plugin.yaml.tmpl b/deploy/addons/gpu/nvidia-gpu-device-plugin.yaml.tmpl index b53a98ebfdec..e1e695866e11 100644 --- a/deploy/addons/gpu/nvidia-gpu-device-plugin.yaml.tmpl +++ b/deploy/addons/gpu/nvidia-gpu-device-plugin.yaml.tmpl @@ -43,7 +43,7 @@ spec: hostPath: path: /var/lib/kubelet/device-plugins containers: - - image: {{default "nvidia" .ImageRepository}}/k8s-device-plugin:1.0.0-beta4 + - image: {{.CustomRegistries.NvidiaDevicePlugin | default .ImageRepository | default .Registries.NvidiaDevicePlugin }}{{.Images.NvidiaDevicePlugin}} command: ["/usr/bin/nvidia-device-plugin", "-logtostderr"] name: nvidia-gpu-device-plugin resources: diff --git a/deploy/addons/gvisor/gvisor-pod.yaml.tmpl b/deploy/addons/gvisor/gvisor-pod.yaml.tmpl index 313f020fb449..648ef38ef9af 100644 --- a/deploy/addons/gvisor/gvisor-pod.yaml.tmpl +++ b/deploy/addons/gvisor/gvisor-pod.yaml.tmpl @@ -25,7 +25,7 @@ spec: hostPID: true containers: - name: gvisor - image: {{default "gcr.io/k8s-minikube" .ImageRepository}}/gvisor-addon:3 + image: {{.CustomRegistries.GvisorAddon | default .ImageRepository | default .Registries.GvisorAddon }}{{.Images.GvisorAddon}} securityContext: privileged: true volumeMounts: diff --git a/deploy/addons/helm-tiller/helm-tiller-dp.tmpl b/deploy/addons/helm-tiller/helm-tiller-dp.tmpl index cdbc92e96732..ed44d410cf04 100644 --- a/deploy/addons/helm-tiller/helm-tiller-dp.tmpl +++ b/deploy/addons/helm-tiller/helm-tiller-dp.tmpl @@ -46,7 +46,7 @@ spec: value: kube-system - name: TILLER_HISTORY_MAX value: "0" - image: {{default "gcr.io/kubernetes-helm" .ImageRepository}}/tiller:v2.16.12 + image: {{.CustomRegistries.Tiller | default .ImageRepository | default .Registries.Tiller }}{{.Images.Tiller}} imagePullPolicy: IfNotPresent livenessProbe: failureThreshold: 3 diff --git a/deploy/addons/ingress-dns/ingress-dns-pod.yaml.tmpl b/deploy/addons/ingress-dns/ingress-dns-pod.yaml.tmpl index 8db1b9dba767..bb0e7c1b3fab 100644 --- a/deploy/addons/ingress-dns/ingress-dns-pod.yaml.tmpl +++ b/deploy/addons/ingress-dns/ingress-dns-pod.yaml.tmpl @@ -80,7 +80,7 @@ spec: hostNetwork: true containers: - name: minikube-ingress-dns - image: {{default "cryptexlabs" .ImageRepository}}/minikube-ingress-dns:0.3.0 + image: {{.CustomRegistries.IngressDNS | default .ImageRepository | default .Registries.IngressDNS }}{{.Images.IngressDNS}} imagePullPolicy: IfNotPresent ports: - containerPort: 53 diff --git a/deploy/addons/ingress/ingress-dp.yaml.tmpl b/deploy/addons/ingress/ingress-dp.yaml.tmpl index fda40ff2bae0..39bc372a3c18 100644 --- a/deploy/addons/ingress/ingress-dp.yaml.tmpl +++ b/deploy/addons/ingress/ingress-dp.yaml.tmpl @@ -49,7 +49,7 @@ spec: serviceAccountName: ingress-nginx containers: - name: controller - image: {{default "us.gcr.io/k8s-artifacts-prod/ingress-nginx" .ImageRepository}}/controller:v0.40.2 + image: {{.CustomRegistries.IngressController | default .ImageRepository | default .Registries.IngressController }}{{.Images.IngressController}} imagePullPolicy: IfNotPresent lifecycle: preStop: @@ -220,7 +220,7 @@ spec: spec: containers: - name: create - image: {{default "jettech" .ImageRepository}}/kube-webhook-certgen:v1.2.2 + image: {{.CustomRegistries.KubeWebhookCertgenCreate | default .ImageRepository | default .Registries.KubeWebhookCertgenCreate }}{{.Images.KubeWebhookCertgenCreate}} imagePullPolicy: IfNotPresent args: - create @@ -255,7 +255,7 @@ spec: spec: containers: - name: patch - image: {{default "jettech" .ImageRepository}}/kube-webhook-certgen:v1.3.0 + image: {{.CustomRegistries.KubeWebhookCertgenPatch | default .ImageRepository | default .Registries.KubeWebhookCertgenPatch }}{{.Images.KubeWebhookCertgenPatch}} imagePullPolicy: args: - patch diff --git a/deploy/addons/istio-provisioner/istio-operator.yaml.tmpl b/deploy/addons/istio-provisioner/istio-operator.yaml.tmpl index 06b0ba995d43..6c5f23118b79 100644 --- a/deploy/addons/istio-provisioner/istio-operator.yaml.tmpl +++ b/deploy/addons/istio-provisioner/istio-operator.yaml.tmpl @@ -218,11 +218,11 @@ spec: serviceAccountName: istio-operator containers: - name: istio-operator - image: docker.io/istio/operator:1.5.0 + image: {{.CustomRegistries.IstioOperator | default .ImageRepository | default .Registries.IstioOperator }}{{.Images.IstioOperator}} command: - operator - server - imagePullPolicy: Always + imagePullPolicy: IfNotPresent resources: limits: cpu: 200m diff --git a/deploy/addons/kubevirt/pod.yaml.tmpl b/deploy/addons/kubevirt/pod.yaml.tmpl index 4b8b8b8616d8..ae575b783ae7 100644 --- a/deploy/addons/kubevirt/pod.yaml.tmpl +++ b/deploy/addons/kubevirt/pod.yaml.tmpl @@ -50,7 +50,7 @@ spec: - /bin/bash - -c - /kubevirt-scripts/install.sh - image: bitnami/kubectl:1.17 + image: {{.CustomRegistries.Kubectl | default .ImageRepository | default .Registries.Kubectl }}{{.Images.Kubectl}} imagePullPolicy: IfNotPresent name: kubevirt-provisioner lifecycle: diff --git a/deploy/addons/logviewer/logviewer-dp-and-svc.yaml.tmpl b/deploy/addons/logviewer/logviewer-dp-and-svc.yaml.tmpl index 912c6e617fcf..2c10bc9f7624 100644 --- a/deploy/addons/logviewer/logviewer-dp-and-svc.yaml.tmpl +++ b/deploy/addons/logviewer/logviewer-dp-and-svc.yaml.tmpl @@ -41,8 +41,8 @@ spec: serviceAccountName: sa-logviewer containers: - name: logviewer - imagePullPolicy: Always - image: {{default "docker.io/ivans3" .ImageRepository}}/minikube-log-viewer:latest + imagePullPolicy: IfNotPresent + image: {{.CustomRegistries.LogViewer | default .ImageRepository | default .Registries.LogViewer }}{{.Images.LogViewer}} volumeMounts: - name: logs mountPath: /var/log/containers/ diff --git a/deploy/addons/metallb/metallb.yaml.tmpl b/deploy/addons/metallb/metallb.yaml.tmpl index 8cf8ddab961c..7d033b69e7cf 100644 --- a/deploy/addons/metallb/metallb.yaml.tmpl +++ b/deploy/addons/metallb/metallb.yaml.tmpl @@ -212,7 +212,7 @@ spec: valueFrom: fieldRef: fieldPath: status.hostIP - image: {{default "metallb" .ImageRepository}}/speaker:v0.8.2 + image: {{.CustomRegistries.Speaker | default .ImageRepository | default .Registries.Speaker }}{{.Images.Speaker}} imagePullPolicy: IfNotPresent name: speaker ports: @@ -268,7 +268,7 @@ spec: - args: - --port=7472 - --config=config - image: {{default "metallb" .ImageRepository}}/controller:v0.8.2 + image: {{.CustomRegistries.Controller | default .ImageRepository | default .Registries.Controller }}{{.Images.Controller}} imagePullPolicy: IfNotPresent name: controller ports: diff --git a/deploy/addons/metrics-server/metrics-server-deployment.yaml.tmpl b/deploy/addons/metrics-server/metrics-server-deployment.yaml.tmpl index 7fcc530a1643..19a92e27a805 100644 --- a/deploy/addons/metrics-server/metrics-server-deployment.yaml.tmpl +++ b/deploy/addons/metrics-server/metrics-server-deployment.yaml.tmpl @@ -19,7 +19,7 @@ spec: spec: containers: - name: metrics-server - image: {{default "k8s.gcr.io" .ImageRepository}}/metrics-server-{{.Arch}}:v0.2.1 + image: {{.CustomRegistries.MetricsServer | default .ImageRepository | default .Registries.MetricsServer }}{{.Images.MetricsServer}} imagePullPolicy: IfNotPresent command: - /metrics-server diff --git a/deploy/addons/olm/olm.yaml.tmpl b/deploy/addons/olm/olm.yaml.tmpl index e034a9604d8d..c3dd5755eb62 100644 --- a/deploy/addons/olm/olm.yaml.tmpl +++ b/deploy/addons/olm/olm.yaml.tmpl @@ -82,7 +82,7 @@ spec: - $(OPERATOR_NAMESPACE) - -writeStatusName - "" - image: quay.io/operator-framework/olm@sha256:0d15ffb5d10a176ef6e831d7865f98d51255ea5b0d16403618c94a004d049373 + image: {{.CustomRegistries.OLM | default .ImageRepository | default .Registries.OLM }}{{.Images.OLM}} imagePullPolicy: IfNotPresent ports: - containerPort: 8080 @@ -143,7 +143,7 @@ spec: - '-namespace' - olm - -configmapServerImage=quay.io/operator-framework/configmap-operator-registry:latest - image: quay.io/operator-framework/olm@sha256:0d15ffb5d10a176ef6e831d7865f98d51255ea5b0d16403618c94a004d049373 + image: {{.CustomRegistries.OLM | default .ImageRepository | default .Registries.OLM }}{{.Images.OLM}} imagePullPolicy: IfNotPresent ports: - containerPort: 8080 @@ -307,8 +307,8 @@ spec: - "5443" - --global-namespace - olm - image: quay.io/operator-framework/olm@sha256:0d15ffb5d10a176ef6e831d7865f98d51255ea5b0d16403618c94a004d049373 - imagePullPolicy: Always + image: {{.CustomRegistries.OLM | default .ImageRepository | default .Registries.OLM }}{{.Images.OLM}} + imagePullPolicy: IfNotPresent ports: - containerPort: 5443 livenessProbe: @@ -346,6 +346,6 @@ metadata: namespace: olm spec: sourceType: grpc - image: quay.io/operator-framework/upstream-community-operators:latest + image: {{.CustomRegistries.UpstreamCommunityOperators | default .ImageRepository | default .Registries.UpstreamCommunityOperators }}{{.Images.UpstreamCommunityOperators}} displayName: Community Operators publisher: OperatorHub.io \ No newline at end of file diff --git a/deploy/addons/registry-aliases/node-etc-hosts-update.tmpl b/deploy/addons/registry-aliases/node-etc-hosts-update.tmpl index 1294201a358d..4df44d41952e 100644 --- a/deploy/addons/registry-aliases/node-etc-hosts-update.tmpl +++ b/deploy/addons/registry-aliases/node-etc-hosts-update.tmpl @@ -17,7 +17,7 @@ spec: spec: initContainers: - name: update - image: {{default "registry.hub.docker.com/library" .ImageRepository}}/alpine:3.11 + image: {{.CustomRegistries.Alpine | default .ImageRepository | default .Registries.Alpine }}{{.Images.Alpine}} volumeMounts: - name: etchosts mountPath: /host-etc/hosts @@ -43,7 +43,7 @@ spec: echo "Done." containers: - name: pause-for-update - image: {{default "gcr.io/google_containers" .ImageRepository}}/pause-amd64:3.1 + image: {{.CustomRegistries.Pause | default .ImageRepository | default .Registries.Pause }}{{.Images.Pause}} terminationGracePeriodSeconds: 30 volumes: - name: etchosts diff --git a/deploy/addons/registry-aliases/patch-coredns-job.tmpl b/deploy/addons/registry-aliases/patch-coredns-job.tmpl index bab8756536af..8a7a74b000dc 100644 --- a/deploy/addons/registry-aliases/patch-coredns-job.tmpl +++ b/deploy/addons/registry-aliases/patch-coredns-job.tmpl @@ -15,7 +15,7 @@ spec: path: /var/lib/minikube/binaries containers: - name: core-dns-patcher - image: {{default "quay.io/rhdevelopers" .ImageRepository}}/core-dns-patcher + image: {{default "quay.io" .ImageRepository}}/{{.Images.CoreDNSPatcher}} imagePullPolicy: IfNotPresent # using the kubectl from the minikube instance volumeMounts: diff --git a/deploy/addons/registry-creds/registry-creds-rc.yaml.tmpl b/deploy/addons/registry-creds/registry-creds-rc.yaml.tmpl index 7f6a7c46b53d..b6cc7e2d556f 100644 --- a/deploy/addons/registry-creds/registry-creds-rc.yaml.tmpl +++ b/deploy/addons/registry-creds/registry-creds-rc.yaml.tmpl @@ -18,9 +18,9 @@ spec: addonmanager.kubernetes.io/mode: Reconcile spec: containers: - - image: {{default "upmcenterprises" .ImageRepository}}/registry-creds:1.10 + - image: {{.CustomRegistries.RegistryCreds | default .ImageRepository | default .Registries.RegistryCreds }}{{.Images.RegistryCreds}} name: registry-creds - imagePullPolicy: Always + imagePullPolicy: IfNotPresent env: - name: AWS_ACCESS_KEY_ID valueFrom: diff --git a/deploy/addons/registry/registry-proxy.yaml.tmpl b/deploy/addons/registry/registry-proxy.yaml.tmpl index 7b8fc3bf16fb..487066156c10 100644 --- a/deploy/addons/registry/registry-proxy.yaml.tmpl +++ b/deploy/addons/registry/registry-proxy.yaml.tmpl @@ -19,7 +19,7 @@ spec: addonmanager.kubernetes.io/mode: Reconcile spec: containers: - - image: {{default "gcr.io/google_containers" .ImageRepository}}/kube-registry-proxy:0.4 + - image: {{.CustomRegistries.KubeRegistryProxy | default .ImageRepository | default .Registries.KubeRegistryProxy }}{{.Images.KubeRegistryProxy}} imagePullPolicy: IfNotPresent name: registry-proxy ports: diff --git a/deploy/addons/registry/registry-rc.yaml.tmpl b/deploy/addons/registry/registry-rc.yaml.tmpl index fd1333a6ca91..eb6d782ba043 100644 --- a/deploy/addons/registry/registry-rc.yaml.tmpl +++ b/deploy/addons/registry/registry-rc.yaml.tmpl @@ -18,7 +18,7 @@ spec: addonmanager.kubernetes.io/mode: Reconcile spec: containers: - - image: {{default "registry.hub.docker.com/library" .ImageRepository}}/registry:2.7.1 + - image: {{.CustomRegistries.Registry | default .ImageRepository | default .Registries.Registry }}{{.Images.Registry}} imagePullPolicy: IfNotPresent name: registry ports: diff --git a/deploy/addons/storage-provisioner-gluster/glusterfs-daemonset.yaml.tmpl b/deploy/addons/storage-provisioner-gluster/glusterfs-daemonset.yaml.tmpl index 1072213168c1..df4f8d602e47 100644 --- a/deploy/addons/storage-provisioner-gluster/glusterfs-daemonset.yaml.tmpl +++ b/deploy/addons/storage-provisioner-gluster/glusterfs-daemonset.yaml.tmpl @@ -31,7 +31,7 @@ spec: # kubernetes.io/hostname: minikube hostNetwork: true containers: - - image: {{default "quay.io/nixpanic" .ImageRepository}}/glusterfs-server:pr_fake-disk + - image: {{.CustomRegistries.GlusterfsServer | default .ImageRepository | default .Registries.GlusterfsServer }}{{.Images.GlusterfsServer}} imagePullPolicy: IfNotPresent name: glusterfs env: diff --git a/deploy/addons/storage-provisioner-gluster/heketi-deployment.yaml.tmpl b/deploy/addons/storage-provisioner-gluster/heketi-deployment.yaml.tmpl index c99217087e4b..db8970bd4738 100644 --- a/deploy/addons/storage-provisioner-gluster/heketi-deployment.yaml.tmpl +++ b/deploy/addons/storage-provisioner-gluster/heketi-deployment.yaml.tmpl @@ -116,7 +116,7 @@ spec: spec: serviceAccountName: heketi-service-account containers: - - image: {{default "heketi" .ImageRepository}}/heketi:latest + - image: {{.CustomRegistries.Heketi | default .ImageRepository | default .Registries.Heketi }}{{.Images.Heketi}} imagePullPolicy: IfNotPresent name: heketi env: diff --git a/deploy/addons/storage-provisioner-gluster/storage-provisioner-glusterfile.yaml.tmpl b/deploy/addons/storage-provisioner-gluster/storage-provisioner-glusterfile.yaml.tmpl index 6777d0e37540..11048d25b92b 100644 --- a/deploy/addons/storage-provisioner-gluster/storage-provisioner-glusterfile.yaml.tmpl +++ b/deploy/addons/storage-provisioner-gluster/storage-provisioner-glusterfile.yaml.tmpl @@ -106,8 +106,8 @@ spec: serviceAccountName: glusterfile-provisioner containers: - name: glusterfile-provisioner - image: {{default "gluster" .ImageRepository}}/glusterfile-provisioner:latest - imagePullPolicy: Always + image: {{.CustomRegistries.GlusterfileProvisioner | default .ImageRepository | default .Registries.GlusterfileProvisioner }}{{.Images.GlusterfileProvisioner}} + imagePullPolicy: IfNotPresent env: - name: PROVISIONER_NAME value: gluster.org/glusterfile diff --git a/deploy/addons/storage-provisioner/storage-provisioner.yaml.tmpl b/deploy/addons/storage-provisioner/storage-provisioner.yaml.tmpl index 61d7adcdc062..ba90e861a172 100644 --- a/deploy/addons/storage-provisioner/storage-provisioner.yaml.tmpl +++ b/deploy/addons/storage-provisioner/storage-provisioner.yaml.tmpl @@ -100,7 +100,7 @@ spec: hostNetwork: true containers: - name: storage-provisioner - image: {{default "gcr.io/k8s-minikube" .ImageRepository}}/storage-provisioner:{{.StorageProvisionerVersion}} + image: {{.CustomRegistries.StorageProvisioner | default .ImageRepository | default .Registries.StorageProvisioner }}{{.Images.StorageProvisioner}} command: ["/storage-provisioner"] imagePullPolicy: IfNotPresent volumeMounts: diff --git a/deploy/addons/volumesnapshots/volume-snapshot-controller-deployment.yaml.tmpl b/deploy/addons/volumesnapshots/volume-snapshot-controller-deployment.yaml.tmpl index 82928f1a4da8..9706cd98e99f 100644 --- a/deploy/addons/volumesnapshots/volume-snapshot-controller-deployment.yaml.tmpl +++ b/deploy/addons/volumesnapshots/volume-snapshot-controller-deployment.yaml.tmpl @@ -23,7 +23,7 @@ spec: containers: - name: volume-snapshot-controller # TODO(xyang): Replace with an official image when it is released - image: {{default "gcr.io/k8s-staging-csi" .ImageRepository}}/snapshot-controller:v2.0.0-rc2 + image: {{.CustomRegistries.SnapshotController | default .ImageRepository | default .Registries.SnapshotController }}{{.Images.SnapshotController}} args: - "--v=5" - imagePullPolicy: Always + imagePullPolicy: IfNotPresent diff --git a/pkg/addons/addons.go b/pkg/addons/addons.go index 3600016c6a79..c8918faa77e0 100644 --- a/pkg/addons/addons.go +++ b/pkg/addons/addons.go @@ -209,7 +209,7 @@ https://github.com/kubernetes/minikube/issues/7332`, out.V{"driver_name": cc.Dri return errors.Wrap(err, "command runner") } - data := assets.GenerateTemplateData(cc.KubernetesConfig) + data := assets.GenerateTemplateData(addon, cc.KubernetesConfig) return enableOrDisableAddonInternal(cc, addon, cmd, data, enable) } diff --git a/pkg/minikube/assets/addons.go b/pkg/minikube/assets/addons.go index 85aa09d225e5..a0aae9248626 100644 --- a/pkg/minikube/assets/addons.go +++ b/pkg/minikube/assets/addons.go @@ -17,10 +17,15 @@ limitations under the License. package assets import ( + "fmt" "runtime" + "strings" + "github.com/spf13/viper" "k8s.io/minikube/pkg/minikube/config" "k8s.io/minikube/pkg/minikube/constants" + "k8s.io/minikube/pkg/minikube/out" + "k8s.io/minikube/pkg/minikube/style" "k8s.io/minikube/pkg/minikube/vmpath" "k8s.io/minikube/pkg/version" ) @@ -30,14 +35,20 @@ type Addon struct { Assets []*BinAsset enabled bool addonName string + Images map[string]string + + // Registries currently only shows the default registry of images + Registries map[string]string } // NewAddon creates a new Addon -func NewAddon(assets []*BinAsset, enabled bool, addonName string) *Addon { +func NewAddon(assets []*BinAsset, enabled bool, addonName string, images map[string]string, registries map[string]string) *Addon { a := &Addon{ - Assets: assets, - enabled: enabled, - addonName: addonName, + Assets: assets, + enabled: enabled, + addonName: addonName, + Images: images, + Registries: registries, } return a } @@ -73,28 +84,35 @@ var Addons = map[string]*Addon{ MustBinAsset("deploy/addons/dashboard/dashboard-sa.yaml", vmpath.GuestAddonsDir, "dashboard-sa.yaml", "0640"), MustBinAsset("deploy/addons/dashboard/dashboard-secret.yaml", vmpath.GuestAddonsDir, "dashboard-secret.yaml", "0640"), MustBinAsset("deploy/addons/dashboard/dashboard-svc.yaml", vmpath.GuestAddonsDir, "dashboard-svc.yaml", "0640"), - }, false, "dashboard"), + }, false, "dashboard", map[string]string{ + "Dashboard": "kubernetesui/dashboard:v2.1.0", + "MetricsScraper": "kubernetesui/metrics-scraper:v1.0.4", + }, nil), "default-storageclass": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/storageclass/storageclass.yaml.tmpl", vmpath.GuestAddonsDir, "storageclass.yaml", "0640"), - }, true, "default-storageclass"), + }, true, "default-storageclass", nil, nil), "pod-security-policy": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/pod-security-policy/pod-security-policy.yaml.tmpl", vmpath.GuestAddonsDir, "pod-security-policy.yaml", "0640"), - }, false, "pod-security-policy"), + }, false, "pod-security-policy", nil, nil), "storage-provisioner": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/storage-provisioner/storage-provisioner.yaml.tmpl", vmpath.GuestAddonsDir, "storage-provisioner.yaml", "0640"), - }, true, "storage-provisioner"), + }, true, "storage-provisioner", map[string]string{ + "StorageProvisioner": fmt.Sprintf("k8s-minikube/storage-provisioner:%s", version.GetStorageProvisionerVersion()), + }, map[string]string{ + "StorageProvisioner": "gcr.io", + }), "storage-provisioner-gluster": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/storage-provisioner-gluster/storage-gluster-ns.yaml.tmpl", @@ -116,7 +134,13 @@ var Addons = map[string]*Addon{ vmpath.GuestAddonsDir, "storage-privisioner-glusterfile.yaml", "0640"), - }, false, "storage-provisioner-gluster"), + }, false, "storage-provisioner-gluster", map[string]string{ + "Heketi": "heketi/heketi:latest", + "GlusterfileProvisioner": "gluster/glusterfile-provisioner:latest", + "GlusterfsServer": "nixpanic/glusterfs-server:pr_fake-disk", + }, map[string]string{ + "GlusterfsServer": "quay.io", + }), "efk": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/efk/elasticsearch-rc.yaml.tmpl", @@ -148,7 +172,16 @@ var Addons = map[string]*Addon{ vmpath.GuestAddonsDir, "kibana-svc.yaml", "0640"), - }, false, "efk"), + }, false, "efk", map[string]string{ + "Elasticsearch": "elasticsearch:v5.6.2", + "FluentdElasticsearch": "fluentd-elasticsearch:v2.0.2", + "Alpine": "alpine:3.6", + "Kibana": "kibana/kibana:5.6.2", + }, map[string]string{ + "Elasticsearch": "k8s.gcr.io", + "FluentdElasticsearch": "k8s.gcr.io", + "Kibana": "docker.elastic.co", + }), "ingress": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/ingress/ingress-configmap.yaml.tmpl", @@ -165,28 +198,38 @@ var Addons = map[string]*Addon{ vmpath.GuestAddonsDir, "ingress-dp.yaml", "0640"), - }, false, "ingress"), + }, false, "ingress", map[string]string{ + "IngressController": "k8s-artifacts-prod/ingress-nginx/controller:v0.40.2", + "KubeWebhookCertgenCreate": "jettech/kube-webhook-certgen:v1.2.2", + "KubeWebhookCertgenPatch": "jettech/kube-webhook-certgen:v1.3.0", + }, map[string]string{ + "IngressController": "us.gcr.io", + }), "istio-provisioner": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/istio-provisioner/istio-operator.yaml.tmpl", vmpath.GuestAddonsDir, "istio-operator.yaml", "0640"), - }, false, "istio-provisioner"), + }, false, "istio-provisioner", map[string]string{ + "IstioOperator": "istio/operator:1.5.0", + }, nil), "istio": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/istio/istio-default-profile.yaml.tmpl", vmpath.GuestAddonsDir, "istio-default-profile.yaml", "0640"), - }, false, "istio"), + }, false, "istio", nil, nil), "kubevirt": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/kubevirt/pod.yaml.tmpl", vmpath.GuestAddonsDir, "pod.yaml", "0640"), - }, false, "kubevirt"), + }, false, "kubevirt", map[string]string{ + "Kubectl": "bitnami/kubectl:1.17", + }, nil), "metrics-server": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/metrics-server/metrics-apiservice.yaml.tmpl", @@ -203,7 +246,11 @@ var Addons = map[string]*Addon{ vmpath.GuestAddonsDir, "metrics-server-service.yaml", "0640"), - }, false, "metrics-server"), + }, false, "metrics-server", map[string]string{ + "MetricsServer": fmt.Sprintf("metrics-server-%s:v0.2.1", runtime.GOARCH), + }, map[string]string{ + "MetricsServer": "k8s.gcr.io", + }), "olm": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/olm/crds.yaml.tmpl", @@ -215,7 +262,13 @@ var Addons = map[string]*Addon{ vmpath.GuestAddonsDir, "olm.yaml", "0640"), - }, false, "olm"), + }, false, "olm", map[string]string{ + "OLM": "operator-framework/olm:0.14.1", + "UpstreamCommunityOperators": "operator-framework/upstream-community-operators:latest", + }, map[string]string{ + "OLM": "quay.io", + "UpstreamCommunityOperators": "quay.io", + }), "registry": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/registry/registry-rc.yaml.tmpl", @@ -232,14 +285,21 @@ var Addons = map[string]*Addon{ vmpath.GuestAddonsDir, "registry-proxy.yaml", "0640"), - }, false, "registry"), + }, false, "registry", map[string]string{ + "Registry": "registry:2.7.1", + "KubeRegistryProxy": "google_containers/kube-registry-proxy:0.4", + }, map[string]string{ + "KubeRegistryProxy": "gcr.io", + }), "registry-creds": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/registry-creds/registry-creds-rc.yaml.tmpl", vmpath.GuestAddonsDir, "registry-creds-rc.yaml", "0640"), - }, false, "registry-creds"), + }, false, "registry-creds", map[string]string{ + "RegistryCreds": "upmcenterprises/registry-creds:1.10", + }, nil), "registry-aliases": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/registry-aliases/registry-aliases-sa.tmpl", @@ -266,28 +326,47 @@ var Addons = map[string]*Addon{ vmpath.GuestAddonsDir, "patch-coredns-job.yaml", "0640"), - }, false, "registry-aliases"), + }, false, "registry-aliases", map[string]string{ + "CoreDNSPatcher": "rhdevelopers/core-dns-patcher", + "Alpine": "alpine:3.11", + "Pause": "google_containers/pause-amd64:3.1", + }, map[string]string{ + "CoreDNSPatcher": "quay.io", + "Pause": "gcr.io", + }), "freshpod": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/freshpod/freshpod-rc.yaml.tmpl", vmpath.GuestAddonsDir, "freshpod-rc.yaml", "0640"), - }, false, "freshpod"), + }, false, "freshpod", map[string]string{ + "FreshPod": "google-samples/freshpod:v0.0.1", + }, map[string]string{ + "FreshPod": "gcr.io", + }), "nvidia-driver-installer": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/gpu/nvidia-driver-installer.yaml.tmpl", vmpath.GuestAddonsDir, "nvidia-driver-installer.yaml", "0640"), - }, false, "nvidia-driver-installer"), + }, false, "nvidia-driver-installer", map[string]string{ + "NvidiaDriverInstaller": "minikube-nvidia-driver-installer:e2d9b43228decf5d6f7dce3f0a85d390f138fa01", + "Pause": "pause:2.0", + }, map[string]string{ + "NvidiaDriverInstaller": "k8s.gcr.io", + "Pause": "k8s.gcr.io", + }), "nvidia-gpu-device-plugin": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/gpu/nvidia-gpu-device-plugin.yaml.tmpl", vmpath.GuestAddonsDir, "nvidia-gpu-device-plugin.yaml", "0640"), - }, false, "nvidia-gpu-device-plugin"), + }, false, "nvidia-gpu-device-plugin", map[string]string{ + "NvidiaDevicePlugin": "nvidia/k8s-device-plugin:1.0.0-beta4", + }, nil), "logviewer": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/logviewer/logviewer-dp-and-svc.yaml.tmpl", @@ -299,7 +378,9 @@ var Addons = map[string]*Addon{ vmpath.GuestAddonsDir, "logviewer-rbac.yaml", "0640"), - }, false, "logviewer"), + }, false, "logviewer", map[string]string{ + "LogViewer": "ivans3/minikube-log-viewer:latest", + }, nil), "gvisor": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/gvisor/gvisor-pod.yaml.tmpl", @@ -316,7 +397,11 @@ var Addons = map[string]*Addon{ vmpath.GuestGvisorDir, constants.GvisorConfigTomlTargetName, "0640"), - }, false, "gvisor"), + }, false, "gvisor", map[string]string{ + "GvisorAddon": "k8s-minikube/gvisor-addon:3", + }, map[string]string{ + "GvisorAddon": "gcr.io", + }), "helm-tiller": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/helm-tiller/helm-tiller-dp.tmpl", @@ -333,14 +418,20 @@ var Addons = map[string]*Addon{ vmpath.GuestAddonsDir, "helm-tiller-svc.yaml", "0640"), - }, false, "helm-tiller"), + }, false, "helm-tiller", map[string]string{ + "Tiller": "kubernetes-helm/tiller:v2.16.12", + }, map[string]string{ + "Tiller": "gcr.io", + }), "ingress-dns": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/ingress-dns/ingress-dns-pod.yaml.tmpl", vmpath.GuestAddonsDir, "ingress-dns-pod.yaml", "0640"), - }, false, "ingress-dns"), + }, false, "ingress-dns", map[string]string{ + "IngressDNS": "cryptexlabs/minikube-ingress-dns:0.3.0", + }, nil), "metallb": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/metallb/metallb.yaml.tmpl", @@ -352,7 +443,10 @@ var Addons = map[string]*Addon{ vmpath.GuestAddonsDir, "metallb-config.yaml", "0640"), - }, false, "metallb"), + }, false, "metallb", map[string]string{ + "Speaker": "metallb/speaker:v0.8.2", + "Controller": "metallb/controller:v0.8.2", + }, nil), "ambassador": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/ambassador/ambassador-operator-crds.yaml.tmpl", @@ -369,7 +463,11 @@ var Addons = map[string]*Addon{ vmpath.GuestAddonsDir, "ambassadorinstallation.yaml", "0640"), - }, false, "ambassador"), + }, false, "ambassador", map[string]string{ + "AmbassadorOperator": "datawire/ambassador-operator:v1.2.3", + }, map[string]string{ + "AmbassadorOperator": "quay.io", + }), "gcp-auth": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/gcp-auth/gcp-auth-ns.yaml.tmpl", @@ -386,7 +484,12 @@ var Addons = map[string]*Addon{ vmpath.GuestAddonsDir, "gcp-auth-webhook.yaml", "0640"), - }, false, "gcp-auth"), + }, false, "gcp-auth", map[string]string{ + "KubeWebhookCertgen": "jettech/kube-webhook-certgen:v1.3.0", + "GCPAuthWebhook": "k8s-minikube/gcp-auth-webhook:v0.0.3", + }, map[string]string{ + "GCPAuthWebhook": "gcr.io", + }), "volumesnapshots": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/volumesnapshots/snapshot.storage.k8s.io_volumesnapshotclasses.yaml.tmpl", @@ -413,7 +516,11 @@ var Addons = map[string]*Addon{ vmpath.GuestAddonsDir, "volume-snapshot-controller-deployment.yaml", "0640"), - }, false, "volumesnapshots"), + }, false, "volumesnapshots", map[string]string{ + "SnapshotController": "k8s-staging-csi/snapshot-controller:v2.0.0-rc2", + }, map[string]string{ + "SnapshotController": "gcr.io", + }), "csi-hostpath-driver": NewAddon([]*BinAsset{ MustBinAsset( "deploy/addons/csi-hostpath-driver/rbac/rbac-external-attacher.yaml.tmpl", @@ -470,11 +577,27 @@ var Addons = map[string]*Addon{ vmpath.GuestAddonsDir, "csi-hostpath-storageclass.yaml", "0640"), - }, false, "csi-hostpath-driver"), + }, false, "csi-hostpath-driver", map[string]string{ + "Attacher": "k8scsi/csi-attacher:v3.0.0-rc1", + "NodeDriverRegistrar": "k8scsi/csi-node-driver-registrar:v1.3.0", + "HostPathPlugin": "k8scsi/hostpathplugin:v1.4.0-rc2", + "LivenessProbe": "k8scsi/livenessprobe:v1.1.0", + "Resizer": "k8scsi/csi-resizer:v0.6.0-rc1", + "Snapshotter": "k8scsi/csi-snapshotter:v2.1.0", + "Provisioner": "k8s-staging-sig-storage/csi-provisioner:v2.0.0-rc2", + }, map[string]string{ + "Attacher": "quay.io", + "NodeDriverRegistrar": "quay.io", + "HostPathPlugin": "quay.io", + "LivenessProbe": "quay.io", + "Resizer": "quay.io", + "Snapshotter": "quay.io", + "Provisioner": "gcr.io", + }), } // GenerateTemplateData generates template data for template assets -func GenerateTemplateData(cfg config.KubernetesConfig) interface{} { +func GenerateTemplateData(addon *Addon, cfg config.KubernetesConfig) interface{} { a := runtime.GOARCH // Some legacy docker images still need the -arch suffix @@ -484,22 +607,105 @@ func GenerateTemplateData(cfg config.KubernetesConfig) interface{} { ea = "-" + runtime.GOARCH } opts := struct { - Arch string - ExoticArch string - ImageRepository string - LoadBalancerStartIP string - LoadBalancerEndIP string - CustomIngressCert string - StorageProvisionerVersion string + Arch string + ExoticArch string + ImageRepository string + LoadBalancerStartIP string + LoadBalancerEndIP string + CustomIngressCert string + Images map[string]string + Registries map[string]string + CustomRegistries map[string]string }{ - Arch: a, - ExoticArch: ea, - ImageRepository: cfg.ImageRepository, - LoadBalancerStartIP: cfg.LoadBalancerStartIP, - LoadBalancerEndIP: cfg.LoadBalancerEndIP, - CustomIngressCert: cfg.CustomIngressCert, - StorageProvisionerVersion: version.GetStorageProvisionerVersion(), + Arch: a, + ExoticArch: ea, + ImageRepository: cfg.ImageRepository, + LoadBalancerStartIP: cfg.LoadBalancerStartIP, + LoadBalancerEndIP: cfg.LoadBalancerEndIP, + CustomIngressCert: cfg.CustomIngressCert, + Images: addon.Images, + Registries: addon.Registries, + CustomRegistries: make(map[string]string), + } + if opts.ImageRepository != "" && !strings.HasSuffix(opts.ImageRepository, "/") { + opts.ImageRepository += "/" + } + + if opts.Images == nil { + opts.Images = make(map[string]string) // Avoid nil access when rendering + } + + images := viper.GetString(config.AddonImages) + if images != "" { + for _, image := range strings.Split(images, ",") { + vals := strings.Split(image, "=") + if len(vals) != 2 || vals[1] == "" { + out.WarningT("Ignoring invalid custom image {{.conf}}", out.V{"conf": image}) + continue + } + if _, ok := opts.Images[vals[0]]; ok { + opts.Images[vals[0]] = vals[1] + } else { + out.WarningT("Ignoring unknown custom image {{.name}}", out.V{"name": vals[0]}) + } + } + } + + if opts.Registries == nil { + opts.Registries = make(map[string]string) } + registries := viper.GetString(config.AddonRegistries) + if registries != "" { + for _, registry := range strings.Split(registries, ",") { + vals := strings.Split(registry, "=") + if len(vals) != 2 { + out.WarningT("Ignoring invalid custom registry {{.conf}}", out.V{"conf": registry}) + continue + } + if _, ok := opts.Images[vals[0]]; ok { // check images map because registry map may omitted default registry + opts.CustomRegistries[vals[0]] = vals[1] + } else { + out.WarningT("Ignoring unknown custom registry {{.name}}", out.V{"name": vals[0]}) + } + } + } + + // Append postfix "/" to registries + for k, v := range opts.Registries { + if v != "" && !strings.HasSuffix(v, "/") { + opts.Registries[k] = v + "/" + } + } + + for k, v := range opts.CustomRegistries { + if v != "" && !strings.HasSuffix(v, "/") { + opts.CustomRegistries[k] = v + "/" + } + } + + for name, image := range opts.Images { + if _, ok := opts.Registries[name]; !ok { + opts.Registries[name] = "" // Avoid nil access when rendering + } + + // Send messages to stderr due to some tests rely on stdout + if override, ok := opts.CustomRegistries[name]; ok { + out.ErrT(style.Option, "Using image {{.registry}}{{.image}}", out.V{ + "registry": override, + "image": image, + }) + } else if opts.ImageRepository != "" { + out.ErrT(style.Option, "Using image {{.registry}}{{.image}} (global image repository)", out.V{ + "registry": opts.ImageRepository, + "image": image, + }) + } else { + out.ErrT(style.Option, "Using image {{.registry}}{{.image}}", out.V{ + "registry": opts.Registries[name], + "image": image, + }) + } + } return opts } diff --git a/pkg/minikube/config/config.go b/pkg/minikube/config/config.go index ee7ff39b7f22..dc1e4827bf0c 100644 --- a/pkg/minikube/config/config.go +++ b/pkg/minikube/config/config.go @@ -50,6 +50,10 @@ const ( ShowBootstrapperDeprecationNotification = "ShowBootstrapperDeprecationNotification" // UserFlag is the key for the global user flag (ex. --user=user1) UserFlag = "user" + // AddonImages stores custom addon images config + AddonImages = "addon-images" + // AddonRegistries stores custom addon images config + AddonRegistries = "addon-registries" ) var ( diff --git a/site/content/en/docs/commands/addons.md b/site/content/en/docs/commands/addons.md index 5abbd05ffc3b..51023fa24dd9 100644 --- a/site/content/en/docs/commands/addons.md +++ b/site/content/en/docs/commands/addons.md @@ -109,16 +109,29 @@ minikube addons disable ADDON_NAME [flags] ## minikube addons enable -Enables the addon w/ADDON_NAME within minikube (example: minikube addons enable dashboard). For a list of available addons use: minikube addons list +Enables the addon w/ADDON_NAME within minikube. For a list of available addons use: minikube addons list ### Synopsis -Enables the addon w/ADDON_NAME within minikube (example: minikube addons enable dashboard). For a list of available addons use: minikube addons list +Enables the addon w/ADDON_NAME within minikube. For a list of available addons use: minikube addons list ```shell minikube addons enable ADDON_NAME [flags] ``` +### Examples + +``` +minikube addons enable dashboard +``` + +### Options + +``` + --images string Images used by this addon. Separated by commas. + --registries string Registries used by this addon. Separated by commas. +``` + ### Options inherited from parent commands ``` @@ -176,6 +189,46 @@ minikube addons help [command] [flags] --vmodule moduleSpec comma-separated list of pattern=N settings for file-filtered logging ``` +## minikube addons images + +List image names the addon w/ADDON_NAME used. For a list of available addons use: minikube addons list + +### Synopsis + +List image names the addon w/ADDON_NAME used. For a list of available addons use: minikube addons list + +```shell +minikube addons images ADDON_NAME [flags] +``` + +### Examples + +``` +minikube addons images ingress +``` + +### Options inherited from parent commands + +``` + --add_dir_header If true, adds the file directory to the header of the log messages + --alsologtostderr log to standard error as well as files + -b, --bootstrapper string The name of the cluster bootstrapper that will set up the Kubernetes cluster. (default "kubeadm") + -h, --help + --log_backtrace_at traceLocation when logging hits line file:N, emit a stack trace (default :0) + --log_dir string If non-empty, write log files in this directory + --log_file string If non-empty, use this log file + --log_file_max_size uint Defines the maximum size a log file can grow to. Unit is megabytes. If the value is 0, the maximum file size is unlimited. (default 1800) + --logtostderr log to standard error instead of files + --one_output If true, only write logs to their native severity level (vs also writing to each lower severity level + -p, --profile string The name of the minikube VM being used. This can be set to allow having multiple instances of minikube independently. (default "minikube") + --skip_headers If true, avoid header prefixes in the log messages + --skip_log_headers If true, avoid headers when opening log files + --stderrthreshold severity logs at or above this threshold go to stderr (default 2) + --user string Specifies the user executing the operation. Useful for auditing operations executed by 3rd party tools. Defaults to the operating system username. + -v, --v Level number for the log level verbosity + --vmodule moduleSpec comma-separated list of pattern=N settings for file-filtered logging +``` + ## minikube addons list Lists all available minikube addons as well as their current statuses (enabled/disabled) diff --git a/site/content/en/docs/handbook/addons/custom-images.md b/site/content/en/docs/handbook/addons/custom-images.md new file mode 100644 index 000000000000..a66c44ee092b --- /dev/null +++ b/site/content/en/docs/handbook/addons/custom-images.md @@ -0,0 +1,57 @@ +--- +title: "Config the Addon to Use Custom Registries and Images" +linkTitle: "Custom Images" +weight: 2 +date: 2021-01-13 +--- + +If you have trouble to access default images, or want to use images from a private registry or local version, you could achieve +this by flag `--images` and `--registries`. + +We defined and named all images used by an addon, you could view them by command `addons images`: + +```shell +minikube addons images efk +``` + +``` + ▪ efk has following images: +|----------------------|------------------------------|-------------------| +| IMAGE NAME | DEFAULT IMAGE | DEFAULT REGISTRY | +|----------------------|------------------------------|-------------------| +| Elasticsearch | elasticsearch:v5.6.2 | k8s.gcr.io | +| FluentdElasticsearch | fluentd-elasticsearch:v2.0.2 | k8s.gcr.io | +| Alpine | alpine:3.6 | | +| Kibana | kibana/kibana:5.6.2 | docker.elastic.co | +|----------------------|------------------------------|-------------------| +``` + +The `DEFAULT IMAGE` and `DEFAULT REGISTRY` columns indicate which images are used by default. +An empty registry means the image is stored locally or default registry `docker.io`. + +The `IMAGE NAME` column is used to customize the corresponding image and registry. + +Assume we have a private registry at `192.168.10.2:5555` to replace `k8s.gcr.io` and a locally built Kibana called `kibana/kibana:5.6.2-custom`. + +We could load local images to minikube by: + +```shell +minikube cache add kibana/kibana:5.6.2-custom +``` + +Then we can start `efk` addon with flags `--images` and `--registries`. +The format is `IMAGE_NAME=CUSTOM_VALUE`, separated by commas, where the `IMAGE_NAME` is the value of `IMAGE NAME` column in the table above. + +```shell +minikube addons enable efk --images="Kibana=kibana/kibana:5.6.2-custom" --registries="Kibana=,Elasticsearch=192.168.10.2:5555,FluentdElasticsearch=192.168.10.2:5555" +``` + +``` + ▪ Using image 192.168.10.2:5555/elasticsearch:v5.6.2 + ▪ Using image 192.168.10.2:5555/fluentd-elasticsearch:v2.0.2 + ▪ Using image alpine:3.6 + ▪ Using image kibana/kibana:5.6.2-custom +🌟 The 'efk' addon is enabled +``` + +Now the `efk` addon is using the custom registry and images. \ No newline at end of file