-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(K8S): Support Restricted Constraints
- Loading branch information
1 parent
2e5138f
commit 69f5f63
Showing
7 changed files
with
193 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# K8S Restricted | ||
|
||
Under fully restricted there is a caveat: | ||
|
||
```log | ||
2024-12-28T02:36:44Z Wrong permissions on /run/chrony | ||
2024-12-28T02:36:44Z Disabled command socket /run/chrony/chronyd.sock | ||
``` | ||
|
||
To use chronyc, instead use: | ||
|
||
```bash | ||
/usr/bin/chronyc -h 127.0.0.1 -p 10323 sources | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: ntp-rootless | ||
namespace: ntp | ||
labels: | ||
app: ntp-rootless | ||
spec: | ||
replicas: 1 # 2 | ||
strategy: | ||
type: RollingUpdate | ||
revisionHistoryLimit: 0 | ||
selector: | ||
matchLabels: | ||
app: ntp-rootless | ||
template: | ||
metadata: | ||
labels: | ||
app: ntp-rootless | ||
spec: | ||
securityContext: | ||
seccompProfile: | ||
type: RuntimeDefault | ||
runAsNonRoot: true | ||
hostname: ntp-rootless | ||
restartPolicy: Always | ||
automountServiceAccountToken: false | ||
serviceAccountName: ntp | ||
# ndots required because of alpine base image | ||
dnsConfig: | ||
options: | ||
- name: ndots | ||
value: "1" | ||
containers: | ||
- image: "" | ||
imagePullPolicy: IfNotPresent | ||
name: ntp-rootless | ||
ports: | ||
- containerPort: 12345 | ||
name: ntp | ||
protocol: UDP | ||
securityContext: | ||
runAsUser: 1001 # Not Needed for OpenShift | ||
runAsGroup: 1001 # Not Needed for OpenShift | ||
privileged: false | ||
runAsNonRoot: true | ||
readOnlyRootFilesystem: true | ||
allowPrivilegeEscalation: false | ||
seccompProfile: | ||
type: RuntimeDefault | ||
capabilities: | ||
drop: | ||
- ALL | ||
resources: | ||
requests: | ||
ephemeral-storage: "15Mi" | ||
memory: "16Mi" | ||
cpu: "5m" | ||
limits: | ||
ephemeral-storage: "15Mi" | ||
memory: "32Mi" | ||
cpu: "50m" | ||
env: | ||
- name: SKIP_CHOWN | ||
value: "true" | ||
- name: PORT | ||
value: "12345" | ||
- name: CMDPORT | ||
value: "10323" | ||
- name: ENABLE_NTS | ||
value: "true" | ||
volumeMounts: | ||
- name: ntp-config | ||
mountPath: /etc/chrony/ | ||
- name: ntp-lib | ||
mountPath: /var/lib/chrony | ||
- name: ntp-run | ||
mountPath: /run/chrony | ||
- name: ntp-var-run | ||
mountPath: /var/run/chrony | ||
livenessProbe: | ||
exec: # /usr/bin/chronyc -h 127.0.0.1 -p 10323 sources | ||
command: | ||
- /usr/bin/chronyc | ||
- -h | ||
- 127.0.0.1 | ||
- -p | ||
- "10323" | ||
- sources | ||
initialDelaySeconds: 45 | ||
timeoutSeconds: 10 | ||
periodSeconds: 30 | ||
successThreshold: 1 | ||
failureThreshold: 5 | ||
readinessProbe: | ||
exec: # /usr/bin/chronyc -h 127.0.0.1 -p 10323 sources | ||
command: | ||
- /usr/bin/chronyc | ||
- -h | ||
- 127.0.0.1 | ||
- -p | ||
- "10323" | ||
- sources | ||
initialDelaySeconds: 45 | ||
timeoutSeconds: 10 | ||
periodSeconds: 30 | ||
successThreshold: 1 | ||
failureThreshold: 5 | ||
volumes: | ||
- name: ntp-config | ||
emptyDir: | ||
sizeLimit: 10Mi | ||
- name: ntp-lib | ||
emptyDir: | ||
sizeLimit: 10Mi | ||
- name: ntp-run | ||
emptyDir: | ||
sizeLimit: 10Mi | ||
- name: ntp-var-run | ||
emptyDir: | ||
sizeLimit: 10Mi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
labels: | ||
pod-security.kubernetes.io/enforce: restricted | ||
pod-security.kubernetes.io/enforce-version: latest | ||
pod-security.kubernetes.io/warn: restricted | ||
pod-security.kubernetes.io/warn-version: latest | ||
pod-security.kubernetes.io/audit: restricted | ||
pod-security.kubernetes.io/audit-version: latest | ||
app.kubernetes.io/instance: ntp | ||
kubernetes.io/metadata.name: ntp | ||
name: ntp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: ntp | ||
namespace: ntp | ||
labels: | ||
app: ntp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: ntp-rootless | ||
namespace: ntp | ||
spec: | ||
externalTrafficPolicy: Local | ||
internalTrafficPolicy: Cluster | ||
ports: | ||
- name: ntp | ||
port: 123 | ||
targetPort: ntp | ||
protocol: UDP | ||
selector: | ||
app: ntp-rootless | ||
type: LoadBalancer # ClusterIP | ||
loadBalancerClass: "" | ||
|