apiVersion: apps/v1  # 1
kind: Deployment          # 2
metadata:
  name: http-server-2
spec:
  replicas: 2
  selector:
    matchLabels:          # 3
      app: http-server-2
  template:
    metadata:
      namespace: custom-ns-1
      name: pod-http-server-2
      labels:
        app: http-server-2
    spec:
      containers:
      - image: jianglichn/node-http-server-2:20191031.1210
        name: http-server-2
        livenessProbe:
          httpGet:
            path: /
            port: 3001
        ports:
        - containerPort: 3001
          protocol: TCP
        
        startupProbe:             #  the app will have 2 * 10 = 20s to finish its startup, once the startup probe has succeeded once, the liveness probe takes over
          httpGet:
            path: /
            port: 3001
          failureThreshold: 2
          periodSeconds: 10
        livenessProbe:            # start working when startupProbe succeed. it is used to know if the container is alive, when there are errors in the request, the kubelet will kill and restart the container
          httpGet:
            path: /
            port: 3001
          periodSeconds: 30       # check every 30 seconds
          initialDelaySeconds: 30 # wait 30 seconds before the first check
        readinessProbe:           # readness is used to know when the container is ready to accept requests. 
          httpGet:
            path: /
            port: 3001
          periodSeconds: 10       # check every 10 seconds
