---
apiVersion: v1
kind: Service
metadata:
  name: docker-registry-service
  labels:
    run: docker-registry
spec:
  selector:
    app: docker-registry
  ports:
    - protocol: TCP
      port: 80
      name: http

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: docker-registry
  labels:
    app: docker-registry
spec:
  replicas: 1
  selector:
    matchLabels:
      app: docker-registry
  template:
    metadata:
      labels:
        app: docker-registry
    spec:
      containers:
      - name: docker-registry
        image: registry:2
        ports:
        - containerPort: 80
          protocol: TCP
        volumeMounts:
        - name: docker-registry-volume
          mountPath: /var/lib/registry
        env:
        - name: REGISTRY_HTTP_ADDR
          value: 0.0.0.0:80
        - name: REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY
          value: /var/lib/registry
      volumes:
      - name: docker-registry-volume
        persistentVolumeClaim:
          claimName: docker-registry-pvc
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: docker-ingress-route
  namespace: default
spec:
  entryPoints:
    - websecure
  routes:
  - match: (Host(`docker.dezendorf.net`)||Host(`dockerr.dezendorf.net`))
    kind: Rule
    services:
    - name: docker-registry-service
      port: 80
  tls:
    certResolver: myresolver
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: docker-web-route
  namespace: default
spec:
  entryPoints:
    - web
  routes:
  - match: (Host(`docker.dezendorf.net`)||Host(`dockerr.dezendorf.net`))
    kind: Rule
    middlewares:
    - name: redirecthttps
    services:
    - name: docker-registry-service
      port: 80
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: docker-registry-pvc
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: nfs
  resources:
    requests:
      storage: 100M
