Addon custom registry:

* fix missing suffix when using global image repo
* support override global image repo
* change all imagePullPolicy to IfNotPresent
* fix empty global image repo suffix

Signed-off-by: Ling Samuel <lingsamuelgrace@gmail.com>
pull/10111/head
Ling Samuel 2021-01-13 12:01:37 +08:00
parent c9f4cb8388
commit 101d39fc51
No known key found for this signature in database
GPG Key ID: 1405A670863B367F
36 changed files with 88 additions and 61 deletions

View File

@ -74,7 +74,7 @@ var (
)
func init() {
addonsEnableCmd.Flags().StringVar(&images, "images", "", "Images used by this addon. Divided by comma.")
addonsEnableCmd.Flags().StringVar(&registries, "registries", "", "Registries used by this addon. Divided by comma.")
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)
}

View File

@ -180,10 +180,10 @@ spec:
containers:
- name: ambassador-operator
# Replace this with the built image name
image: {{default .Registries.AmbassadorOperator .ImageRepository}}{{.Images.AmbassadorOperator}}
image: {{.CustomRegistries.AmbassadorOperator | default .ImageRepository | default .Registries.AmbassadorOperator }}{{.Images.AmbassadorOperator}}
command:
- ambassador-operator
imagePullPolicy: Always
imagePullPolicy: IfNotPresent
env:
- name: WATCH_NAMESPACE
valueFrom:

View File

@ -57,7 +57,7 @@ spec:
serviceAccountName: csi-attacher
containers:
- name: csi-attacher
image: {{default .Registries.Attacher .ImageRepository}}{{.Images.Attacher}}
image: {{.CustomRegistries.Attacher | default .ImageRepository | default .Registries.Attacher }}{{.Images.Attacher}}
args:
- --v=5
- --csi-address=/csi/csi.sock

View File

@ -53,7 +53,7 @@ spec:
spec:
containers:
- name: node-driver-registrar
image: {{default .Registries.NodeDriverRegistrar .ImageRepository}}{{.Images.NodeDriverRegistrar}}
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 .Registries.HostPathPlugin .ImageRepository}}{{.Images.HostPathPlugin}}
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 .Registries.LivenessProbe .ImageRepository}}{{.Images.LivenessProbe}}
image: {{.CustomRegistries.LivenessProbe | default .ImageRepository | default .Registries.LivenessProbe }}{{.Images.LivenessProbe}}
args:
- --csi-address=/csi/csi.sock
- --health-port=9898

View File

@ -57,7 +57,7 @@ spec:
serviceAccountName: csi-provisioner
containers:
- name: csi-provisioner
image: {{default .Registries.Provisioner .ImageRepository}}{{.Images.Provisioner}}
image: {{.CustomRegistries.Provisioner | default .ImageRepository | default .Registries.Provisioner }}{{.Images.Provisioner}}
args:
- -v=5
- --csi-address=/csi/csi.sock

View File

@ -57,7 +57,7 @@ spec:
serviceAccountName: csi-resizer
containers:
- name: csi-resizer
image: {{default .Registries.Resizer .ImageRepository}}{{.Images.Resizer}}
image: {{.CustomRegistries.Resizer | default .ImageRepository | default .Registries.Resizer }}{{.Images.Resizer}}
args:
- -v=5
- -csi-address=/csi/csi.sock

View File

@ -57,7 +57,7 @@ spec:
serviceAccount: csi-snapshotter
containers:
- name: csi-snapshotter
image: {{default .Registries.Snapshotter .ImageRepository}}{{.Images.Snapshotter}}
image: {{.CustomRegistries.Snapshotter | default .ImageRepository | default .Registries.Snapshotter }}{{.Images.Snapshotter}}
args:
- -v=5
- --csi-address=/csi/csi.sock

View File

@ -36,7 +36,7 @@ spec:
spec:
containers:
- name: dashboard-metrics-scraper
image: {{default .Registries.MetricsScraper .ImageRepository}}{{.Images.MetricsScraper}}
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 .Registries.Dashboard .ImageRepository}}{{.Images.Dashboard}}
image: {{.CustomRegistries.Dashboard | default .ImageRepository | default .Registries.Dashboard }}{{.Images.Dashboard}}
ports:
- containerPort: 9090
protocol: TCP

View File

@ -34,7 +34,7 @@ spec:
spec:
containers:
- name: elasticsearch-logging
image: {{default .Registries.Elasticsearch .ImageRepository}}{{.Images.Elasticsearch}}
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 .Registries.Alpine .ImageRepository}}{{.Images.Alpine}}
- image: {{.CustomRegistries.Alpine | default .ImageRepository | default .Registries.Alpine }}{{.Images.Alpine}}
command: ["/sbin/sysctl", "-w", "vm.max_map_count=262144"]
name: elasticsearch-logging-init
securityContext:

View File

@ -31,7 +31,7 @@ spec:
spec:
containers:
- name: fluentd-es
image: {{default .Registries.FluentdElasticsearch .ImageRepository}}{{.Images.FluentdElasticsearch}}
image: {{.CustomRegistries.FluentdElasticsearch | default .ImageRepository | default .Registries.FluentdElasticsearch }}{{.Images.FluentdElasticsearch}}
env:
- name: FLUENTD_ARGS
value: --no-supervisor -q

View File

@ -34,7 +34,7 @@ spec:
spec:
containers:
- name: kibana-logging
image: {{default .Registries.Kibana .ImageRepository}}{{.Images.Kibana}}
image: {{.CustomRegistries.Kibana | default .ImageRepository | default .Registries.Kibana }}{{.Images.Kibana}}
resources:
limits:
cpu: 500m

View File

@ -34,7 +34,7 @@ spec:
spec:
containers:
- name: freshpod
image: {{default .Registries.FreshPod .ImageRepository}}{{.Images.FreshPod}}
image: {{.CustomRegistries.FreshPod | default .ImageRepository | default .Registries.FreshPod }}{{.Images.FreshPod}}
imagePullPolicy: IfNotPresent
volumeMounts:
- name: docker

View File

@ -68,7 +68,7 @@ spec:
serviceAccountName: minikube-gcp-auth-certs
containers:
- name: create
image: {{default .Registries.KubeWebhookCertgen .ImageRepository}}{{.Images.KubeWebhookCertgen}}
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 .Registries.GCPAuthWebhook .ImageRepository}}{{.Images.GCPAuthWebhook}}
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 .Registries.KubeWebhookCertgen .ImageRepository}}{{.Images.KubeWebhookCertgen}}
image: {{.CustomRegistries.KubeWebhookCertgen | default .ImageRepository | default .Registries.KubeWebhookCertgen }}{{.Images.KubeWebhookCertgen}}
imagePullPolicy: IfNotPresent
args:
- patch

View File

@ -50,7 +50,7 @@ spec:
hostPath:
path: /
initContainers:
- image: {{default .Registries.NvidiaDriverInstaller .ImageRepository}}{{.Images.NvidiaDriverInstaller}}
- image: {{.CustomRegistries.NvidiaDriverInstaller | default .ImageRepository | default .Registries.NvidiaDriverInstaller }}{{.Images.NvidiaDriverInstaller}}
name: nvidia-driver-installer
resources:
requests:

View File

@ -43,7 +43,7 @@ spec:
hostPath:
path: /var/lib/kubelet/device-plugins
containers:
- image: {{default .Registries.NvidiaDevicePlugin .ImageRepository}}{{.Images.NvidiaDevicePlugin}}
- image: {{.CustomRegistries.NvidiaDevicePlugin | default .ImageRepository | default .Registries.NvidiaDevicePlugin }}{{.Images.NvidiaDevicePlugin}}
command: ["/usr/bin/nvidia-device-plugin", "-logtostderr"]
name: nvidia-gpu-device-plugin
resources:

View File

@ -25,7 +25,7 @@ spec:
hostPID: true
containers:
- name: gvisor
image: {{default .Registries.GvisorAddon .ImageRepository}}{{.Images.GvisorAddon}}
image: {{.CustomRegistries.GvisorAddon | default .ImageRepository | default .Registries.GvisorAddon }}{{.Images.GvisorAddon}}
securityContext:
privileged: true
volumeMounts:

View File

@ -46,7 +46,7 @@ spec:
value: kube-system
- name: TILLER_HISTORY_MAX
value: "0"
image: {{default .Registries.Tiller .ImageRepository}}{{.Images.Tiller}}
image: {{.CustomRegistries.Tiller | default .ImageRepository | default .Registries.Tiller }}{{.Images.Tiller}}
imagePullPolicy: IfNotPresent
livenessProbe:
failureThreshold: 3

View File

@ -80,7 +80,7 @@ spec:
hostNetwork: true
containers:
- name: minikube-ingress-dns
image: {{default .Registries.IngressDNS .ImageRepository}}{{.Images.IngressDNS}}
image: {{.CustomRegistries.IngressDNS | default .ImageRepository | default .Registries.IngressDNS }}{{.Images.IngressDNS}}
imagePullPolicy: IfNotPresent
ports:
- containerPort: 53

View File

@ -49,7 +49,7 @@ spec:
serviceAccountName: ingress-nginx
containers:
- name: controller
image: {{default .Registries.IngressController .ImageRepository}}{{.Images.IngressController}}
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 .Registries.KubeWebhookCertgenCreate .ImageRepository}}{{.Images.KubeWebhookCertgenCreate}}
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 .Registries.KubeWebhookCertgenPatch .ImageRepository}}{{.Images.KubeWebhookCertgenPatch}}
image: {{.CustomRegistries.KubeWebhookCertgenPatch | default .ImageRepository | default .Registries.KubeWebhookCertgenPatch }}{{.Images.KubeWebhookCertgenPatch}}
imagePullPolicy:
args:
- patch

View File

@ -218,11 +218,11 @@ spec:
serviceAccountName: istio-operator
containers:
- name: istio-operator
image: {{default .Registries.IstioOperator .ImageRepository}}{{.Images.IstioOperator}}
image: {{.CustomRegistries.IstioOperator | default .ImageRepository | default .Registries.IstioOperator }}{{.Images.IstioOperator}}
command:
- operator
- server
imagePullPolicy: Always
imagePullPolicy: IfNotPresent
resources:
limits:
cpu: 200m

View File

@ -50,7 +50,7 @@ spec:
- /bin/bash
- -c
- /kubevirt-scripts/install.sh
image: {{default .Registries.Kubectl .ImageRepository}}{{.Images.Kubectl}}
image: {{.CustomRegistries.Kubectl | default .ImageRepository | default .Registries.Kubectl }}{{.Images.Kubectl}}
imagePullPolicy: IfNotPresent
name: kubevirt-provisioner
lifecycle:

View File

@ -41,8 +41,8 @@ spec:
serviceAccountName: sa-logviewer
containers:
- name: logviewer
imagePullPolicy: Always
image: {{default .Registries.LogViewer .ImageRepository}}{{.Images.LogViewer}}
imagePullPolicy: IfNotPresent
image: {{.CustomRegistries.LogViewer | default .ImageRepository | default .Registries.LogViewer }}{{.Images.LogViewer}}
volumeMounts:
- name: logs
mountPath: /var/log/containers/

View File

@ -212,7 +212,7 @@ spec:
valueFrom:
fieldRef:
fieldPath: status.hostIP
image: {{default .Registries.Speaker .ImageRepository}}{{.Images.Speaker}}
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 .Registries.Controller .ImageRepository}}{{.Images.Controller}}
image: {{.CustomRegistries.Controller | default .ImageRepository | default .Registries.Controller }}{{.Images.Controller}}
imagePullPolicy: IfNotPresent
name: controller
ports:

View File

@ -19,7 +19,7 @@ spec:
spec:
containers:
- name: metrics-server
image: {{default .Registries.MetricsServer .ImageRepository}}{{.Images.MetricsServer}}
image: {{.CustomRegistries.MetricsServer | default .ImageRepository | default .Registries.MetricsServer }}{{.Images.MetricsServer}}
imagePullPolicy: IfNotPresent
command:
- /metrics-server

View File

@ -82,7 +82,7 @@ spec:
- $(OPERATOR_NAMESPACE)
- -writeStatusName
- ""
image: {{default .Registries.OLM .ImageRepository}}{{.Images.OLM}}
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: {{default .Registries.OLM .ImageRepository}}{{.Images.OLM}}
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: {{default .Registries.OLM .ImageRepository}}{{.Images.OLM}}
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: {{default .Registries.UpstreamCommunityOperators .ImageRepository}}{{.Images.UpstreamCommunityOperators}}
image: {{.CustomRegistries.UpstreamCommunityOperators | default .ImageRepository | default .Registries.UpstreamCommunityOperators }}{{.Images.UpstreamCommunityOperators}}
displayName: Community Operators
publisher: OperatorHub.io

View File

@ -17,7 +17,7 @@ spec:
spec:
initContainers:
- name: update
image: {{default .Registries.Alpine .ImageRepository}}{{.Images.Alpine}}
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 .Registries.Pause .ImageRepository}}{{.Images.Pause}}
image: {{.CustomRegistries.Pause | default .ImageRepository | default .Registries.Pause }}{{.Images.Pause}}
terminationGracePeriodSeconds: 30
volumes:
- name: etchosts

View File

@ -18,9 +18,9 @@ spec:
addonmanager.kubernetes.io/mode: Reconcile
spec:
containers:
- image: {{default .Registries.RegistryCreds .ImageRepository}}{{.Images.RegistryCreds}}
- image: {{.CustomRegistries.RegistryCreds | default .ImageRepository | default .Registries.RegistryCreds }}{{.Images.RegistryCreds}}
name: registry-creds
imagePullPolicy: Always
imagePullPolicy: IfNotPresent
env:
- name: AWS_ACCESS_KEY_ID
valueFrom:

View File

@ -19,7 +19,7 @@ spec:
addonmanager.kubernetes.io/mode: Reconcile
spec:
containers:
- image: {{default .Registries.KubeRegistryProxy .ImageRepository}}{{.Images.KubeRegistryProxy}}
- image: {{.CustomRegistries.KubeRegistryProxy | default .ImageRepository | default .Registries.KubeRegistryProxy }}{{.Images.KubeRegistryProxy}}
imagePullPolicy: IfNotPresent
name: registry-proxy
ports:

View File

@ -18,7 +18,7 @@ spec:
addonmanager.kubernetes.io/mode: Reconcile
spec:
containers:
- image: {{default .Registries.Registry .ImageRepository}}{{.Images.Registry}}
- image: {{.CustomRegistries.Registry | default .ImageRepository | default .Registries.Registry }}{{.Images.Registry}}
imagePullPolicy: IfNotPresent
name: registry
ports:

View File

@ -31,7 +31,7 @@ spec:
# kubernetes.io/hostname: minikube
hostNetwork: true
containers:
- image: {{default .Registries.GlusterfsServer .ImageRepository}}{{.Images.GlusterfsServer}}
- image: {{.CustomRegistries.GlusterfsServer | default .ImageRepository | default .Registries.GlusterfsServer }}{{.Images.GlusterfsServer}}
imagePullPolicy: IfNotPresent
name: glusterfs
env:

View File

@ -116,7 +116,7 @@ spec:
spec:
serviceAccountName: heketi-service-account
containers:
- image: {{default .Registries.Heketi .ImageRepository}}{{.Images.Heketi}}
- image: {{.CustomRegistries.Heketi | default .ImageRepository | default .Registries.Heketi }}{{.Images.Heketi}}
imagePullPolicy: IfNotPresent
name: heketi
env:

View File

@ -106,8 +106,8 @@ spec:
serviceAccountName: glusterfile-provisioner
containers:
- name: glusterfile-provisioner
image: {{default .Registries.GlusterfileProvisioner .ImageRepository}}{{.Images.GlusterfileProvisioner}}
imagePullPolicy: Always
image: {{.CustomRegistries.GlusterfileProvisioner | default .ImageRepository | default .Registries.GlusterfileProvisioner }}{{.Images.GlusterfileProvisioner}}
imagePullPolicy: IfNotPresent
env:
- name: PROVISIONER_NAME
value: gluster.org/glusterfile

View File

@ -100,7 +100,7 @@ spec:
hostNetwork: true
containers:
- name: storage-provisioner
image: {{default .Registries.StorageProvisioner .ImageRepository}}{{.Images.StorageProvisioner}}
image: {{.CustomRegistries.StorageProvisioner | default .ImageRepository | default .Registries.StorageProvisioner }}{{.Images.StorageProvisioner}}
command: ["/storage-provisioner"]
imagePullPolicy: IfNotPresent
volumeMounts:

View File

@ -23,7 +23,7 @@ spec:
containers:
- name: volume-snapshot-controller
# TODO(xyang): Replace with an official image when it is released
image: {{default .Registries.SnapshotController .ImageRepository}}{{.Images.SnapshotController}}
image: {{.CustomRegistries.SnapshotController | default .ImageRepository | default .Registries.SnapshotController }}{{.Images.SnapshotController}}
args:
- "--v=5"
imagePullPolicy: Always
imagePullPolicy: IfNotPresent

View File

@ -615,6 +615,7 @@ func GenerateTemplateData(addon *Addon, cfg config.KubernetesConfig) interface{}
CustomIngressCert string
Images map[string]string
Registries map[string]string
CustomRegistries map[string]string
}{
Arch: a,
ExoticArch: ea,
@ -624,6 +625,10 @@ func GenerateTemplateData(addon *Addon, cfg config.KubernetesConfig) interface{}
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 {
@ -658,8 +663,8 @@ func GenerateTemplateData(addon *Addon, cfg config.KubernetesConfig) interface{}
out.WarningT("Ignoring invalid custom registry {{.conf}}", out.V{"conf": registry})
continue
}
if _, ok := opts.Registries[vals[0]]; ok {
opts.Registries[vals[0]] = vals[1]
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]})
}
@ -668,17 +673,39 @@ func GenerateTemplateData(addon *Addon, cfg config.KubernetesConfig) interface{}
// Append postfix "/" to registries
for k, v := range opts.Registries {
if opts.Registries[k] != "" && !strings.HasSuffix(opts.Registries[k], "/") {
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
out.ErrT(style.Option, "Using image {{.registry}}{{.image}}", out.V{"registry": opts.Registries[name], "image": image})
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
}

View File

@ -128,8 +128,8 @@ minikube addons enable dashboard
### Options
```
--images string Images used by this addon. Divided by comma.
--registries string Registries used by this addon. Divided by comma.
--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