Skip to content

Commit

Permalink
feat: added securityContext to container spec in edge and cloud workers
Browse files Browse the repository at this point in the history
  • Loading branch information
siredmar committed May 20, 2022
1 parent 1dd00f4 commit 9226239
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 64 deletions.
26 changes: 26 additions & 0 deletions cue/components/cloud-worker.cue
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ template: {
if parameter["readinessProbe"] != _|_ {
readinessProbe: parameter.readinessProbe
}

if parameter["securityContext"] != _|_ {
securityContext: parameter.securityContext
}

}

]
Expand Down Expand Up @@ -122,6 +127,27 @@ template: {
// +usage=Args to run for the command
args?: [...string]

// +usage=Specifies the SecurityContext of the container
securityContext?: {
allowPrivilegeEscalation?: bool
capabilities?: {
add?: [...string]
drop?: [...string]
}
privileged?: bool
// procMount currently ununsed
// procMount?: string
readOnlyRootFilesystem?: bool
runAsGroup?: int
runAsNonRoot?: bool
runAsUser?: int
// seLinuxOptions currently ununsed
// seLinuxOptions?: {...}
// seccompProfile currently ununsed
// seccompProfile?: {}
// windowsOptions never used
}

// +usage=Define arguments by using environment variables
env?: [...{
// +usage=Environment variable name
Expand Down
25 changes: 25 additions & 0 deletions cue/components/edge-worker.cue
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ template: {
if parameter["readinessProbe"] != _|_ {
readinessProbe: parameter.readinessProbe
}

if parameter["securityContext"] != _|_ {
securityContext: parameter.securityContext
}
}

]
Expand Down Expand Up @@ -132,6 +136,27 @@ template: {
// +usage=Args to run for the command
args?: [...string]

// +usage=Specifies the SecurityContext of the container
securityContext?: {
allowPrivilegeEscalation?: bool
capabilities?: {
add?: [...string]
drop?: [...string]
}
privileged?: bool
// procMount currently ununsed
// procMount?: string
readOnlyRootFilesystem?: bool
runAsGroup?: int
runAsNonRoot?: bool
runAsUser?: int
// seLinuxOptions currently ununsed
// seLinuxOptions?: {...}
// seccompProfile currently ununsed
// seccompProfile?: {}
// windowsOptions never used
}

// +usage=Define arguments by using environment variables
env?: [...{
// +usage=Environment variable name
Expand Down
64 changes: 0 additions & 64 deletions dev/manifests/applications/examples/edge-nats-box copy.yaml

This file was deleted.

11 changes: 11 additions & 0 deletions dev/manifests/applications/examples/edge-nats-box.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ spec:
type: edge-worker
properties:
image: natsio/nats-box:latest
imagePullSecrets:
- mysecret
name: nats-box
runtime:
- mydevice
Expand All @@ -19,6 +21,15 @@ spec:
- --
args:
- "while true; do sleep 1; done;"
securityContext:
privileged: false
capabilities:
add:
- CAP_SYS_RAWIO
- CAP_NET_ADMIN
drop:
- CAP_KILL

traits:
- type: edge-network-participant
properties:
Expand Down
26 changes: 26 additions & 0 deletions manifests/vela-caps/components/cloud-worker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ spec:
if parameter["readinessProbe"] != _|_ {
readinessProbe: parameter.readinessProbe
}
if parameter["securityContext"] != _|_ {
securityContext: parameter.securityContext
}
},
]
Expand Down Expand Up @@ -117,6 +122,27 @@ spec:
// +usage=Args to run for the command
args?: [...string]
// +usage=Specifies the SecurityContext of the container
securityContext?: {
allowPrivilegeEscalation?: bool
capabilities?: {
add?: [...string]
drop?: [...string]
}
privileged?: bool
// procMount currently ununsed
// procMount?: string
readOnlyRootFilesystem?: bool
runAsGroup?: int
runAsNonRoot?: bool
runAsUser?: int
// seLinuxOptions currently ununsed
// seLinuxOptions?: {...}
// seccompProfile currently ununsed
// seccompProfile?: {}
// windowsOptions never used
}
// +usage=Define arguments by using environment variables
env?: [...{
// +usage=Environment variable name
Expand Down
25 changes: 25 additions & 0 deletions manifests/vela-caps/components/edge-worker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ spec:
if parameter["readinessProbe"] != _|_ {
readinessProbe: parameter.readinessProbe
}
if parameter["securityContext"] != _|_ {
securityContext: parameter.securityContext
}
},
]
Expand Down Expand Up @@ -127,6 +131,27 @@ spec:
// +usage=Args to run for the command
args?: [...string]
// +usage=Specifies the SecurityContext of the container
securityContext?: {
allowPrivilegeEscalation?: bool
capabilities?: {
add?: [...string]
drop?: [...string]
}
privileged?: bool
// procMount currently ununsed
// procMount?: string
readOnlyRootFilesystem?: bool
runAsGroup?: int
runAsNonRoot?: bool
runAsUser?: int
// seLinuxOptions currently ununsed
// seLinuxOptions?: {...}
// seccompProfile currently ununsed
// seccompProfile?: {}
// windowsOptions never used
}
// +usage=Define arguments by using environment variables
env?: [...{
// +usage=Environment variable name
Expand Down

0 comments on commit 9226239

Please sign in to comment.