multiple command in postStart hook of a container

后端 未结 2 813
粉色の甜心
粉色の甜心 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: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
    

提交回复
热议问题