一:k8s如何获取历史版本的image tag:
注释:不使用–record的情景
第二种情况根据所有镜像版本的时间进行排序
1.通过阿里云的接口:aliyun cr GetRepoTags --RepoNamespace youximao-online --RepoName base |jq ".data.tags[].tag"|grep online|head -n4
2.通过rs: kubectl get rs -n yxm-online -l app=sdk-server,version=v3 --sort-by=.metadata.creationTimestamp -o wide|tail -n2|head -n1|awk '{print $(NF-1)}'
3.release文件:docker.tag=xxxxx
4.通过json:kubectl get deployments -n 命名空间 服务 -o jsonpath="{..image}" |tr -s '[[:space:]]' '\n' |sort
1:源站:https://blog.csdn.net/qq_50119948/article/details/116712337?spm=1001.2014.3001.5501
2:源站:https://blog.csdn.net/qq_50119948/article/details/117063566?spm=1001.2014.3001.5501
二:如何修改镜像
第一种方法:
kubectl -n (命名空间) set image deployment(资源类型) 资源的名字 容器名=镜像版本
eg:kubectl -n yxm-dev set image deployment base base=nginx:1.13
第二种方法:
kubectl get deployments -n yxm-dev -o yaml > deploy.yaml
sed -i 修改image
"sed -i '54c \ image: 仓库:latest' deploy.yaml" -b
"kubectl apply -f deploy.yaml" -b
第三种方法:
阿里云k8s集群中:找到历史版本对应的tag,然后在无状态找到服务选择镜像版本