K8S回退configmap版本
时间: 2024-01-24 20:05:10 浏览: 197
要回退configmap版本,可以使用以下步骤:
1. 列出configmap的所有版本
```
kubectl get cm <configmap-name> -o=jsonpath='{.metadata.annotations.kubectl\.kubernetes\.io/last-applied-configuration}' | jq '.spec.template.spec.containers[].env[] | select(.valueFrom.configMapKeyRef.name == "<configmap-name>") | .valueFrom.configMapKeyRef.version'
```
2. 找到要回退到的版本号
根据需要回退到的版本号,选择要恢复的configmap版本。
3. 恢复configmap版本
使用以下命令来恢复configmap版本:
```
kubectl apply -f <configmap-file>.yaml --prune -l <configmap-label> --configmap-version=<version>
```
其中,`<configmap-file>.yaml`是configmap的yaml文件,`<configmap-label>`是configmap的标签,`<version>`是要恢复的版本号。
4. 验证configmap版本已回退
使用以下命令验证configmap版本已回退:
```
kubectl describe cm <configmap-name>
```
在输出中,应该看到`Annotations: kubectl.kubernetes.io/last-applied-configuration`的值应该与回退的版本号相同。
阅读全文
相关推荐











