-
Notifications
You must be signed in to change notification settings - Fork 99
/
namespace-operator.yaml
249 lines (245 loc) · 7.87 KB
/
namespace-operator.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
apiVersion: v1
kind: Namespace
metadata:
name: seccomp-operator
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: seccomp-operator
namespace: seccomp-operator
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: config-map-reader
namespace: NS_REPLACE
rules:
- apiGroups: [""]
resources: ["configmaps"]
verbs: ["get", "watch", "list"]
- apiGroups: [""]
resources: ["events"]
verbs: ["create", "patch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: config-map-reader-binding
namespace: NS_REPLACE
subjects:
- kind: ServiceAccount
name: seccomp-operator
namespace: seccomp-operator
roleRef:
kind: Role
name: config-map-reader
apiGroup: rbac.authorization.k8s.io
---
apiVersion: v1
kind: ConfigMap
metadata:
name: seccomp-operator-profile
namespace: seccomp-operator
data:
seccomp-operator.json: |-
{
"defaultAction": "SCMP_ACT_ERRNO",
"architectures": [
"SCMP_ARCH_X86_64",
"SCMP_ARCH_X86",
"SCMP_ARCH_X32"
],
"syscalls": [
{
"names": [
"accept4",
"arch_prctl",
"bind",
"brk",
"clone",
"close",
"connect",
"epoll_create1",
"epoll_ctl",
"epoll_pwait",
"execve",
"exit",
"exit_group",
"fcntl",
"fstat",
"futex",
"getcwd",
"getgid",
"getpeername",
"getpgrp",
"getpid",
"getppid",
"getrandom",
"getsockname",
"getsockopt",
"gettid",
"getuid",
"listen",
"madvise",
"membarrier",
"mkdirat",
"mlock",
"mmap",
"mprotect",
"nanosleep",
"newfstatat",
"open",
"openat",
"pipe2",
"pread64",
"read",
"readlinkat",
"rt_sigaction",
"rt_sigprocmask",
"rt_sigreturn",
"sched_getaffinity",
"sched_yield",
"setgid",
"setsockopt",
"set_tid_address",
"setuid",
"sigaltstack",
"socket",
"tgkill",
"uname",
"write"
],
"action": "SCMP_ACT_ALLOW"
}
]
}
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: seccomp-operator
namespace: seccomp-operator
spec:
selector:
matchLabels:
name: seccomp-operator
template:
metadata:
annotations:
seccomp.security.alpha.kubernetes.io/pod: runtime/default
container.seccomp.security.alpha.kubernetes.io/seccomp-operator: localhost/seccomp-operator.json
labels:
name: seccomp-operator
spec:
serviceAccountName: seccomp-operator
initContainers:
- name: non-root-enabler
image: bash:5.0
# Creates folder /var/lib/seccomp-operator, sets 2000:2000 as its
# owner and symlink it to /var/lib/kubelet/seccomp/operator. This is
# required to allow the main container to run as non-root.
command: [bash, -c]
args:
- |+
set -euo pipefail
if [ ! -d $KUBELET_SECCOMP_ROOT ]; then
/bin/mkdir -m 0744 -p $KUBELET_SECCOMP_ROOT
fi
/bin/mkdir -p $OPERATOR_ROOT
/bin/chmod 0744 $OPERATOR_ROOT
if [ ! -L $OPERATOR_SYMLINK ]; then
/bin/ln -s $OPERATOR_ROOT $OPERATOR_SYMLINK
fi
/bin/chown -R 2000:2000 $OPERATOR_ROOT
cp -f -v /opt/seccomp-profiles/* $KUBELET_SECCOMP_ROOT
env:
- name: KUBELET_SECCOMP_ROOT
value: /var/lib/kubelet/seccomp
- name: OPERATOR_SYMLINK
value: $(KUBELET_SECCOMP_ROOT)/operator
- name: OPERATOR_ROOT
value: /var/lib/seccomp-operator
volumeMounts:
- name: host-varlib-volume
mountPath: /var/lib
- name: profile-configmap-volume
mountPath: /opt/seccomp-profiles
readOnly: true
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop: ["ALL"]
add: ["CHOWN", "FOWNER", "FSETID", "DAC_OVERRIDE"]
resources:
requests:
memory: "32Mi"
cpu: "100m"
ephemeral-storage: "10Mi"
limits:
memory: "64Mi"
cpu: "250m"
ephemeral-storage: "50Mi"
containers:
- name: seccomp-operator
image: gcr.io/k8s-staging-seccomp-operator/seccomp-operator:latest
imagePullPolicy: Always
volumeMounts:
- name: host-operator-volume
mountPath: /var/lib/kubelet/seccomp/operator
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsUser: 2000
runAsGroup: 2000
capabilities:
drop: ["ALL"]
resources:
requests:
memory: "64Mi"
cpu: "100m"
ephemeral-storage: "50Mi"
limits:
memory: "128Mi"
cpu: "300m"
ephemeral-storage: "200Mi"
env:
- name: RESTRICT_TO_NAMESPACE
value: NS_REPLACE
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
volumes:
# /var/lib is used as symlinks cannot be created across different volumes
- name: host-varlib-volume
hostPath:
path: /var/lib
type: Directory
- name: host-operator-volume
hostPath:
path: /var/lib/seccomp-operator
type: DirectoryOrCreate
- name: profile-configmap-volume
configMap:
name: seccomp-operator-profile
tolerations:
- effect: NoSchedule
key: node-role.kubernetes.io/master
- effect: NoExecute
key: node.kubernetes.io/not-ready
operator: Exists
nodeSelector:
kubernetes.io/os: linux
---
apiVersion: v1
kind: ConfigMap
metadata:
namespace: NS_REPLACE
name: default-profiles
annotations:
seccomp.security.kubernetes.io/profile: "true"
data:
nginx-1.19.1.json: |-
{"defaultAction":"SCMP_ACT_ERRNO","architectures":["SCMP_ARCH_X86_64","SCMP_ARCH_X86","SCMP_ARCH_X32"],"syscalls":[{"names":["accept4","access","arch_prctl","bind","brk","capget","capset","chdir","chown","clone","close","connect","dup2","epoll_create","epoll_ctl","epoll_pwait","epoll_wait","eventfd2","execve","exit","exit_group","faccessat","fadvise64","fchdir","fchown","fcntl","fgetxattr","fsetxattr","fstat","fstatfs","futex","getcwd","getdents","getdents64","getegid","geteuid","getgid","getpid","getppid","getrlimit","getuid","ioctl","io_setup","listen","lseek","mkdir","mmap","mprotect","munmap","nanosleep","newfstatat","open","openat","pipe","prctl","pread64","prlimit64","pwrite64","read","recvfrom","recvmsg","rename","rt_sigaction","rt_sigprocmask","rt_sigreturn","rt_sigsuspend","sched_getaffinity","seccomp","sendfile","sendmsg","setgid","setgroups","setitimer","set_robust_list","setsockopt","set_tid_address","setuid","sigaltstack","socket","socketpair","stat","statfs","sysinfo","umask","uname","unlink","utimensat","wait4","write","writev"],"action":"SCMP_ACT_ALLOW","args":[],"comment":"","includes":{},"excludes":{}}]}