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

Allow setting custom images for addons #10111

Merged
merged 11 commits into from
Feb 1, 2021
18 changes: 15 additions & 3 deletions cmd/minikube/cmd/config/enable.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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")
Expand All @@ -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)
Expand All @@ -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(&registries, "registries", "", "Registries used by this addon. Separated by commas.")
AddonsCmd.AddCommand(addonsEnableCmd)
}
70 changes: 70 additions & 0 deletions cmd/minikube/cmd/config/images.go
Original file line number Diff line number Diff line change
@@ -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"})
medyagh marked this conversation as resolved.
Show resolved Hide resolved
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)
}
4 changes: 2 additions & 2 deletions deploy/addons/ambassador/ambassador-operator.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions deploy/addons/dashboard/dashboard-dp.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions deploy/addons/efk/elasticsearch-rc.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion deploy/addons/efk/fluentd-es-rc.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion deploy/addons/efk/kibana-rc.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion deploy/addons/freshpod/freshpod-rc.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions deploy/addons/gcp-auth/gcp-auth-webhook.yaml.tmpl.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions deploy/addons/gpu/nvidia-driver-installer.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
2 changes: 1 addition & 1 deletion deploy/addons/gpu/nvidia-gpu-device-plugin.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion deploy/addons/gvisor/gvisor-pod.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion deploy/addons/helm-tiller/helm-tiller-dp.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion deploy/addons/ingress-dns/ingress-dns-pod.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions deploy/addons/ingress/ingress-dp.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions deploy/addons/istio-provisioner/istio-operator.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion deploy/addons/kubevirt/pod.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions deploy/addons/logviewer/logviewer-dp-and-svc.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
Loading