Skip to content

Instantly share code, notes, and snippets.

@edib
Created January 25, 2022 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edib/7f9a01031c6e6f48fa5518aea18050c8 to your computer and use it in GitHub Desktop.
Save edib/7f9a01031c6e6f48fa5518aea18050c8 to your computer and use it in GitHub Desktop.
apiVersion: v1
kind: Pod
metadata:
name: example
spec:
containers:
- image: busybox
command: [ "sh", "-c", "sleep 84000s" ]
name: examplepod
env:
- name: NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
volumeMounts:
- mountPath: /var/log/kokdemir
name: hostpath
subPathExpr: $(NAME)
securityContext:
runAsUser: 1001
runAsGroup: 1001
runAsNonRoot: true
allowPrivilegeEscalation: false
capabilities:
drop:
- all
initContainers:
- name: volume-mount-permission
env:
- name: NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.name
image: busybox
command: ["sh", "-c"]
args: ["chown -R 1001:1001 /var/log/kokdemir/$(NAME)"]
volumeMounts:
- mountPath: /var/log/kokdemir
name: hostpath
subPathExpr: $(NAME)
readOnly: false
securityContext:
runAsUser: 0
allowPrivilegeEscalation: true
volumes:
- name: hostpath
hostPath:
path: /var/log/kokdemir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment