multiple command in postStart hook of a container

后端 未结 2 812
粉色の甜心
粉色の甜心 2021-02-02 08:20

in a kubernetes Deployment yaml file is there a simple way to run multiple commands in the postStart hook of a container?

I\'m trying to do something like this:

相关标签:
2条回答
  • 2021-02-02 09:16

    You also can create a bash or make script to group all those commands.

    0 讨论(0)
  • 2021-02-02 09:17

    Only one command allowed, but you can use sh -c like this

      lifecycle:
        postStart:
          exec:
            command:
              - "sh"
              - "-c"
              - >
                if [ -s /var/www/mybb/inc/config.php ]; then
                rm -rf /var/www/mybb/install;
                fi;
                if [ ! -f /var/www/mybb/index.php ]; then
                cp -rp /originroot/var/www/mybb/. /var/www/mybb/;
                fi
    
    0 讨论(0)
提交回复
热议问题