apiVersion: apps/v1
kind: Deployment
metadata:
  name: result
  namespace: voting-app-prd
spec:
  replicas: 1
  selector:
    matchLabels:
      name: result
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        name: result
    spec:
      affinity:
        podAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: name
                operator: In
                values:
                - db
            topologyKey: "kubernetes.io/hostname"
      containers:
        - env:
            - name: "DB_SERVICE_NAME"
              value: "db"
            - name: "DB_NAME"
              valueFrom:
                configMapKeyRef:
                  key: database-name
                  name: db
            - name: "DB_USERNAME"
              valueFrom:
                secretKeyRef:
                  key: database-user
                  name: db
            - name: "DB_PASSWORD"
              valueFrom:
                secretKeyRef:
                  key: database-password
                  name: db
            - name: "PORT"
              value: "8080"
          image: wikitops/examplevotingapp-result:1.0
          imagePullPolicy: IfNotPresent
          livenessProbe:
            httpGet:
              path: /
              port: result
            initialDelaySeconds: 3
            periodSeconds: 3
          name: result
          ports:
            - name: result
              containerPort: 8080
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
