To be a better coder
分类: LINUX
2020-01-16 14:18:37
[root@master ~]# tree tomcat tomcat ├── charts ├── Chart.yaml ├── templates │ ├── deployment.yaml │ ├── _helpers.tpl │ ├── ingress.yaml │ ├── NOTES.txt │ ├── service.yaml │ └── tests │ └── test-connection.yaml └── values.yaml 3 directories, 8 files
目前创建Chart已经成功,接下来就是修改deployment.yaml和vlues.yaml,改成tomcat所需的内容;
至此,修改完毕,接下来尝试部署到Kubernetes环境;
helm install --dry-run --debug tomcat
得到输出如下:
[root@master ~]# helm install --dry-run --debug tomcat [debug] Created tunnel using local port: '42163' [debug] SERVER: "127.0.0.1:42163" [debug] Original chart version: "" [debug] CHART PATH: /root/tomcat NAME: virtuous-gorilla REVISION: 1 RELEASED: Sat Mar 23 14:52:35 2019 CHART: tomcat-0.1.0 USER-SUPPLIED VALUES: {} COMPUTED VALUES: affinity: {} fullnameOverride: "" image: pullPolicy: IfNotPresent repository: tomcat tag: latest ingress: annotations: {} enabled: false hosts: - chart-example.local paths: [] tls: [] nameOverride: "" nodeSelector: {} replicaCount: 1 resources: {} service: port: 80 type: NodePort tolerations: [] ...
篇幅所限只展示了一部分输出,可见设置的值已经生效; 2. 执行命令helm install tomcat,即可部署当前的Chart到Kubernetes环境,控制台输出如下:
[root@master ~]# helm install tomcat NAME: wistful-condor LAST DEPLOYED: Sat Mar 23 14:54:27 2019 NAMESPACE: default STATUS: DEPLOYED RESOURCES: ==> v1/Service NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE wistful-condor-tomcat NodePort 10.108.155.239 <none> 80:32190/TCP 0s ==> v1/Deployment NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE wistful-condor-tomcat 1 1 1 0 0s ==> v1/Pod(related) NAME READY STATUS RESTARTS AGE wistful-condor-tomcat-7c784699b8-zl7mm 0/1 ContainerCreating 0 0s NOTES: 1. Get the application URL by running these commands: export NODE_PORT=$(kubectl get --namespace default -o jsonpath="{.spec.ports[0].nodePort}" services wistful-condor-tomcat) export NODE_IP=$(kubectl get nodes --namespace default -o jsonpath="{.items[0].status.addresses[0].address}") echo http://$NODE_IP:$NODE_PORT
export NODE_PORT=$(kubectl get --namespace default -o jsonpath="{.spec.ports[0].nodePort}" services wistful-condor-tomcat) export NODE_IP=$(kubectl get nodes --namespace default -o jsonpath="{.items[0].status.addresses[0].address}") echo http://$NODE_IP:$NODE_PORT
我这里得到的地址是: 3. 在浏览器输入上述地址,可见访问tomcat服务成功,如下图:
4. 自定义Chart开发和验证都完成了,执行命令helm package tomcat即可将整个Chart的配置文件打包,方便在其他环境安装部署;
至此helm开发Chart实战就全部完成了,经历了此番实战,今后学习中如遇到公共仓库有不错的Chart,可用helm fetch xxx 将Chart包下载到本地来研究学习源码和配置,也可自己修改后再在本地install;
问题: