apiVersion: apps/v1
kind: Deployment
metadata:
  name: vote
  namespace: voting-app-prd
spec:
  replicas: 1
  selector:
    matchLabels:
      name: vote
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        name: vote
    spec:
      affinity:
        podAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: name
                operator: In
                values:
                - redis
            topologyKey: "kubernetes.io/hostname"
      containers:
        - env:
            - name: "REDIS_SERVICE_NAME"
              valueFrom:
                configMapKeyRef:
                  name: redis
                  key: database-name
            - name: "PORT"
              value: "8080"
            - name: "OPTION_A"
              valueFrom:
                configMapKeyRef:
                  name: vote
                  key: option_a
            - name: "OPTION_B"
              valueFrom:
                configMapKeyRef:
                  name: vote
                  key: option_b
          image: wikitops/examplevotingapp-vote:1.0
          imagePullPolicy: IfNotPresent
          livenessProbe:
            httpGet:
              path: /
              port: vote
            initialDelaySeconds: 3
            periodSeconds: 3
          name: vote
          ports:
            - containerPort: 8080
              name: vote
              protocol: TCP
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
