制作kubectl自定义镜像
Dockerfile
FROM alpine:3.15.0
COPY config /root/.kube/config
COPY kubectl /bin/
build:
/bin/cp -arf /usr/bin/kubectl .
/bin/cp -arf /root/.kube/config .
docker build -t kubectl:1.23.3-0.x86_64 .
test:
[root@node01 kubectl]# docker run --rm kubectl:1.23.3-0.x86_64 kubectl get nodes
NAME STATUS ROLES AGE VERSION
master Ready,SchedulingDisabled control-plane,master 147d v1.23.3
n1 Ready <none> 45d v1.23.1
node01 Ready <none> 147d v1.23.3
node02 Ready <none> 94d v1.23.3
You have mail in /var/spool/mail/root
用于Drone部署:
- name: deploy
image: kubectl:1.23.3-0.x86_64
commands:
- kubectl set image deployments testdp testct=testimg:${DRONE_BUILD_NUMBER} -n myns