我正在尝试将 docker 映像部署到 kubernetes,但遇到了一个奇怪的问题。下面是我在 jenkinsfile 中使用的命令
stage('Deploy to k8s') {
steps{
sshagent(['kops-machine']) {
sh "scp -o StrictHostKeyChecking=no deployment.yml ubuntu@<ip>:/home/ubuntu/"
sh "ssh ubuntu@<ip> kubectl apply -f ."
sh 'kubectl set image deployment/nginx-deployment nginx=account/repo:${BUILD_NUMBER}'
}
}
我收到此错误消息
- kubectl set image deployment/nginx-deployment nginx=account/repo:69 错误:服务器没有资源类型“部署”
奇怪的是,如果我复制并粘贴此命令并在集群上执行,图像会更新 kubectl set image deployment/nginx-deployment nginx=account/repo:69 有人可以帮忙,图像构建并成功推送到 docker hub,它的只是我坚持拉和部署到 kubernetes 集群,如果您有任何其他选择,请告诉我,复制到服务器的 deployment.yml 文件如下
spec:
containers:
- name: nginx
image: account/repo:3
ports:
- containerPort: 80