第154天学习打卡(Kubernetes 使用Helm快速部署应用, 如何自己创建Chart) (2)

修改service的yaml文件,type改为NodePort,使其对外暴露端口

 [root@master linux-amd64]# kubectl edit svc ui3-weave-scope
 service/ui3-weave-scope edited
 [root@master linux-amd64]# kubectl get svc
 NAME             TYPE       CLUSTER-IP       EXTERNAL-IP   PORT(S)       AGE
 kubernetes       ClusterIP   10.96.0.1       <none>        443/TCP       5d19h
 ui3-weave-scope   NodePort    10.103.97.141   <none>        80:31674/TCP   15m
 web               NodePort    10.111.111.127   <none>        80:32079/TCP   19h
 [root@master linux-amd64]#
 

image-20210611162755019

image-20210611163519276

如何自己创建Chart

1.使用命令创建chart

 helm create chart名称  [root@master linux-amd64]# cd ..
 [root@master ~]# helm create mychart
 Creating mychart
 [root@master ~]# ls
 10-flannel.conflist cronjob.yaml                   ingress01.yaml           mary                   recommended.yaml service1.yaml
 10-kubeadm.conf     deploy.yaml                     ingress-controller.yaml mychart               redis.properties sts.yaml
 admin.conf           deploy.yaml.1                   job.yaml                 myconfig.yaml         secret-var.yaml
 cm.yaml             ds.yaml                         kube-flannel.yml         rbac-rolebinding.yaml secret-vol.yaml
 config-var.yaml     helm-v3.6.0-linux-amd64.tar.gz linux-amd64             rbac-role.yaml         secret.yaml
 [root@master ~]# cd mychart
 [root@master mychart]# ls
 charts Chart.yaml templates values.yaml
 [root@master mychart]# ls charts/
 [root@master mychart]# cd charts/
 [root@master charts]# cd ..
 [root@master mychart]# cat Chart.yaml #查看信息
 apiVersion: v2
 name: mychart
 description: A Helm chart for Kubernetes
 
 # A chart can be either an \'application\' or a \'library\' chart.
 #
 # Application charts are a collection of templates that can be packaged into versioned archives
 # to be deployed.
 #
 # Library charts provide useful utilities or functions for the chart developer. They\'re included as
 # a dependency of application charts to inject those utilities and functions into the rendering
 # pipeline. Library charts do not define any templates and therefore cannot be deployed.
 type: application
 
 # This is the chart version. This version number should be incremented each time you make changes
 # to the chart and its templates, including the app version.
 # Versions are expected to follow Semantic Versioning (https://semver.org/)
 version: 0.1.0
 
 # This is the version number of the application being deployed. This version number should be
 # incremented each time you make changes to the application. Versions are not expected to
 # follow Semantic Versioning. They should reflect the version the application is using.
 # It is recommended to use it with quotes.
 appVersion: "1.16.0"
 [root@master mychart]# cd templates/
 [root@master templates]# ls
 deployment.yaml _helpers.tpl hpa.yaml ingress.yaml NOTES.txt serviceaccount.yaml  service.yaml tests
 [root@master templates]# rm -rf * #删除templates里面的文件,然后等下把自己写的放到这里面
 [root@master templates]# ls
 [root@master templates]#
 

Chartyaml: 当前chart属性配置信心

templates: 编写yaml文件放到这个目录中

values.yaml:yaml文件可以使用全局变量

2.在templates文件夹创建两个yaml文件

deployment.yaml

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zzzjdp.html