apiVersion: apps/v1
kind: Deployment
metadata:
  name: java2days-ratings-backend
  namespace: java2days
spec:
  replicas: 2
  selector:
    matchLabels:
      app: java2days-ratings-backend
  template:
    metadata:
      labels:
        app: java2days-ratings-backend
      annotations:
        balev.eu/author: "Lachezar Balev, Georgi Peychev"
    spec:
      containers:
        - name: java2days-ratings-backend
          image: luchob/ratings-service:v1
          imagePullPolicy: Always
          ports:
            - containerPort: 8080
              name: server-port
          livenessProbe:
            httpGet:
              path: /admin/healthcheck
              port: 8080
            initialDelaySeconds: 25
            periodSeconds: 30
            timeoutSeconds: 3
          readinessProbe:
            httpGet:
              path: /admin/healthcheck
              port: 8080
            initialDelaySeconds: 25
            periodSeconds: 30
            timeoutSeconds: 3
          env:
            - name: MYSQL_HOST
              valueFrom:
                configMapKeyRef:
                  name: java2days-ratings-config
                  key: mysql.host
            - name: MYSQL_PORT
              valueFrom:
                configMapKeyRef:
                  name: java2days-ratings-config
                  key: mysql.port
            - name: MYSQL_USER
              valueFrom:
                configMapKeyRef:
                  name: java2days-ratings-config
                  key: mysql.user
            - name: MYSQL_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: java2days-mysql-credentials
                  key: password
