apiVersion: apps/v1
kind: Deployment
metadata:
  name: spring3hibernate
  namespace: t0
  labels:
    app: spring3hibernate
    version: "1.0"
    environment: testing
spec:
  replicas: 2
  selector:
    matchLabels:
      app: spring3hibernate
      version: "1.0"
      environment: testing
  template:
    metadata:
      labels:
        app: spring3hibernate
        version: "1.0"
        environment: testing
    spec:
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: app
                operator: In
                values:
                - spring3hibernate
            topologyKey: kubernetes.io/hostname
      terminationGracePeriodSeconds: 60
      containers:
      - name: spring3hibernate
        image: singhjaspreet291/spring3hibernate:latest
        env:
        - name: MYSQL_DB_HOST
          value: "jdbc:mysql://mysql-service"
        - name: MYSQL_DB_PORT
          value: "3306"
        - name: MYSQL_DB_USERNAME
          valueFrom:
            secretKeyRef:
              name: spring-secrets
              key: mysqluser
        - name: MYSQL_DB_PASSWORD
          valueFrom:
            secretKeyRef:
              name: spring-secrets
              key: mysqlpass
        ports:
        - containerPort: 8080
        readinessProbe:
          tcpSocket:
            port: 8080
          initialDelaySeconds: 5
          periodSeconds: 10
          timeoutSeconds: 2
          failureThreshold: 1
          successThreshold: 1
        livenessProbe:
          tcpSocket:
            port: 8080
          initialDelaySeconds: 15
          periodSeconds: 20
          timeoutSeconds: 2
          failureThreshold: 1
          successThreshold: 1
      imagePullSecrets:
        - name: dockerhub
