书籍来源:《CKA/CKAD应试指南:从Docker到Kubernetes完全攻略》
一边学习一边整理老师的课程内容及试验笔记,并与大家分享,侵权即删,谢谢支持!
附上汇总贴:CKA备考实验 | 汇总-CSDN博客
前面使用的是互联网的源,但是如果在私网里无法连接到互联网,要使用helm来部署应用程序的话,可以在私网内部搭建私有源。
步骤1:在vms12上用nginx镜像创建一个容器,名字为c1。
##########实操验证##########
[root@vms12 ~]# docker run -dit --name=c1 -p 8080:80 -v /data:/usr/share/nginx/html/charts docker.io/nginx
ba2a6a4a44b0bb4ca62b5f32f34e5100a815381a2b0c9c494dc91f305b1d0d3e
[root@vms12 ~]#
步骤2:在master上自定义一个chart。
##########实操验证##########
[root@vms10 ~]# mkdir mychar
[root@vms10 ~]#
[root@vms10 ~]# cd mychar/
[root@vms10 mychar]# helm create chart1
Creating chart1
[root@vms10 mychar]# cp -r /root/helm/mysql .
[root@vms10 mychar]#
[root@vms10 mychar]# ls
chart1 mysql
[root@vms10 mychar]#
步骤3:对这两个chart进行打包。
##########实操验证##########
[root@vms10 mychar]# helm package chart1
Successfully packaged chart and saved it to: /root/mychar/chart1-0.1.0.tgz
[root@vms10 mychar]#
[root@vms10 mychar]# helm package mysql/
Successfully packaged chart and saved it to: /root/mychar/mysql-1.6.8.tgz
[root@vms10 mychar]#
[root@vms10 mychar]# ls
chart1 chart1-0.1.0.tgz mysql mysql-1.6.8.tgz
[root@vms10 mychar]#
这里后缀为tgz的文件就是对chart进行打包生成的文件。
步骤4:给当前目录下的两个包建立索引文件,并指定私有仓库地址。
##########实操验证##########
[root@vms10 mychar]# helm repo index . --url http://192.168.1.112:8080/charts
[root@vms10 mychar]#
[root@vms10 mychar]# ls
chart1 chart1-0.1.0.tgz index.yaml mysql mysql-1.6.8.tgz
[root@vms10 mychar]#
可以看到这里多了一个索引文件index.yaml,里面记录了当前两个包的信息及所在仓库地址。
步骤5:把当前目录下index.yaml和后缀为tgz的包全部拷贝至192.168.26.12的/data目录里(请理解前面c1容器数据卷的设置)。
扫描二维码关注公众号,回复:
16841144 查看本文章
##########实操验证##########
[root@vms10 mychar]# scp index.yaml *.tgz 192.168.1.112:/data
[email protected]'s password:
index.yaml 100% 1192 1.4MB/s 00:00
chart1-0.1.0.tgz 100% 3573 1.8MB/s 00:00
mysql-1.6.8.tgz 100% 11KB 10.6MB/s 00:00
[root@vms10 mychar]#
步骤6:切换到vms12上。
##########实操验证##########
[root@vms12 ~]# ls /data
chart1-0.1.0.tgz index.yaml mysql-1.6.8.tgz
[root@vms12 ~]# docker exec -it c1 ls /usr/share/nginx/html/charts
chart1-0.1.0.tgz index.yaml mysql-1.6.8.tgz
[root@vms12 ~]#
步骤7:切换到master上,添加http://192.168.26.12:8080/charts作为仓库,仓库名为myrepo。
##########实操验证##########
[root@vms10 mychar]# helm repo add myrepo http://192.168.1.112:8080/charts
"myrepo" has been added to your repositories
[root@vms10 mychar]#
[root@vms10 mychar]# helm repo list
NAME URL
github https://burdenbear.github.io/kube-charts-mirror
stable https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
myrepo http://192.168.1.112:8080/charts
[root@vms10 mychar]#
步骤8:搜索mysql的chart。
##########实操验证##########
[root@vms10 mychar]# helm search repo mysql
NAME CHART VERSION APP VERSION DESCRIPTION
github/mysql 1.6.8 5.7.30 Fast, reliable, scalable, and easy to use open-...
github/mysqldump 2.6.2 2.4.1 DEPRECATED! - A Helm chart to help backup MySQL...
github/prometheus-mysql-exporter 0.7.1 v0.11.0 DEPRECATED A Helm chart for prometheus mysql ex...
myrepo/mysql 1.6.8 5.7.30 Fast, reliable, scalable, and easy to use open-...
stable/mysql 0.3.5 Fast, reliable, scalable, and easy to use open-...
github/percona 1.2.2 5.7.26 free, fully compatible, enhanced, open source d...
github/percona-xtradb-cluster 1.0.7 5.7.19 free, fully compatible, enhanced, open source d...
github/phpmyadmin 4.3.5 5.0.1 DEPRECATED phpMyAdmin is an mysql administratio...
stable/percona 0.3.0 free, fully compatible, enhanced, open source d...
stable/percona-xtradb-cluster 0.0.2 5.7.19 free, fully compatible, enhanced, open source d...
github/gcloud-sqlproxy 0.6.1 1.11 DEPRECATED Google Cloud SQL Proxy
github/mariadb 7.3.14 10.3.22 DEPRECATED Fast, reliable, scalable, and easy t...
stable/gcloud-sqlproxy 0.2.3 Google Cloud SQL Proxy
stable/mariadb 2.1.6 10.1.31 Fast, reliable, scalable, and easy to use open-...
[root@vms10 mychar]#
除了在github里可以找到mysql的仓库之外,在自定义的仓库里也能找到mysql。
步骤9:查询chart1。
##########实操验证##########
[root@vms10 mychar]# helm search repo chart1
NAME CHART VERSION APP VERSION DESCRIPTION
myrepo/chart1 0.1.0 1.16.0 A Helm chart for Kubernetes
[root@vms10 mychar]#
私有仓库配置完毕。
步骤10:删除本地私有仓库地址。
##########实操验证##########
[root@vms10 mychar]# helm repo remove myrepo
"myrepo" has been removed from your repositories
[root@vms10 mychar]#