kubernetes -- helm charts 开发: 4、 容器可以执行主机上的命令的方法

问题:一个容器需要能够执行主机上某些命令
解决办法:
容器内采用hostPath挂载,挂载的patch设定为主机上该命令的路径
大致代码结构如下:
 

...
      containers:
        - name: mycontainer
          image: ...
          imagePullPolicy: ...
          command:
            - ...
          volumeMounts:
            - name: kubectl
              mountPath: /usr/local/bin/kubectl
      volumes:
        - name: kubectl
          hostPath:
            path: /usr/local/bin/kubectl
...

猜你喜欢

转载自blog.csdn.net/qingyuanluofeng/article/details/85043636
今日推荐