Skip to content

Instantly share code, notes, and snippets.

@antweiss
Created April 11, 2022 06:34
Show Gist options
  • Save antweiss/2992accce07677fb8b4a277191fd74e5 to your computer and use it in GitHub Desktop.
Save antweiss/2992accce07677fb8b4a277191fd74e5 to your computer and use it in GitHub Desktop.
apiVersion: v1
kind: Service
metadata:
name: nginx
namespace: orange
labels:
app: nginx
spec:
ports:
- port: 80
name: web
clusterIP: None
selector:
app: nginx
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: nginx
namespace: orange
spec:
replicas: 2
serviceName: nginx
selector:
matchLabels:
app: nginx
volumeClaimTemplates:
- metadata:
name: www
spec:
storageClassName: k3d
accessModes:
- ReadWriteMany
resources:
requests:
storage: 1Gi
template:
metadata:
labels:
app: nginx
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- nginx
topologyKey: kubernetes.io/hostname
initContainers:
- name: git
image: alpine/git
command: [ "sh", "-c", "[ -f /www/index.html ] || git clone https://github.com/octocat/Spoon-Knife /www" ]
volumeMounts:
- name: www
mountPath: /www/
containers:
- name: nginx
image: nginx
volumeMounts:
- name: www
mountPath: /usr/share/nginx/html/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment