问题描述
我有一个.NET核心的Web应用程序.这已部署到Azure容器注册表.我使用
I have a .NET-core web application. This is deployed to an Azure Container Registry. I deploy this to my Azure Kubernetes Service using
带有下面的yaml文件
with the yaml-file below
apiVersion: apps/v1
kind: Deployment
metadata:
name: myweb
spec:
replicas: 1
selector:
matchLabels:
app: myweb
template:
metadata:
labels:
app: myweb
spec:
containers:
- name: myweb
image: mycontainerregistry.azurecr.io/myweb:latest
ports:
- containerPort: 80
imagePullSecrets:
- name: my-registry-key
这很出色,但是当我更改一些代码时,将新代码推送到容器中并运行
This works splendid, but when I change some code, push new code to container and run the
同样,直到我使用以下方式删除部署后,AKS/网站才会更新:
again, the AKS/website does not get updated, until I remove the deployment with
我应该怎么做才能使其覆盖已部署的内容?我想在yaml文件中添加一些内容. (我试图将其用于Azure DevOps中的连续交付).
What should I do to make it overwrite whatever is deployed? I would like to add something in my yaml-file. (Im trying to use this for continuous delivery in Azure DevOps).
推荐答案
我相信您正在寻找的是imagePullPolicy.默认值为ifNotPresent,这表示将不会提取最新版本.
I believe what you are looking for is imagePullPolicy. The default is ifNotPresent which means that the latest version will not be pulled.
https://kubernetes.io/docs/concepts/containers/images/
apiVersion: apps/v1
kind: Deployment
metadata:
name: myweb
spec:
replicas: 1
selector:
matchLabels:
app: myweb
template:
metadata:
labels:
app: myweb
spec:
containers:
- name: myweb
image: mycontainerregistry.azurecr.io/myweb
imagePullPolicy: Always
ports:
- containerPort: 80
imagePullSecrets:
- name: my-registry-key
要确保已重新创建Pod,请运行:
To ensure that the pod is recreated, rather run:
kubectl delete -f testdeployment && kubectl apply -f testdeployment
这篇关于如何使用kubernetes进行"kubectl应用"?不更新现有部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!