栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

基于Rancher+K3S(K8S)环境导出Charts(需要helm)、docker镜像、POD的yaml

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

基于Rancher+K3S(K8S)环境导出Charts(需要helm)、docker镜像、POD的yaml

有时候我们需要从一个环境中,把当前的Helm-Charts、对应docker镜像文件,甚至有一些通过其他手段搞出来的POD的yaml导出来,然后在另一个环境中使用

这里面就是一些我们自己用到的工具,分享出来,自愿使用或修改。

有问题不负责 ^_^。

所有内容都在 https://github.com/wangxi83/migration_util


1- 导出镜像

File: ./save-images-to-tar/save-images.sh

Usage:

1) list your images
docker images | grep |awk '{printf("%s:%sn",$1,$2)}'  >> images.txt
docker images | grep |awk '{printf("%s:%sn",$1,$2)}'  >> images.txt
.... and more images 

2) save them to a single tar file
./save-images-to-tar/save-images.sh --image-list ./images.txt

a all-images.tar.gz file will craete. We can docker load from it

Fearther, you can use ‘./save-images-to-tar/load-images-registry.sh’ to upload images to a registry


2- helm-charts

File: ./getcharts.sh

Usage:

help ()
{
    echo  ' ================================================================ '
    echo  ' save charts listed in rancher Apps from helm-repo to dir charts-out-put '
    echo  ' --rancher-server: must,rancher server address'
    echo  ' --rancher-api-key: must。rancher apikey for Bearer Token'
    echo  ' --rancher-project-id:must。rancher project's id from browser address'
    echo  ' --harbor-server: must。harbor server address'
    echo  ' 使用示例:'
    echo  ' ./getcharts.sh --rancher-server=dbu.rancher.com --rancher-api-key=token-9zqtt:lj2j78jqjcqmgdx8n4kftn5j79rmq99j7hn548q8jc54shw9t8v2bm --rancher-project-id=c-bsv8l:p-rcv69  --harbor-server=harbor.sobey.com'
    echo  ' ================================================================'
}

after this, all charts will downloaded to dir ./charts-out-put


3- pod-yamls

File: ./getyaml.sh

Usage:

help ()
{
    echo  ' ================================================================ '
    echo  ' --kubectl:optional。the path to kubectl '
    echo  ' --type: must。k8s resourcetype,ex. pods。'
    echo  ' --ns:must。k8s namespace'
    echo  ' --kubeconfig:optional。Kubeconfig file'
    echo  ' --grep: optional。some grep workds '
    echo  ' 使用示例:'
    echo  ' ./getyaml.sh --type=pods --ns=sobeyficus '
    echo  ' ================================================================'
}

after this, all yamls will download to ./getyamlout. And then we can kubectl apply -f ./getyamlout to apply them to another cluster

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/830968.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号