apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: k8s.gcr.io/nginx-slim:0.8
        ports:
        - containerPort: 80
        lifecycle:
          postStart:
            exec:
              command: ["/bin/sh", "-c", "echo `hostname` `hostname -i` > /usr/share/nginx/html/index.html"]
          #preStop:
          #  exec:
          #    # SIGTERM triggers a quick exit; gracefully terminate instead
          #    command: ["sleep 10"]
