Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions deploy/installer/generated/ibm-block-csi-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,9 @@ spec:
- amd64
- s390x
- ppc64le
hostIPC: false
hostNetwork: false
hostPID: false
containers:
- name: ibm-block-csi-operator
resources:
Expand All @@ -1467,9 +1470,14 @@ spec:
initialDelaySeconds: 10
periodSeconds: 30
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
privileged: false
readOnlyRootFilesystem: true
runAsNonRoot: true
runAsUser: 1001
image: ibmcom/ibm-block-csi-operator:1.4.0
imagePullPolicy: IfNotPresent
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,9 @@ spec:
operator: In
values:
- amd64
hostIPC: false
hostNetwork: false
hostPID: false
containers:
- name: ibm-block-csi-operator
resources:
Expand All @@ -765,9 +768,14 @@ spec:
initialDelaySeconds: 10
periodSeconds: 30
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
privileged: false
readOnlyRootFilesystem: true
runAsNonRoot: true
runAsUser: 1001
image: ibmcom/ibm-block-csi-operator:1.4.0
imagePullPolicy: IfNotPresent
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,9 @@ spec:
operator: In
values:
- amd64
hostIPC: false
hostNetwork: false
hostPID: false
containers:
- name: ibm-block-csi-operator
resources:
Expand All @@ -763,9 +766,14 @@ spec:
initialDelaySeconds: 10
periodSeconds: 30
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
privileged: false
readOnlyRootFilesystem: true
runAsNonRoot: true
runAsUser: 1001
image: registry.connect.redhat.com/ibm/ibm-block-csi-operator:1.4.0
imagePullPolicy: IfNotPresent
command:
Expand Down
8 changes: 8 additions & 0 deletions deploy/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ spec:
- amd64
- s390x
- ppc64le
hostIPC: false
hostNetwork: false
hostPID: false
containers:
- name: ibm-block-csi-operator
resources:
Expand All @@ -60,9 +63,14 @@ spec:
initialDelaySeconds: 10
periodSeconds: 30
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
privileged: false
readOnlyRootFilesystem: true
runAsNonRoot: true
runAsUser: 1001
image: ibmcom/ibm-block-csi-operator:1.4.0
imagePullPolicy: IfNotPresent
command:
Expand Down
1 change: 1 addition & 0 deletions pkg/config/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const (
DefaultNamespace = "default"
DefaultLogLevel = "DEBUG"
ControllerUserID = int64(9999)
NonRootUserID = int64(1001)

NodeAgentPort = "10086"
)
12 changes: 9 additions & 3 deletions pkg/controller/ibmblockcsi/syncer/csi_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ func (s *csiControllerSyncer) ensurePodSpec() corev1.PodSpec {
Containers: s.ensureContainersSpec(),
Volumes: s.ensureVolumes(),
SecurityContext: &corev1.PodSecurityContext{
FSGroup: &fsGroup,
RunAsUser: &fsGroup,
RunAsUser: &fsGroup,
RunAsNonRoot: boolptr.True(),
FSGroup: &fsGroup,
},
Affinity: s.driver.Spec.Controller.Affinity,
Tolerations: s.driver.Spec.Controller.Tolerations,
Expand Down Expand Up @@ -223,7 +224,12 @@ func ensureNodeAffinity() *corev1.NodeAffinity {
}

func (s *csiControllerSyncer) ensureContainer(name, image string, args []string) corev1.Container {
sc := &corev1.SecurityContext{AllowPrivilegeEscalation: boolptr.False()}
sc := &corev1.SecurityContext{
Privileged: boolptr.False(),
RunAsNonRoot: boolptr.True(),
ReadOnlyRootFilesystem: boolptr.True(),
AllowPrivilegeEscalation: boolptr.False(),
}
fillSecurityContextCapabilities(sc)
return corev1.Container{
Name: name,
Expand Down
22 changes: 20 additions & 2 deletions pkg/controller/ibmblockcsi/syncer/csi_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ func (s *csiNodeSyncer) ensurePodSpec() corev1.PodSpec {
HostIPC: true,
HostNetwork: true,
ServiceAccountName: config.GetNameForResource(config.CSINodeServiceAccount, s.driver.Name),
SecurityContext: &corev1.PodSecurityContext{RunAsNonRoot: boolptr.True()},
Affinity: s.driver.Spec.Node.Affinity,
Tolerations: s.driver.Spec.Node.Tolerations,
}
Expand Down Expand Up @@ -135,6 +136,8 @@ func (s *csiNodeSyncer) ensureContainersSpec() []corev1.Container {

nodePlugin.SecurityContext = &corev1.SecurityContext{
Privileged: boolptr.True(),
RunAsNonRoot: boolptr.False(),
ReadOnlyRootFilesystem: boolptr.True(),
AllowPrivilegeEscalation: boolptr.True(),
}
fillSecurityContextCapabilities(
Expand Down Expand Up @@ -163,7 +166,16 @@ func (s *csiNodeSyncer) ensureContainersSpec() []corev1.Container {
},
},
}
registrar.SecurityContext = &corev1.SecurityContext{AllowPrivilegeEscalation: boolptr.False()}

nonRootUserID := config.NonRootUserID

registrar.SecurityContext = &corev1.SecurityContext{
Privileged: boolptr.False(),
RunAsUser: &nonRootUserID,
RunAsNonRoot: boolptr.True(),
ReadOnlyRootFilesystem: boolptr.False(),
AllowPrivilegeEscalation: boolptr.False(),
}
fillSecurityContextCapabilities(registrar.SecurityContext)
registrar.ImagePullPolicy = s.getCSINodeDriverRegistrarPullPolicy()

Expand All @@ -174,7 +186,13 @@ func (s *csiNodeSyncer) ensureContainersSpec() []corev1.Container {
"--csi-address=/csi/csi.sock",
},
)
livenessProbe.SecurityContext = &corev1.SecurityContext{AllowPrivilegeEscalation: boolptr.False()}
livenessProbe.SecurityContext = &corev1.SecurityContext{
Privileged: boolptr.False(),
RunAsUser: &nonRootUserID,
RunAsNonRoot: boolptr.True(),
ReadOnlyRootFilesystem: boolptr.True(),
AllowPrivilegeEscalation: boolptr.False(),
}
fillSecurityContextCapabilities(livenessProbe.SecurityContext)
livenessProbe.ImagePullPolicy = s.getCSINodeDriverRegistrarPullPolicy()

Expand Down