apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello-service-deployment
  labels:
    app: hello-service
spec:
  replicas: 1
  selector:
    matchLabels:
      app: hello-service
  template:
    metadata:
      labels:
        app: hello-service
    spec:
      containers:
      - name: hello-service
        image: wkorando/hello-java-on-kube-101:11
        imagePullPolicy: Always
        ports:
        - containerPort: 8080
        env:
          - name: ENVIRONMENT_MESSAGE
            value: "Hello from ENVIRONMENT_MESSAGE!"
          - name: db-password
            valueFrom:
              secretKeyRef:
                name: datasource-connection-info
                key: password
          - name: my-secret-message
            valueFrom:
              secretKeyRef:
                name: datasource-connection-info
                key: my-secret
        args: ["--environment.message=$(ENVIRONMENT_MESSAGE)", "--spring.datasource.password=$(db-password)", "--my.secret.message=$(my-secret-message)"]
        volumeMounts:
        - name: h2-data
          mountPath: /volume-mount
        - name: application-properties
          mountPath: /application/config
        livenessProbe:
          httpGet:
            path: /actuator/health/liveness
            port: 8080
          initialDelaySeconds: 15
          periodSeconds: 3
          failureThreshold: 2
        readinessProbe:
          httpGet:
            path: /actuator/health/readiness
            port: 8080
          initialDelaySeconds: 15
          periodSeconds: 3
          failureThreshold: 1 
      terminationGracePeriodSeconds: 15
      volumes:
      - name: h2-data
        hostPath:
          type: DirectoryOrCreate
          path: /tmp
      - name: application-properties
        configMap:
          name: spring-config
          items:
          - key: application.properties 
            path: application.properties