Skip to content

Commit

Permalink
Disable unshare in the pod containers (#179)
Browse files Browse the repository at this point in the history
Signed-off-by: asararatnakar <[email protected]>
Signed-off-by: Shoaeb Jindani <[email protected]>
  • Loading branch information
asararatnakar authored and Shoaeb Jindani committed Mar 21, 2024
1 parent 6ebcc7e commit f612cb2
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1816,6 +1816,8 @@ spec:
ephemeral-storage: 100Mi
memory: 200Mi
securityContext:
seccompProfile:
type: RuntimeDefault
allowPrivilegeEscalation: false
capabilities:
add:
Expand Down
2 changes: 2 additions & 0 deletions config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ spec:
memory: 200Mi
ephemeral-storage: 100Mi
securityContext:
seccompProfile:
type: RuntimeDefault
allowPrivilegeEscalation: false
capabilities:
add:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1813,6 +1813,8 @@ spec:
ephemeral-storage: 100Mi
memory: 200Mi
securityContext:
seccompProfile:
type: RuntimeDefault
allowPrivilegeEscalation: false
capabilities:
add:
Expand Down
2 changes: 2 additions & 0 deletions definitions/ca/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ spec:
ephemeral-storage: 100M
memory: 100Mi
securityContext:
seccompProfile:
type: RuntimeDefault
allowPrivilegeEscalation: false
capabilities:
add:
Expand Down
6 changes: 6 additions & 0 deletions definitions/console/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ spec:
ephemeral-storage: 100M
memory: 1000Mi
securityContext:
seccompProfile:
type: RuntimeDefault
allowPrivilegeEscalation: false
capabilities:
add:
Expand Down Expand Up @@ -110,6 +112,8 @@ spec:
ephemeral-storage: 100M
memory: 200Mi
securityContext:
seccompProfile:
type: RuntimeDefault
allowPrivilegeEscalation: false
capabilities:
add:
Expand Down Expand Up @@ -160,6 +164,8 @@ spec:
ephemeral-storage: 100M
memory: 50Mi
securityContext:
seccompProfile:
type: RuntimeDefault
allowPrivilegeEscalation: false
capabilities:
add:
Expand Down
4 changes: 4 additions & 0 deletions definitions/orderer/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ spec:
ephemeral-storage: 100M
memory: 100Mi
securityContext:
seccompProfile:
type: RuntimeDefault
allowPrivilegeEscalation: false
capabilities:
add:
Expand Down Expand Up @@ -165,6 +167,8 @@ spec:
ephemeral-storage: 100M
memory: 100Mi
securityContext:
seccompProfile:
type: RuntimeDefault
capabilities:
add:
- NET_BIND_SERVICE
Expand Down
2 changes: 2 additions & 0 deletions definitions/peer/chaincode-launcher.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
name: "chaincode-launcher"
imagePullPolicy: Always
securityContext:
seccompProfile:
type: RuntimeDefault
privileged: false
readOnlyRootFileSystem: false
runAsGroup: 7051
Expand Down
2 changes: 2 additions & 0 deletions definitions/peer/couchdb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ name: "couchdb"
image: ""
imagePullPolicy: Always
securityContext:
seccompProfile:
type: RuntimeDefault
privileged: false
readOnlyRootFileSystem: false
runAsGroup: 5984
Expand Down
4 changes: 4 additions & 0 deletions pkg/offering/base/ca/override/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/IBM-Blockchain/fabric-operator/pkg/manager/resources/deployment"
dep "github.com/IBM-Blockchain/fabric-operator/pkg/manager/resources/deployment"
"github.com/IBM-Blockchain/fabric-operator/pkg/manager/resources/serviceaccount"
"github.com/IBM-Blockchain/fabric-operator/pkg/offering/common"
"github.com/IBM-Blockchain/fabric-operator/pkg/util"

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

// set seccompProfile to RuntimeDefault
common.GetPodSecurityContext(caCont)

return nil
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/offering/base/console/override/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,11 @@ func (o *Override) CommonDeployment(instance *current.IBPConsole, deployment *de
}
init.SetCommand([]string{"sh", "-c", initCommand})

// set seccompProfile to RuntimeDefault
common.GetPodSecurityContext(console)
common.GetPodSecurityContext(deployer)
common.GetPodSecurityContext(configtxlator)

return nil
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/offering/base/orderer/override/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,10 @@ func (o *Override) CommonDeploymentOverrides(instance *current.IBPOrderer, deplo
deployment.UpdateContainer(grpcProxy)
deployment.UpdateInitContainer(initCont)

// set seccompProfile to RuntimeDefault
common.GetPodSecurityContext(orderer)
common.GetPodSecurityContext(grpcProxy)

return nil
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/offering/base/peer/override/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,11 @@ func (o *Override) CommonDeploymentOverrides(instance *current.IBPPeer, deployme

deployment.UpdateContainer(peerContainer)
deployment.UpdateContainer(grpcContainer)

// set seccompProfile to RuntimeDefault
common.GetPodSecurityContext(peerContainer)
common.GetPodSecurityContext(grpcContainer)

return nil
}

Expand Down
10 changes: 10 additions & 0 deletions pkg/offering/common/override.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package common

import (
container "github.com/IBM-Blockchain/fabric-operator/pkg/manager/resources/container"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -106,3 +107,12 @@ func GetPodAntiAffinity(orgName string) *corev1.PodAntiAffinity {
},
}
}

func GetPodSecurityContext(con container.Container) {
secContext := con.SecurityContext
if secContext.SeccompProfile == nil {
secContext.SeccompProfile = &corev1.SeccompProfile{
Type: corev1.SeccompProfileTypeRuntimeDefault,
}
}
}

0 comments on commit f612cb2

Please sign in to comment.