Skip to content

Commit

Permalink
Merge pull request openshift#334 from e0ne/image-pull-secret
Browse files Browse the repository at this point in the history
Pass imagePullSecrets values to operator components via helm chart
  • Loading branch information
SchSeba authored Aug 1, 2022
2 parents d6c5f87 + f105b46 commit e91b58d
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 0 deletions.
6 changes: 6 additions & 0 deletions bindata/manifests/daemon/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ spec:
- operator: Exists
serviceAccountName: sriov-network-config-daemon
priorityClassName: "system-node-critical"
{{- if .ImagePullSecrets }}
imagePullSecrets:
{{- range .ImagePullSecrets }}
- name: {{ . }}
{{- end }}
{{- end }}
containers:
- name: sriov-cni
image: {{.SRIOVCNIImage}}
Expand Down
6 changes: 6 additions & 0 deletions bindata/manifests/operator-webhook/server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ spec:
- key: "node.kubernetes.io/not-ready"
operator: Exists
effect: NoSchedule
{{- if .ImagePullSecrets }}
imagePullSecrets:
{{- range .ImagePullSecrets }}
- name: {{ . }}
{{- end }}
{{- end }}
containers:
- name: webhook-server
image: {{.SriovNetworkWebhookImage}}
Expand Down
6 changes: 6 additions & 0 deletions bindata/manifests/plugins/sriov-device-plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ spec:
- operator: Exists
serviceAccountName: sriov-device-plugin
priorityClassName: "system-node-critical"
{{- if .ImagePullSecrets }}
imagePullSecrets:
{{- range .ImagePullSecrets }}
- name: {{ . }}
{{- end }}
{{- end }}
containers:
- name: sriov-device-plugin
image: {{.SRIOVDevicePluginImage}}
Expand Down
6 changes: 6 additions & 0 deletions bindata/manifests/webhook/server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ spec:
- key: "node.kubernetes.io/not-ready"
operator: Exists
effect: NoSchedule
{{- if .ImagePullSecrets }}
imagePullSecrets:
{{- range .ImagePullSecrets }}
- name: {{ . }}
{{- end }}
{{- end }}
containers:
- name: webhook-server
image: {{.NetworkResourcesInjectorImage}}
Expand Down
10 changes: 10 additions & 0 deletions controllers/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package controllers

import (
"os"
"strings"

constants "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/utils"
)
Expand All @@ -28,3 +29,12 @@ var webhooks = map[string](string){
}

var namespace = os.Getenv("NAMESPACE")

func GetImagePullSecrets() []string {
imagePullSecrets := os.Getenv("IMAGE_PULL_SECRETS")
if imagePullSecrets != "" {
return strings.Split(imagePullSecrets, ",")
} else {
return []string{}
}
}
1 change: 1 addition & 0 deletions controllers/sriovnetworknodepolicy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ func (r *SriovNetworkNodePolicyReconciler) syncPluginDaemonObjs(dp *sriovnetwork
data.Data["SRIOVDevicePluginImage"] = os.Getenv("SRIOV_DEVICE_PLUGIN_IMAGE")
data.Data["ReleaseVersion"] = os.Getenv("RELEASEVERSION")
data.Data["ResourcePrefix"] = os.Getenv("RESOURCE_PREFIX")
data.Data["ImagePullSecrets"] = GetImagePullSecrets()

objs, err := renderDsForCR(constants.PluginPath, &data)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions controllers/sriovoperatorconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ func (r *SriovOperatorConfigReconciler) syncConfigDaemonSet(dc *sriovnetworkv1.S
data.Data["ReleaseVersion"] = os.Getenv("RELEASEVERSION")
data.Data["ClusterType"] = constants.ClusterType
data.Data["DevMode"] = os.Getenv("DEV_MODE")
data.Data["ImagePullSecrets"] = GetImagePullSecrets()
envCniBinPath := os.Getenv("SRIOV_CNI_BIN_PATH")
if envCniBinPath == "" {
data.Data["CNIBinPath"] = "/var/lib/cni/bin"
Expand Down Expand Up @@ -226,6 +227,7 @@ func (r *SriovOperatorConfigReconciler) syncWebhookObjs(dc *sriovnetworkv1.Sriov
data.Data["ClusterType"] = constants.ClusterType
data.Data["CaBundle"] = os.Getenv("WEBHOOK_CA_BUNDLE")
data.Data["DevMode"] = os.Getenv("DEV_MODE")
data.Data["ImagePullSecrets"] = GetImagePullSecrets()
objs, err := render.RenderDir(path, &data)
if err != nil {
logger.Error(err, "Fail to render webhook manifests")
Expand Down
4 changes: 4 additions & 0 deletions deployment/sriov-network-operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ $ kubectl -n sriov-network-operator get pods
In order to tailor the deployment of the network operator to your cluster needs
We have introduced the following Chart parameters.

| Name | Type | Default | description |
| ---- |------|---------|-------------|
| `imagePullSecrets` | list | `[]` | An optional list of references to secrets to use for pulling any of the SR-IOV Network Operator image |

### Operator parameters

| Name | Type | Default | description |
Expand Down
8 changes: 8 additions & 0 deletions deployment/sriov-network-operator/templates/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ spec:
{{- end }}
serviceAccountName: {{ include "sriov-network-operator.fullname" . }}
priorityClassName: "system-node-critical"
{{- if .ImagePullSecrets }}
imagePullSecrets:
{{- range .ImagePullSecrets }}
- name: {{ . }}
{{- end }}
{{- end }}
containers:
- name: {{ include "sriov-network-operator.fullname" . }}
image: {{ .Values.images.operator }}
Expand Down Expand Up @@ -65,6 +71,8 @@ spec:
value: {{ .Values.operator.resourcePrefix }}
- name: ENABLE_ADMISSION_CONTROLLER
value: {{ .Values.operator.enableAdmissionController | quote }}
- name: IMAGE_PULL_SECRETS
value: {{ join "," .Values.imagePullSecrets }}
- name: NAMESPACE
valueFrom:
fieldRef:
Expand Down
2 changes: 2 additions & 0 deletions deployment/sriov-network-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ images:
sriovDevicePlugin: ghcr.io/k8snetworkplumbingwg/sriov-network-device-plugin
resourcesInjector: ghcr.io/k8snetworkplumbingwg/network-resources-injector
webhook: ghcr.io/k8snetworkplumbingwg/sriov-network-operator-webhook

imagePullSecrets: []

0 comments on commit e91b58d

Please sign in to comment.