Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save daemonfire300/50994f844c04ee3289ccf777da4355ff to your computer and use it in GitHub Desktop.

Select an option

Save daemonfire300/50994f844c04ee3289ccf777da4355ff to your computer and use it in GitHub Desktop.
example.yaml
# Dev container StatefulSet.
#
# Usage: kubectl exec -it devcontainer-0 -- zsh -l
#
# - runs unprivileged as me:me (1000:1000), readOnlyRootFilesystem
# - /home/me is a PVC (repos, shell history, caches, all mutable state)
# - /tmp is an emptyDir
# - storageClassName is intentionally unset: uses the cluster default
# (kind: local-path). Set it explicitly for your production cluster.
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: devcontainer
labels:
app: devcontainer
spec:
serviceName: devcontainer
replicas: 1
selector:
matchLabels:
app: devcontainer
template:
metadata:
labels:
app: devcontainer
spec:
securityContext:
runAsNonRoot: true
runAsUser: 1000
runAsGroup: 1000
fsGroup: 1000
fsGroupChangePolicy: OnRootMismatch
seccompProfile:
type: RuntimeDefault
containers:
- name: devcontainer
image: devcontainer:dev
imagePullPolicy: IfNotPresent
securityContext:
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
volumeMounts:
- name: home
mountPath: /home/me
- name: tmp
mountPath: /tmp
resources:
requests:
cpu: 500m
memory: 1Gi
volumes:
- name: tmp
emptyDir: {}
volumeClaimTemplates:
- metadata:
name: home
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment