use post install for pod in k8s

1/19/2020

in the docs there is an option of using postStart hook, however we have some long script that we want to run, how we can do it ? I mean to provide the script and provide the path to run it ... instead of running it inline ...

apiVersion: v1
kind: Pod
metadata:
  name: lifecycle-demo
spec:
  containers:
  - name: lifecycle-demo-container
    image: nginx
    lifecycle:
      postStart:
        exec:
          command: ["/bin/sh", "-c", "echo Hello from the postStart handler > /usr/share/message"]
-- Jenny M
azure
kubernetes

1 Answer

1/19/2020

You just need to mention the path of the script, refer this answer

lifecycle:
      postStart:
        exec:
          command: ["/bin/sh", "-c", /opt/poststart.sh ]
-- Sajeetharan
Source: StackOverflow