---
apiVersion: v1
data:
# AZURE_DOCKER_REGISTRY_CONFIG is base64 of this:
# {"auths":{"parity.azurecr.io":{"username":"parity","password":"<password>","email":"admin@parity.io","auth":"<base64 of user+passwoed>"}}}
  .dockerconfigjson: $AZURE_DOCKER_REGISTRY_CONFIG
kind: Secret
metadata:
  name: azure-docker-registry-key
type: kubernetes.io/dockerconfigjson
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: $CI_ENVIRONMENT_SLUG-backend
spec:
  replicas: $REPLICAS
  template:
    metadata:
      labels:
        app: $CI_ENVIRONMENT_SLUG
        component: backend
    spec:
      containers:
        - name: $CI_ENVIRONMENT_SLUG-backend
          image: $DOCKER_IMAGE_FULL_NAME
          imagePullPolicy: Always
          ports:
          - containerPort: 80
      imagePullSecrets:
        - name: azure-docker-registry-key
---
apiVersion: v1
kind: Service
metadata:
  name: $CI_ENVIRONMENT_SLUG-service
spec:
  selector:
    app: $CI_ENVIRONMENT_SLUG
  ports:
    - name: http
      port: 80
      targetPort: 80
      protocol: TCP
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: $CI_ENVIRONMENT_SLUG-ingress
  annotations:
    kubernetes.io/ingress.class: traefik
    traefik.frontend.entryPoints: "https,http"
spec:
  rules:
  - host: $AUTODEVOPS_HOST
    http:
      paths:
      - backend:
          serviceName: $CI_ENVIRONMENT_SLUG-service
          servicePort: 80
