apiVersion: v1 kind: Pod metadata: name: lifecycle-demo spec: containers: - name: demo-container image: nginx lifecycle: postStart: exec: command: ["/bin/sh", "-c", "echo 'Container started!' > /usr/share/nginx/html/index.html"] preStop: exec: command: ["/bin/sh", "-c", "echo 'Container stopping...' >> /usr/share/nginx/html/index.html && sleep 10"] terminationGracePeriodSeconds: 15