apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: docker-registry
  labels:
    app: docker-registry
spec:
  serviceName: docker-registry
  replicas: 3
  selector:
    matchLabels:
     app: docker-registry
  template:
    metadata:
      labels:
        app: docker-registry
        tier: backend
    spec:
      containers:
      - name: docker-registry
        image: registry:2.6.2
        imagePullPolicy: IfNotPresent
        ports:
          - name: http
            containerPort: 5000
            protocol: TCP
        env:
        - name: WORDPRESS_DB_HOST
          value: wordpress-mysql
        - name: WORDPRESS_DB_PASSWORD
          value: changeme
        volumeMounts:
        - name: config
          mountPath: /etc/docker/registry
          readOnly: true
        - name: htpasswd
          mountPath: /auth
          readOnly: true
        - name: storage
          mountPath: /var/lib/registry
      volumes:
      - name: config
        configMap:
          name: docker-registry
          items:
            - key: registry-config.yml
              path: config.yml
      - name: htpasswd
        secret:
          secretName: docker-registry
          items:
            - key: HTPASSWD
              path: htpasswd
  volumeClaimTemplates:
  - metadata:
      name: storage
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 30Gi
