apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app
spec:
  replicas: 1
  selector:
    matchLabels:
      app: my-app
  template:
    metadata:
      labels:
        app: my-app
    spec:
      terminationGracePeriodSeconds: 30
      containers:
      - name: main
        image: devopswithkubernetes/okeydokey:v0.0.4
        # readinessProbe:
        #   httpGet:
        #     path: /
        #     port: 5000
        #   periodSeconds: 8
        #   initialDelaySeconds: 10
        #   successThreshold: 2
        #   failureThreshold: 3
        #   timeoutSeconds: 1
        lifecycle:
          postStart:
            exec:
              command:
              - /bin/sh
              - -c
              - |
                echo "$(date +%s.%N) - [hook] postStart received." >> /var/log/hook.log
                sleep 30
                echo "$(date +%s.%N) - [hook] postStart ends." >> /var/log/hook.log
          preStop:
            exec:
              command:
              - /bin/sh
              - -c
              - |
                echo "$(date +%s.%N) - [hook] preStop received." >> /var/log/hook.log
                sleep 30
                echo "$(date +%s.%N) - preStop ends." >> /var/log/hook.log
