kubectl set image deployment/$DEPLOYMENT_EXTENSION $INSTANCE_NAME=gcr.io/$PROJECT_ID/$DOCKER_REPOSITORY:latest我使用这个命令将新创建的映像加载到我现有的集群中(更新我的应用程序的版本)。但当我这样做,然后去网站,我没有看到任何变化。
spec:
terminationGracePeriodSeconds: 30
containers:
- name: booknotes
image: gcr.io/my-image:latest
imagePullPolicy: Always我还在deployment.yaml文件中添加了这2行代码,并将其应用于cluser:
imagePullPolicy: Always
terminationGracePeriodSeconds: 30但还是没用。可能是因为我使用了:latest标签吗?还是没有关系?如果你有一些成语,请告诉我。此外,如果你需要更多的信息,我会附上它!
gitlab-ci.yml
stages:
- build
- docker-push
- deploy
cache:
paths:
- node_modules/
build:
stage: build
image: node:latest
script:
- yarn install
- npm run build
artifacts:
paths:
- dist/
only:
- master
docker:
stage: docker-push
image: docker:18.09.7
services:
- docker:18.09.7-dind
- google/cloud-sdk:latest
script:
- echo $GCP_ACCESS_JSON > $CI_PIPELINE_ID.json
- cat $CI_PIPELINE_ID.json | docker login -u _json_key --password-stdin $GCP_REGION
- docker build -t gcr.io/$PROJECT_ID/$DOCKER_REPOSITORY:latest .
- docker push gcr.io/$PROJECT_ID/$DOCKER_REPOSITORY:latest
only:
- master
test:
stage: deploy
image: google/cloud-sdk:latest
script:
- echo $GCP_ACCESS_JSON > $CI_PIPELINE_ID.json
- gcloud auth activate-service-account $GCP_CE_PROJECT_EMAIL --key-file $CI_PIPELINE_ID.json --project $GCP_PROJECT_ID
- gcloud container clusters get-credentials $CLUSTER_NAME --zone $ZONE --project $PROJECT_NAME
- kubectl set image deployment/$DEPLOYMENT_EXTENSION $INSTANCE_NAME=gcr.io/$PROJECT_ID/$DOCKER_REPOSITORY:latest
only:
- master发布于 2019-10-26 19:42:15
这个问题,症状和原因非常接近这个问题,(Google cloud platform creating a pipeline with Kubernetes and replacing the same container)
在Gitlab管道中应用相同的解决方案(使用全局变量更改图像标记,并每次部署新的解决方案以强制Kubernetes拉动和部署它)。
如果你有困难的话我可以帮你。
发布于 2019-10-26 19:03:47
你是对的,最新的标签不会触发你的吊舱的重新部署。相反,您可以设置映像,然后缩放部署。
kubectl set image deployment/alpine alpine=alpine:latest
kubectl scale deployment --replicas=0
kubectl scale deployment --replicas=1另一种选择是设置映像,然后修补注释或更改yaml字段。
https://stackoverflow.com/questions/58572171
复制相似问题