docker - kubernetes 没有从 docker 应用新的服务更新
问题描述
我有一个节点 JS 应用程序,我正在部署到 kubernetes。
我已经对节点 JS 应用程序进行了更改,并将该应用程序重新部署到 K8s。
但是,我注意到部署没有通过。
我检查了我的 docker hub,是的,正在部署最新的图像。这是我下面的 service.yaml 文件
apiVersion: v1
kind: Service
metadata:
name: fourthapp
spec:
type: LoadBalancer #Exposes the service as a node port
ports:
- port: 3000
protocol: TCP
targetPort: 3000
selector:
app: webapp
这是我的 deploy.yaml 文件
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: fourthapp
spec:
replicas: 2
template:
metadata:
labels:
app: webapp
spec:
containers:
- name: webapp
image: index.docker.io/leexha/nodejsapp:latest
ports:
- containerPort: 3000
resources:
requests:
memory: 500Mi
cpu: 0.5
limits:
memory: 500Mi
cpu: 0.5
imagePullPolicy: Always
当我运行 service.yaml 它读取
C:\Users\adrlee\Desktop\oracle\Web_projects>kubectl apply -f service.yml
service "fourthapp" unchanged
有什么我做错了吗?
解决方案
If I understood the question you should update the Deployment instead. The service is just a kind of LB which dispatch traffic between your pods.
First, you should add imagePullPolicy: Always
to the deployment to force k8s to download the newest image.
If you want to update the deployment you can run
kubectl apply -f deploy.yml
or performing a Rolling Update
推荐阅读
- laravel - Laravel 缺少路由所需的参数:
- javascript - 导入第 3 方 javascript 资产
- jquery - 取消选择后如何使用 ASP RadioButtonList 回发 OnSelectedIndexChanged?
- angular - 如何包装 Angular 组件并将 ng-template 从外部组件传递到内部组件
- java - 在某些情况下从新线程获取响应
- android - 如何发送自定义标头或验证 Chromecast
- javascript - 我的 javascript 无法运行,文件链接不正确吗?
- java - Java OpenCV 在 inRange 之后将 HSV 转换回 BGR
- javascript - 屏幕阅读器 aria live 自信的文本被打断
- java - 模拟类返回 null 而不是数据