Skip to content

Commit 23b15af

Browse files
Disable unshare in the pod containers (#179)
Signed-off-by: asararatnakar <[email protected]>
1 parent e314f75 commit 23b15af

File tree

14 files changed

+56
-0
lines changed

14 files changed

+56
-0
lines changed

bundle/manifests/fabric-opensource-operator.clusterserviceversion.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1837,6 +1837,8 @@ spec:
18371837
ephemeral-storage: 100Mi
18381838
memory: 200Mi
18391839
securityContext:
1840+
seccompProfile:
1841+
type: RuntimeDefault
18401842
allowPrivilegeEscalation: false
18411843
capabilities:
18421844
add:

config/manager/manager.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ spec:
9898
memory: 200Mi
9999
ephemeral-storage: 100Mi
100100
securityContext:
101+
seccompProfile:
102+
type: RuntimeDefault
101103
allowPrivilegeEscalation: false
102104
capabilities:
103105
add:

config/manifests/bases/fabric-opensource-operator.clusterserviceversion.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -1834,6 +1834,8 @@ spec:
18341834
ephemeral-storage: 100Mi
18351835
memory: 200Mi
18361836
securityContext:
1837+
seccompProfile:
1838+
type: RuntimeDefault
18371839
allowPrivilegeEscalation: false
18381840
capabilities:
18391841
add:

definitions/ca/deployment.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ spec:
7474
ephemeral-storage: 100M
7575
memory: 100Mi
7676
securityContext:
77+
seccompProfile:
78+
type: RuntimeDefault
7779
allowPrivilegeEscalation: false
7880
capabilities:
7981
add:

definitions/console/deployment.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ spec:
6262
ephemeral-storage: 100M
6363
memory: 1000Mi
6464
securityContext:
65+
seccompProfile:
66+
type: RuntimeDefault
6567
allowPrivilegeEscalation: false
6668
capabilities:
6769
add:
@@ -110,6 +112,8 @@ spec:
110112
ephemeral-storage: 100M
111113
memory: 200Mi
112114
securityContext:
115+
seccompProfile:
116+
type: RuntimeDefault
113117
allowPrivilegeEscalation: false
114118
capabilities:
115119
add:
@@ -160,6 +164,8 @@ spec:
160164
ephemeral-storage: 100M
161165
memory: 50Mi
162166
securityContext:
167+
seccompProfile:
168+
type: RuntimeDefault
163169
allowPrivilegeEscalation: false
164170
capabilities:
165171
add:

definitions/orderer/deployment.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ spec:
7272
ephemeral-storage: 100M
7373
memory: 100Mi
7474
securityContext:
75+
seccompProfile:
76+
type: RuntimeDefault
7577
allowPrivilegeEscalation: false
7678
capabilities:
7779
add:
@@ -165,6 +167,8 @@ spec:
165167
ephemeral-storage: 100M
166168
memory: 100Mi
167169
securityContext:
170+
seccompProfile:
171+
type: RuntimeDefault
168172
capabilities:
169173
add:
170174
- NET_BIND_SERVICE

definitions/peer/chaincode-launcher.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
name: "chaincode-launcher"
1919
imagePullPolicy: Always
2020
securityContext:
21+
seccompProfile:
22+
type: RuntimeDefault
2123
privileged: false
2224
readOnlyRootFileSystem: false
2325
runAsGroup: 7051

definitions/peer/couchdb.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ name: "couchdb"
1919
image: ""
2020
imagePullPolicy: Always
2121
securityContext:
22+
seccompProfile:
23+
type: RuntimeDefault
2224
privileged: false
2325
readOnlyRootFileSystem: false
2426
runAsGroup: 5984

definitions/peer/deployment.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ spec:
5959
cpu: 500m
6060
memory: 1000M
6161
securityContext:
62+
seccompProfile:
63+
type: RuntimeDefault
6264
allowPrivilegeEscalation: true
6365
capabilities:
6466
add:
@@ -136,6 +138,8 @@ spec:
136138
cpu: 200m
137139
memory: 400M
138140
securityContext:
141+
seccompProfile:
142+
type: RuntimeDefault
139143
allowPrivilegeEscalation: false
140144
capabilities:
141145
add:
@@ -218,6 +222,8 @@ spec:
218222
cpu: 100m
219223
memory: 200M
220224
securityContext:
225+
seccompProfile:
226+
type: RuntimeDefault
221227
allowPrivilegeEscalation: false
222228
capabilities:
223229
add:

pkg/offering/base/ca/override/deployment.go

+4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333
"github.com/IBM-Blockchain/fabric-operator/pkg/manager/resources/deployment"
3434
dep "github.com/IBM-Blockchain/fabric-operator/pkg/manager/resources/deployment"
3535
"github.com/IBM-Blockchain/fabric-operator/pkg/manager/resources/serviceaccount"
36+
"github.com/IBM-Blockchain/fabric-operator/pkg/offering/common"
3637
"github.com/IBM-Blockchain/fabric-operator/pkg/util"
3738

3839
appsv1 "k8s.io/api/apps/v1"
@@ -182,6 +183,9 @@ func (o *Override) CommonDeployment(instance *current.IBPCA, deployment *dep.Dep
182183
deployment.SetReplicas(instance.Spec.Replicas)
183184
}
184185

186+
// set seccompProfile to RuntimeDefault
187+
common.GetPodSecurityContext(caCont)
188+
185189
return nil
186190
}
187191

pkg/offering/base/console/override/deployment.go

+5
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,11 @@ func (o *Override) CommonDeployment(instance *current.IBPConsole, deployment *de
319319
}
320320
init.SetCommand([]string{"sh", "-c", initCommand})
321321

322+
// set seccompProfile to RuntimeDefault
323+
common.GetPodSecurityContext(console)
324+
common.GetPodSecurityContext(deployer)
325+
common.GetPodSecurityContext(configtxlator)
326+
322327
return nil
323328
}
324329

pkg/offering/base/orderer/override/deployment.go

+4
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,10 @@ func (o *Override) CommonDeploymentOverrides(instance *current.IBPOrderer, deplo
317317
deployment.UpdateContainer(grpcProxy)
318318
deployment.UpdateInitContainer(initCont)
319319

320+
// set seccompProfile to RuntimeDefault
321+
common.GetPodSecurityContext(orderer)
322+
common.GetPodSecurityContext(grpcProxy)
323+
320324
return nil
321325
}
322326

pkg/offering/base/peer/override/deployment.go

+5
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,11 @@ func (o *Override) CommonDeploymentOverrides(instance *current.IBPPeer, deployme
756756

757757
deployment.UpdateContainer(peerContainer)
758758
deployment.UpdateContainer(grpcContainer)
759+
760+
// set seccompProfile to RuntimeDefault
761+
common.GetPodSecurityContext(peerContainer)
762+
common.GetPodSecurityContext(grpcContainer)
763+
759764
return nil
760765
}
761766

pkg/offering/common/override.go

+10
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package common
2020

2121
import (
22+
container "github.com/IBM-Blockchain/fabric-operator/pkg/manager/resources/container"
2223
corev1 "k8s.io/api/core/v1"
2324
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2425
)
@@ -106,3 +107,12 @@ func GetPodAntiAffinity(orgName string) *corev1.PodAntiAffinity {
106107
},
107108
}
108109
}
110+
111+
func GetPodSecurityContext(con container.Container) {
112+
secContext := con.SecurityContext
113+
if secContext.SeccompProfile == nil {
114+
secContext.SeccompProfile = &corev1.SeccompProfile{
115+
Type: corev1.SeccompProfileTypeRuntimeDefault,
116+
}
117+
}
118+
}

0 commit comments

Comments
 (0)