除了创建,Deployment 提供的另一个重要的功能就是更新应用,这是一个比创建复杂很多的过程。想象一下在日常交付中,在线升级是一个很常见的需求,同时应该尽量保证不能因为升级中断服务。这就要求我们必须使用一定的策略来决定何时创建新的 Pod,何时删除旧版本的 Pod。kubectl 支持滚动升级的方式,每次更新一个pod,而不是同时删除整个服务。
前置知识
回顾知识:
kubectl set image
命令格式:
kubectl set image (-f FILENAME | TYPE NAME) CONTAINER_NAME_1=CONTAINER_IMAGE_1 ... CONTAINER_NAME_N=CONTAINER_IMAGE_N
例如:
Examples:
# Set a deployment's Nginx container image to 'Nginx:1.9.1', and its busyBox container image to 'busyBox'.
kubectl set image deployment/Nginx busyBox=busyBox Nginx=Nginx:1.9.1
# Update all deployments' and rc's Nginx container's image to 'Nginx:1.9.1'
kubectl set image deployments,rc Nginx=Nginx:1.9.1 --all
# Update image of all containers of daemonset abc to 'Nginx:1.9.1'
kubectl set image daemonset abc *=Nginx:1.9.1
# Print result (in yaml format) of updating Nginx container image from local file, without hitting the server
kubectl set image -f path/to/file.yaml Nginx=Nginx:1.9.1 --local -o yaml
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。