Advertisement
wagz

Statefulset example

Dec 17th, 2019
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 0.99 KB | None | 0 0
  1. apiVersion: v1
  2. kind: Service
  3. metadata:
  4.   name: nginx
  5.   labels:
  6.     app: nginx
  7. spec:
  8.   ports:
  9.   - port: 80
  10.     name: web
  11.   clusterIP: None
  12.   selector:
  13.     app: nginx
  14. ---
  15. apiVersion: apps/v1
  16. kind: StatefulSet
  17. metadata:
  18.   name: web
  19. spec:
  20.   selector:
  21.     matchLabels:
  22.       app: nginx # has to match .spec.template.metadata.labels
  23.   serviceName: "nginx"
  24.   replicas: 3 # by default is 1
  25.   template:
  26.     metadata:
  27.       labels:
  28.         app: nginx # has to match .spec.selector.matchLabels
  29.     spec:
  30.       terminationGracePeriodSeconds: 10
  31.       containers:
  32.       - name: nginx
  33.         image: gcr.io/google_containers/nginx-slim:0.8
  34.         ports:
  35.         - containerPort: 80
  36.           name: web
  37.         volumeMounts:
  38.         - name: www
  39.           mountPath: /usr/share/nginx/html
  40.   volumeClaimTemplates:
  41.   - metadata:
  42.       name: www
  43.     spec:
  44.       accessModes: [ "ReadWriteOnce" ]
  45.       storageClassName: default
  46.       resources:
  47.         requests:
  48.           storage: 1Gi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement