Skip to content

Commit 48282e6

Browse files
authored
Operator can override default images from env
1 parent 339efdf commit 48282e6

File tree

8 files changed

+253
-154
lines changed

8 files changed

+253
-154
lines changed

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ RUN --mount=type=secret,id=activation_key,env=ACTIVATION_KEY \
1111
--mount=type=secret,id=organization,env=ORGANIZATION \
1212
function unregister() { subscription-manager unregister || true; }; trap unregister EXIT; \
1313
if [[ $DEPS_IMAGE =~ "alpine" ]]; \
14-
then apk add nfs-utils; \
15-
else subscription-manager register --activationkey $ACTIVATION_KEY --org $ORGANIZATION && \
16-
yum install --repo=rhel-9-*-baseos-rpms -y nfs-utils; \
14+
then apk add nfs-utils; \
15+
else subscription-manager register --activationkey $ACTIVATION_KEY --org $ORGANIZATION && \
16+
yum install --repo=rhel-9-*-baseos-rpms -y nfs-utils; \
1717
fi
1818

1919
# Get the mount.nfs4 dependency

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,9 @@ create_manifest_for_platforms = $(DOCKER_BUILDX_BUILD_CLI) imagetools create -t
323323
# digest: "$digest", os: "$os", architecture: "$arch"}
324324
# usage: $(call image_digests,$(platforms),$(tag))
325325
image_digests = for image in $(foreach platform,$1,$(call image_tag,$2,$(platform))); do\
326-
$(DOCKER_BUILDX_BUILD_CLI) imagetools inspect --raw $$image |\
326+
$(DOCKER_BUILDX_BUILD_CLI) imagetools inspect --format '{{json .Manifest}}' $$image |\
327327
jq ".manifests[0] | {image: \"$$image\", digest: .digest, os: .platform.os, architecture: .platform.architecture }";\
328-
done | jq -n '{manifest: "$2", images: [inputs]}'
328+
done | jq -n "{manifest: \"$2\", digest: \"$$($(DOCKER_BUILDX_BUILD_CLI) imagetools inspect --format '{{json .Manifest}}' $2 | jq -r .digest)\", images: [inputs]}"
329329

330330
# Build targets
331331

cli/k8s_client/types.go

Lines changed: 62 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -135,65 +135,71 @@ type KubernetesClient interface {
135135
}
136136

137137
type DeploymentYAMLArguments struct {
138-
DeploymentName string `json:"deploymentName"`
139-
TridentImage string `json:"tridentImage"`
140-
AutosupportImage string `json:"autosupportImage"`
141-
AutosupportProxy string `json:"autosupportProxy"`
142-
AutosupportInsecure bool `json:"autosupportInsecure"`
143-
AutosupportCustomURL string `json:"autosupportCustomURL"`
144-
AutosupportSerialNumber string `json:"autosupportSerialNumber"`
145-
AutosupportHostname string `json:"autosupportHostname"`
146-
ImageRegistry string `json:"imageRegistry"`
147-
LogFormat string `json:"logFormat"`
148-
LogLevel string `json:"logLevel"`
149-
LogWorkflows string `json:"logWorkflows"`
150-
LogLayers string `json:"logLayers"`
151-
ImagePullSecrets []string `json:"imagePullSecrets"`
152-
Labels map[string]string `json:"labels"`
153-
ControllingCRDetails map[string]string `json:"controllingCRDetails"`
154-
Debug bool `json:"debug"`
155-
UseIPv6 bool `json:"useIPv6"`
156-
SilenceAutosupport bool `json:"silenceAutosupport"`
157-
Version *versionutils.Version `json:"version"`
158-
DisableAuditLog bool `json:"disableAuditLog"`
159-
HTTPRequestTimeout string `json:"httpRequestTimeout"`
160-
NodeSelector map[string]string `json:"nodeSelector"`
161-
Tolerations []map[string]string `json:"tolerations"`
162-
ServiceAccountName string `json:"serviceAccountName"`
163-
ImagePullPolicy string `json:"imagePullPolicy"`
164-
EnableForceDetach bool `json:"enableForceDetach"`
165-
ACPImage string `json:"acpImage"` // TODO: Remove after 26.04.
166-
EnableACP bool `json:"enableACP"` // TODO: Remove after 26.04.
167-
CloudProvider string `json:"cloudProvider"`
168-
IdentityLabel bool `json:"identityLabel"`
169-
K8sAPIQPS int `json:"k8sAPIQPS"`
138+
DeploymentName string `json:"deploymentName"`
139+
TridentImage string `json:"tridentImage"`
140+
AutosupportImage string `json:"autosupportImage"`
141+
AutosupportProxy string `json:"autosupportProxy"`
142+
AutosupportInsecure bool `json:"autosupportInsecure"`
143+
AutosupportCustomURL string `json:"autosupportCustomURL"`
144+
AutosupportSerialNumber string `json:"autosupportSerialNumber"`
145+
AutosupportHostname string `json:"autosupportHostname"`
146+
ImageRegistry string `json:"imageRegistry"`
147+
CSISidecarProvisionerImage string `json:"csiSidecarProvisionerImage"`
148+
CSISidecarAttacherImage string `json:"csiSidecarAttacherImage"`
149+
CSISidecarResizerImage string `json:"csiSidecarResizerImage"`
150+
CSISidecarSnapshotterImage string `json:"csiSidecarSnapshotterImage"`
151+
LogFormat string `json:"logFormat"`
152+
LogLevel string `json:"logLevel"`
153+
LogWorkflows string `json:"logWorkflows"`
154+
LogLayers string `json:"logLayers"`
155+
ImagePullSecrets []string `json:"imagePullSecrets"`
156+
Labels map[string]string `json:"labels"`
157+
ControllingCRDetails map[string]string `json:"controllingCRDetails"`
158+
Debug bool `json:"debug"`
159+
UseIPv6 bool `json:"useIPv6"`
160+
SilenceAutosupport bool `json:"silenceAutosupport"`
161+
Version *versionutils.Version `json:"version"`
162+
DisableAuditLog bool `json:"disableAuditLog"`
163+
HTTPRequestTimeout string `json:"httpRequestTimeout"`
164+
NodeSelector map[string]string `json:"nodeSelector"`
165+
Tolerations []map[string]string `json:"tolerations"`
166+
ServiceAccountName string `json:"serviceAccountName"`
167+
ImagePullPolicy string `json:"imagePullPolicy"`
168+
EnableForceDetach bool `json:"enableForceDetach"`
169+
ACPImage string `json:"acpImage"` // TODO: Remove after 26.04.
170+
EnableACP bool `json:"enableACP"` // TODO: Remove after 26.04.
171+
CloudProvider string `json:"cloudProvider"`
172+
IdentityLabel bool `json:"identityLabel"`
173+
K8sAPIQPS int `json:"k8sAPIQPS"`
170174
}
171175

172176
type DaemonsetYAMLArguments struct {
173-
DaemonsetName string `json:"daemonsetName"`
174-
TridentImage string `json:"tridentImage"`
175-
ImageRegistry string `json:"imageRegistry"`
176-
KubeletDir string `json:"kubeletDir"`
177-
LogFormat string `json:"logFormat"`
178-
LogLevel string `json:"logLevel"`
179-
LogWorkflows string `json:"logWorkflows"`
180-
LogLayers string `json:"logLayers"`
181-
ProbePort string `json:"probePort"`
182-
ImagePullSecrets []string `json:"imagePullSecrets"`
183-
Labels map[string]string `json:"labels"`
184-
ControllingCRDetails map[string]string `json:"controllingCRDetails"`
185-
EnableForceDetach bool `json:"enableForceDetach"`
186-
DisableAuditLog bool `json:"disableAuditLog"`
187-
Debug bool `json:"debug"`
188-
Version *versionutils.Version `json:"version"`
189-
HTTPRequestTimeout string `json:"httpRequestTimeout"`
190-
NodeSelector map[string]string `json:"nodeSelector"`
191-
Tolerations []map[string]string `json:"tolerations"`
192-
ServiceAccountName string `json:"serviceAccountName"`
193-
ImagePullPolicy string `json:"imagePullPolicy"`
194-
ISCSISelfHealingInterval string `json:"iscsiSelfHealingInterval"`
195-
ISCSISelfHealingWaitTime string `json:"iscsiSelfHealingWaitTime"`
196-
NodePrep []string `json:"nodePrep"`
177+
DaemonsetName string `json:"daemonsetName"`
178+
TridentImage string `json:"tridentImage"`
179+
ImageRegistry string `json:"imageRegistry"`
180+
CSISidecarNodeDriverRegistrarImage string `json:"csiSidecarNodeDriverRegistrarImage"`
181+
CSISidecarLivenessProbeImage string `json:"csiSidecarLivenessProbeImage"`
182+
KubeletDir string `json:"kubeletDir"`
183+
LogFormat string `json:"logFormat"`
184+
LogLevel string `json:"logLevel"`
185+
LogWorkflows string `json:"logWorkflows"`
186+
LogLayers string `json:"logLayers"`
187+
ProbePort string `json:"probePort"`
188+
ImagePullSecrets []string `json:"imagePullSecrets"`
189+
Labels map[string]string `json:"labels"`
190+
ControllingCRDetails map[string]string `json:"controllingCRDetails"`
191+
EnableForceDetach bool `json:"enableForceDetach"`
192+
DisableAuditLog bool `json:"disableAuditLog"`
193+
Debug bool `json:"debug"`
194+
Version *versionutils.Version `json:"version"`
195+
HTTPRequestTimeout string `json:"httpRequestTimeout"`
196+
NodeSelector map[string]string `json:"nodeSelector"`
197+
Tolerations []map[string]string `json:"tolerations"`
198+
ServiceAccountName string `json:"serviceAccountName"`
199+
ImagePullPolicy string `json:"imagePullPolicy"`
200+
ISCSISelfHealingInterval string `json:"iscsiSelfHealingInterval"`
201+
ISCSISelfHealingWaitTime string `json:"iscsiSelfHealingWaitTime"`
202+
NodePrep []string `json:"nodePrep"`
197203
}
198204

199205
type TridentVersionPodYAMLArguments struct {

cli/k8s_client/yaml_factory.go

Lines changed: 59 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,21 @@ func GetCSIDeploymentYAML(args *DeploymentYAMLArguments) string {
408408
args.ImageRegistry = commonconfig.KubernetesCSISidecarRegistry
409409
}
410410

411+
sidecarImages := []struct {
412+
arg *string
413+
tag string
414+
}{
415+
{&args.CSISidecarProvisionerImage, commonconfig.CSISidecarProvisionerImageTag},
416+
{&args.CSISidecarAttacherImage, commonconfig.CSISidecarAttacherImageTag},
417+
{&args.CSISidecarResizerImage, commonconfig.CSISidecarResizerImageTag},
418+
{&args.CSISidecarSnapshotterImage, commonconfig.CSISidecarSnapshotterImageTag},
419+
}
420+
for _, image := range sidecarImages {
421+
if *image.arg == "" {
422+
*image.arg = args.ImageRegistry + "/" + image.tag
423+
}
424+
}
425+
411426
if args.AutosupportImage == "" {
412427
args.AutosupportImage = commonconfig.DefaultAutosupportImage
413428
}
@@ -477,7 +492,10 @@ func GetCSIDeploymentYAML(args *DeploymentYAMLArguments) string {
477492

478493
deploymentYAML = strings.ReplaceAll(deploymentYAML, "{TRIDENT_IMAGE}", args.TridentImage)
479494
deploymentYAML = strings.ReplaceAll(deploymentYAML, "{DEPLOYMENT_NAME}", args.DeploymentName)
480-
deploymentYAML = strings.ReplaceAll(deploymentYAML, "{CSI_SIDECAR_REGISTRY}", args.ImageRegistry)
495+
deploymentYAML = strings.ReplaceAll(deploymentYAML, "{CSI_SIDECAR_PROVISIONER_IMAGE}", args.CSISidecarProvisionerImage)
496+
deploymentYAML = strings.ReplaceAll(deploymentYAML, "{CSI_SIDECAR_ATTACHER_IMAGE}", args.CSISidecarAttacherImage)
497+
deploymentYAML = strings.ReplaceAll(deploymentYAML, "{CSI_SIDECAR_RESIZER_IMAGE}", args.CSISidecarResizerImage)
498+
deploymentYAML = strings.ReplaceAll(deploymentYAML, "{CSI_SIDECAR_SNAPSHOTTER_IMAGE}", args.CSISidecarSnapshotterImage)
481499
deploymentYAML = strings.ReplaceAll(deploymentYAML, "{LABEL_APP}", args.Labels[TridentAppLabelKey])
482500
deploymentYAML = strings.ReplaceAll(deploymentYAML, "{SIDECAR_LOG_LEVEL}", sideCarLogLevel)
483501
deploymentYAML = strings.ReplaceAll(deploymentYAML, "{LOG_FORMAT}", args.LogFormat)
@@ -633,7 +651,7 @@ spec:
633651
- name: asup-dir
634652
mountPath: /asup
635653
- name: csi-provisioner
636-
image: {CSI_SIDECAR_REGISTRY}/csi-provisioner:v5.2.0
654+
image: {CSI_SIDECAR_PROVISIONER_IMAGE}
637655
imagePullPolicy: {IMAGE_PULL_POLICY}
638656
securityContext:
639657
capabilities:
@@ -653,7 +671,7 @@ spec:
653671
- name: socket-dir
654672
mountPath: /var/lib/csi/sockets/pluginproxy/
655673
- name: csi-attacher
656-
image: {CSI_SIDECAR_REGISTRY}/csi-attacher:v4.8.0
674+
image: {CSI_SIDECAR_ATTACHER_IMAGE}
657675
imagePullPolicy: {IMAGE_PULL_POLICY}
658676
securityContext:
659677
capabilities:
@@ -672,8 +690,12 @@ spec:
672690
- name: socket-dir
673691
mountPath: /var/lib/csi/sockets/pluginproxy/
674692
- name: csi-resizer
675-
image: {CSI_SIDECAR_REGISTRY}/csi-resizer:v1.13.1
693+
image: {CSI_SIDECAR_RESIZER_IMAGE}
676694
imagePullPolicy: {IMAGE_PULL_POLICY}
695+
securityContext:
696+
capabilities:
697+
drop:
698+
- all
677699
args:
678700
- "--v={SIDECAR_LOG_LEVEL}"
679701
- "--timeout=300s"
@@ -686,7 +708,7 @@ spec:
686708
- name: socket-dir
687709
mountPath: /var/lib/csi/sockets/pluginproxy/
688710
- name: csi-snapshotter
689-
image: {CSI_SIDECAR_REGISTRY}/csi-snapshotter:v8.2.0
711+
image: {CSI_SIDECAR_SNAPSHOTTER_IMAGE}
690712
imagePullPolicy: {IMAGE_PULL_POLICY}
691713
securityContext:
692714
capabilities:
@@ -771,10 +793,6 @@ func GetCSIDaemonSetYAMLWindows(args *DaemonsetYAMLArguments) string {
771793
daemonSetYAML = daemonSet120YAMLTemplateWindows
772794
}
773795

774-
if args.ImageRegistry == "" {
775-
args.ImageRegistry = commonconfig.KubernetesCSISidecarRegistry
776-
}
777-
778796
if args.Labels == nil {
779797
args.Labels = map[string]string{}
780798
}
@@ -788,10 +806,28 @@ func GetCSIDaemonSetYAMLWindows(args *DaemonsetYAMLArguments) string {
788806
}
789807
}
790808

809+
if args.ImageRegistry == "" {
810+
args.ImageRegistry = commonconfig.KubernetesCSISidecarRegistry
811+
}
812+
813+
sidecarImages := []struct {
814+
arg *string
815+
tag string
816+
}{
817+
{&args.CSISidecarNodeDriverRegistrarImage, commonconfig.CSISidecarNodeDriverRegistrarImageTag},
818+
{&args.CSISidecarLivenessProbeImage, commonconfig.CSISidecarLivenessProbeImageTag},
819+
}
820+
for _, image := range sidecarImages {
821+
if *image.arg == "" {
822+
*image.arg = args.ImageRegistry + "/" + image.tag
823+
}
824+
}
825+
791826
kubeletDir := strings.TrimRight(args.KubeletDir, "/")
792827
daemonSetYAML = strings.ReplaceAll(daemonSetYAML, "{TRIDENT_IMAGE}", args.TridentImage)
793828
daemonSetYAML = strings.ReplaceAll(daemonSetYAML, "{DAEMONSET_NAME}", args.DaemonsetName)
794-
daemonSetYAML = strings.ReplaceAll(daemonSetYAML, "{CSI_SIDECAR_REGISTRY}", args.ImageRegistry)
829+
daemonSetYAML = strings.ReplaceAll(daemonSetYAML, "{CSI_SIDECAR_NODE_DRIVER_REGISTRAR_IMAGE}", args.CSISidecarNodeDriverRegistrarImage)
830+
daemonSetYAML = strings.ReplaceAll(daemonSetYAML, "{CSI_SIDECAR_LIVENESS_PROBE_IMAGE}", args.CSISidecarLivenessProbeImage)
795831
daemonSetYAML = strings.ReplaceAll(daemonSetYAML, "{KUBELET_DIR}", kubeletDir)
796832
daemonSetYAML = strings.ReplaceAll(daemonSetYAML, "{LABEL_APP}", args.Labels[TridentAppLabelKey])
797833
daemonSetYAML = strings.ReplaceAll(daemonSetYAML, "{SIDECAR_LOG_LEVEL}", sidecarLogLevel)
@@ -844,10 +880,6 @@ func GetCSIDaemonSetYAMLLinux(args *DaemonsetYAMLArguments) string {
844880

845881
daemonSetYAML := daemonSet120YAMLTemplateLinux
846882

847-
if args.ImageRegistry == "" {
848-
args.ImageRegistry = commonconfig.KubernetesCSISidecarRegistry
849-
}
850-
851883
if args.Labels == nil {
852884
args.Labels = map[string]string{}
853885
}
@@ -861,12 +893,21 @@ func GetCSIDaemonSetYAMLLinux(args *DaemonsetYAMLArguments) string {
861893
}
862894
}
863895

896+
if args.ImageRegistry == "" {
897+
args.ImageRegistry = commonconfig.KubernetesCSISidecarRegistry
898+
}
899+
900+
if args.CSISidecarNodeDriverRegistrarImage == "" {
901+
args.CSISidecarNodeDriverRegistrarImage = args.ImageRegistry + "/" + commonconfig.CSISidecarNodeDriverRegistrarImageTag
902+
}
903+
864904
kubeletDir := strings.TrimRight(args.KubeletDir, "/")
865905
// NodePrep this must come first because it adds a section that has tags in it
866906
daemonSetYAML = replaceNodePrepTag(daemonSetYAML, args.NodePrep)
867907
daemonSetYAML = strings.ReplaceAll(daemonSetYAML, "{TRIDENT_IMAGE}", args.TridentImage)
868908
daemonSetYAML = strings.ReplaceAll(daemonSetYAML, "{DAEMONSET_NAME}", args.DaemonsetName)
869-
daemonSetYAML = strings.ReplaceAll(daemonSetYAML, "{CSI_SIDECAR_REGISTRY}", args.ImageRegistry)
909+
daemonSetYAML = strings.ReplaceAll(daemonSetYAML, "{CSI_SIDECAR_NODE_DRIVER_REGISTRAR_IMAGE}",
910+
args.CSISidecarNodeDriverRegistrarImage)
870911
daemonSetYAML = strings.ReplaceAll(daemonSetYAML, "{KUBELET_DIR}", kubeletDir)
871912
daemonSetYAML = strings.ReplaceAll(daemonSetYAML, "{LABEL_APP}", args.Labels[TridentAppLabelKey])
872913
daemonSetYAML = strings.ReplaceAll(daemonSetYAML, "{FORCE_DETACH_BOOL}", strconv.FormatBool(args.EnableForceDetach))
@@ -1069,7 +1110,7 @@ spec:
10691110
mountPath: /certs
10701111
readOnly: true
10711112
- name: driver-registrar
1072-
image: {CSI_SIDECAR_REGISTRY}/csi-node-driver-registrar:v2.13.0
1113+
image: {CSI_SIDECAR_NODE_DRIVER_REGISTRAR_IMAGE}
10731114
imagePullPolicy: {IMAGE_PULL_POLICY}
10741115
args:
10751116
- "--v={SIDECAR_LOG_LEVEL}"
@@ -1273,7 +1314,7 @@ spec:
12731314
cpu: 10m
12741315
memory: 20Mi
12751316
- name: node-driver-registrar
1276-
image: {CSI_SIDECAR_REGISTRY}/csi-node-driver-registrar:v2.10.0
1317+
image: {CSI_SIDECAR_NODE_DRIVER_REGISTRAR_IMAGE}
12771318
imagePullPolicy: {IMAGE_PULL_POLICY}
12781319
args:
12791320
- --v=2
@@ -1313,7 +1354,7 @@ spec:
13131354
volumeMounts:
13141355
- mountPath: C:\csi
13151356
name: plugin-dir
1316-
image: {CSI_SIDECAR_REGISTRY}/livenessprobe:v2.5.0
1357+
image: {CSI_SIDECAR_LIVENESS_PROBE_IMAGE}
13171358
args:
13181359
- --csi-address=$(CSI_ENDPOINT)
13191360
- --probe-timeout=3s

config/config.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,13 @@ const (
154154
KubernetesVersionMax = "v1.32"
155155

156156
// KubernetesCSISidecarRegistry is where the CSI sidecar images are hosted
157-
KubernetesCSISidecarRegistry = "registry.k8s.io/sig-storage"
157+
KubernetesCSISidecarRegistry = "registry.k8s.io/sig-storage"
158+
CSISidecarProvisionerImageTag = "csi-provisioner:v5.2.0"
159+
CSISidecarAttacherImageTag = "csi-attacher:v4.8.0"
160+
CSISidecarResizerImageTag = "csi-resizer:v1.13.1"
161+
CSISidecarSnapshotterImageTag = "csi-snapshotter:v8.2.0"
162+
CSISidecarNodeDriverRegistrarImageTag = "csi-node-driver-registrar:v2.13.0"
163+
CSISidecarLivenessProbeImageTag = "livenessprobe:v2.9.0"
158164

159165
DefaultK8sAPIQPS = 100.0
160166
DefaultK8sAPIBurst = 200

operator/config/config.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ const (
2525

2626
// ConfiguratorReconcileInterval is the resource refresh rate for the auto generated backends.
2727
ConfiguratorReconcileInterval time.Duration = 30 * time.Minute
28+
29+
TridentImageEnv = "DEFAULT_TRIDENT_IMAGE"
30+
AutosupportImageEnv = "DEFAULT_TRIDENT_AUTOSUPPORT_IMAGE"
31+
CSISidecarProvisionerImageEnv = "TRIDENT_CSI_SIDECAR_PROVISIONER_IMAGE"
32+
CSISidecarAttacherImageEnv = "TRIDENT_CSI_SIDECAR_ATTACHER_IMAGE"
33+
CSISidecarResizerImageEnv = "TRIDENT_CSI_SIDECAR_RESIZER_IMAGE"
34+
CSISidecarSnapshotterImageEnv = "TRIDENT_CSI_SIDECAR_SNAPSHOTTER_IMAGE"
35+
CSISidecarNodeDriverRegistrarImageEnv = "TRIDENT_CSI_SIDECAR_NODE_DRIVER_REGISTRAR_IMAGE"
36+
CSISidecarLivenessProbeImageEnv = "TRIDENT_CSI_SIDECAR_LIVENESS_PROBE_IMAGE"
2837
)
2938

3039
var (

0 commit comments

Comments
 (0)