Skip to content

Commit 2bbfd8f

Browse files
authored
Merge pull request #62471 from GroceryBoyJr/namespace
2 parents fd07e80 + 59db7bc commit 2bbfd8f

File tree

4 files changed

+72
-17
lines changed

4 files changed

+72
-17
lines changed

modules/spo-applying-profiles.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ $ oc -n my-namespace get seccompprofile profile1 --output wide
5555
.Example output
5656
[source,terminal]
5757
----
58-
NAME STATUS AGE SECCOMPPROFILE.LOCALHOSTPROFILE
59-
profile1 Active 14s operator/my-namespace/profile1.json
58+
NAME STATUS AGE SECCOMPPROFILE.LOCALHOSTPROFILE
59+
profile1 Installed 14s operator/my-namespace/profile1.json
6060
----
6161

6262
. View the path to the localhost profile by running the following command:
@@ -144,7 +144,7 @@ $ oc get selinuxprofile.security-profiles-operator.x-k8s.io/nginx-secure -n ngin
144144
.Example output
145145
[source,terminal]
146146
----
147-
nginx-secure_nginx-deploy.process%
147+
nginx-secure_nginx-deploy.process
148148
----
149149

150150
. Apply the output string in the workload manifest in the `.spec.containers[].securityContext.seLinuxOptions` attribute:

modules/spo-container-profile-instances.adoc

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
//
33
// * security/security_profiles_operator/spo-seccomp.adoc
44
// * security/security_profiles_operator/spo-selinux.adoc
5+
// JKB added conditionalization requested by QE
6+
57

68
ifeval::["{context}" == "spo-seccomp"]
79
:seccomp:
@@ -34,6 +36,7 @@ metadata:
3436
# The name of the Recording is the same as the resulting {kind} CRD
3537
# after reconciliation.
3638
name: test-recording
39+
namespace: my-namespace
3740
spec:
3841
kind: {kind}
3942
recorder: logs
@@ -43,14 +46,21 @@ spec:
4346
app: sp-record
4447
----
4548

46-
. Create the workload:
49+
. Label the namespace by running the following command:
50+
+
51+
[source,terminal]
52+
----
53+
$ oc label ns my-namespace security.openshift.io/scc.podSecurityLabelSync=false pod-security.kubernetes.io/enforce=privileged pod-security.kubernetes.io/audit=privileged pod-security.kubernetes.io/warn=privileged --overwrite=true
54+
----
55+
. Create the workload with the following YAML:
4756
+
4857
[source,yaml]
4958
----
5059
apiVersion: apps/v1
5160
kind: Deployment
5261
metadata:
5362
name: nginx-deploy
63+
namespace: my-namespace
5464
spec:
5565
replicas: 3
5666
selector:
@@ -73,30 +83,40 @@ spec:
7383
+
7484
[source,terminal]
7585
----
76-
$ oc delete deployment nginx-deploy
86+
$ oc delete deployment nginx-deploy -n my-namespace
7787
----
7888

7989
. To merge the profiles, delete the profile recording by running the following command:
8090
+
8191
[source,terminal]
8292
----
83-
$ oc delete profilerecording test-recording
93+
$ oc delete profilerecording test-recording -n my-namespace
8494
----
8595

8696
. To start the merge operation and generate the results profile, run the following command:
8797
+
8898
[source,terminal,subs="attributes+"]
8999
----
90-
$ oc get {object} -lspo.x-k8s.io/recording-id=test-recording
100+
$ oc get {object} -lspo.x-k8s.io/recording-id=test-recording -n my-namespace
91101
----
102+
ifdef::selinux[]
92103
+
93-
.Example output
104+
.Example output for {object}
94105
[source,terminal]
95106
----
96-
NAME USAGE STATE
97-
test-recording-nginx-record test-recording-nginx-record_mytest1.process Installed
107+
NAME USAGE STATE
108+
test-recording-nginx-record test-recording-nginx-record_my-namespace.process Installed
98109
----
99-
110+
endif::[]
111+
ifdef::seccomp[]
112+
+
113+
.Example output for {object}
114+
[source,terminal]
115+
----
116+
NAME STATUS AGE
117+
test-recording-nginx-record Installed 55s
118+
----
119+
endif::[]
100120
. To view the permissions used by any of the containers, run the following command:
101121
+
102122
[source,terminal,subs="attributes+"]

modules/spo-creating-profiles.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ The {type} profile will be saved in `/var/lib/kubelet/{type}/operator/<namespace
4343

4444
An `init` container creates the root directory of the Security Profiles Operator to run the Operator without `root` group or user ID privileges. A symbolic link is created from the rootless profile storage `/var/lib/openshift-security-profiles` to the default `seccomp` root path inside of the kubelet root `/var/lib/kubelet/{type}/operator`.
4545
endif::[]
46+
4647
ifdef::selinux[]
4748
The `{kind}` object has several features that allow for better security hardening and readability:
4849

modules/spo-recording-profiles.adoc

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ $ oc label ns my-namespace spo.x-k8s.io/enable-recording=true
4646
apiVersion: security-profiles-operator.x-k8s.io/v1alpha1
4747
kind: ProfileRecording
4848
metadata:
49+
namespace: my-namespace
4950
name: test-recording
5051
spec:
5152
kind: {kind}
@@ -62,6 +63,7 @@ spec:
6263
apiVersion: v1
6364
kind: Pod
6465
metadata:
66+
namespace: my-namespace
6567
name: my-pod
6668
labels:
6769
app: my-app
@@ -79,7 +81,7 @@ spec:
7981
+
8082
[source,terminal]
8183
----
82-
$ oc -n openshift-security-profiles get pods
84+
$ oc -n my-namespace get pods
8385
----
8486
+
8587
.Example output
@@ -95,36 +97,68 @@ my-pod 2/2 Running 0 18s
9597
----
9698
$ oc -n openshift-security-profiles logs --since=1m --selector name=spod -c log-enricher
9799
----
100+
101+
ifdef::seccomp[]
102+
+
103+
.Example output
104+
[source,terminal]
105+
----
106+
I0523 14:19:08.747313 430694 enricher.go:445] log-enricher "msg"="audit" "container"="redis" "executable"="/usr/local/bin/redis-server" "namespace"="my-namespace" "node"="xiyuan-23-5g2q9-worker-eastus2-6rpgf" "pid"=656802 "pod"="my-pod" "syscallID"=0 "syscallName"="read" "timestamp"="1684851548.745:207179" "type"="seccomp"
107+
----
108+
endif::[]
109+
110+
ifdef::selinux[]
98111
+
99112
.Example output
100113
[source,terminal,subs="attributes+"]
101114
----
102-
I0517 13:55:36.383187 348295 enricher.go:376] log-enricher "msg"="audit" "container"="redis" "namespace"="my-namespace" "node"="ip-10-0-189-53.us-east-2.compute.internal" "perm"="name_bind" "pod"="my-pod" "profile"="test-recording_redis_6kmrb_1684331729" "scontext"="system_u:system_r:selinuxrecording.process:s0:c4,c27" "tclass"="tcp_socket" "tcontext"="system_u:object_r:redis_port_t:s0" "timestamp"="1684331735.105:273965" "type"="{type}"
115+
I0517 13:55:36.383187 348295 enricher.go:376] log-enricher "msg"="audit" "container"="redis" "namespace"="my-namespace" "node"="ip-10-0-189-53.us-east-2.compute.internal" "perm"="name_bind" "pod"="my-pod" "profile"="test-recording_redis_6kmrb_1684331729" "scontext"="system_u:system_r:selinuxrecording.process:s0:c4,c27" "tclass"="tcp_socket" "tcontext"="system_u:object_r:redis_port_t:s0" "timestamp"="1684331735.105:273965" "type"="selinux"
103116
----
117+
endif::[]
118+
104119

105120
.Verification
106121

107122
. Remove the pod:
108123
+
109124
[source,terminal]
110125
----
111-
$ oc -n openshift-security-profiles delete pod my-pod
126+
$ oc -n my-namepace delete pod my-pod
112127
----
113128

114129
. Confirm the Security Profiles Operator reconciles the two {type} profiles:
130+
131+
ifdef::seccomp[]
115132
+
116-
[source,terminal,subs="attributes+"]
133+
[source,terminal]
117134
----
118-
$ oc get {object} -n my-namespace
135+
$ oc get seccompprofiles -lspo.x-k8s.io/recording-id=test-recording -n my-namespace
119136
----
120137
+
121-
.Example output
138+
.Example output for seccompprofile
139+
[source,terminal]
140+
----
141+
NAME STATUS AGE
142+
test-recording-nginx Installed 2m48s
143+
test-recording-redis Installed 2m48s
144+
----
145+
endif::[]
146+
147+
ifdef::selinux[]
148+
+
149+
[source,terminal]
150+
----
151+
$ oc get selinuxprofiles -lspo.x-k8s.io/recording-id=test-recording -n my-namespace
152+
----
153+
+
154+
.Example output for selinuxprofile
122155
[source,terminal]
123156
----
124157
NAME USAGE STATE
125158
test-recording-nginx test-recording-nginx_my-namespace.process Installed
126159
test-recording-redis test-recording-redis_my-namespace.process Installed
127160
----
161+
endif::[]
128162

129163
ifeval::["{context}" == "spo-seccomp"]
130164
:!seccomp:

0 commit comments

Comments
 (0)