apiVersion: apps/v1
kind: Deployment
metadata:
  name: http-server-deployment
  namespace: http-server
  labels:
    app: http-server
spec:
  replicas: 3
  selector:
    matchLabels:
      app: http-server
  template:
    metadata:
      labels:
        app: http-server
    spec:
      containers:
      - name: http-server
        image: tonylixu/go_http_server:v1.10
        volumeMounts:
        - mountPath: /logs
          name: log-volume
        env:
        - name: HTTP_SERVER_PORT
          valueFrom:
            configMapKeyRef:
              name: http-server
              key: server_port
        - name: LOG_FILE
          valueFrom:
            configMapKeyRef:
              name: http-server
              key: log_file
        args: ["--port", "$(HTTP_SERVER_PORT)", "--log", "$(LOG_FILE)"]
        ports:
          - containerPort: 8080
        readinessProbe:
          httpGet:
            path: /healthz
            port: 8080
          initialDelaySeconds: 3
          periodSeconds: 3
        livenessProbe:
          exec:
            command:
            - cat
            - /tmp/live
          initialDelaySeconds: 3
          periodSeconds: 3
        startupProbe:
          httpGet:
            path: /healthz
            port: 8080
          # One minute startup finish
          failureThreshold: 6
          periodSeconds: 10
      volumes:
      - name: log-volume
        emptyDir: {}
