Kubernetes提供了简单的工具,用于推出和回滚对Deployments和Daemonsets的更改。但是,部署通常与其他kubernetes原语(如Secrets或Services)紧密关联,我想知道如何对它们执行相同的操作,因为它们也会直接影响app / cluster的运行状态。
例如,如果我更改服务中的某些端口或更改基于Secrets的环境变量(然后重新启动我的pod),我可能会破坏某些内容并希望将配置回滚到以前的版本。
我怎样才能最轻松地做到这一点?
答案 0 :(得分:2)
您描述的功能不在Kubernetes API中。
我建议您查看Helm哪个是Kubernetes应用程序管理器。 Helm允许您升级或回滚与您的应用程序关联的所有资源。
您可以找到Helm包here的示例
要安装此软件包及其所有Kubernetes资源,您可以使用helm install nginx --name my-nginx
这允许您升级包helm upgrade my-nginx nginx
并使用0
版本helm rollback my-nginx 0
回滚到以前的版本。
当您更改密码或配置图时,可以通过adding an annotation to your pods that is based on the state of your configmap执行您的广告连续滚动升级。
例如:
kind: Deployment
spec:
template:
metadata:
annotations:
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}