k8s-創建自定義chart及部署efk-二十五


一、chart的結構

(1)更改helm為阿里雲倉庫源

[root@master helm]# helm repo remove stable
"stable" has been removed from your repositories

[root@master helm]# helm repo add stable https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts
"stable" has been added to your repositories

[root@master helm]# helm repo list
NAME         URL                                                        
local        http://127.0.0.1:8879/charts                               
incubator    https://kubernetes-charts-incubator.storage.googleapis.com/
stable       https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts

#更新
[root@master helm]# helm repo update
Hang tight while we grab the latest from your chart repositories...
...Skip local chart repository
...Successfully got an update from the "incubator" chart repository
...Successfully got an update from the "stable" chart repository
Update Complete. ⎈ Happy Helming!⎈

(2)

[root@master helm]# pwd
/root/manifests/helm
[root@master helm]# helm fetch stable/redis    #獲取chart,會得到一個壓縮包

[root@master helm]# tar zxf redis-6.4.3.tgz

[root@master helm]# ls
redis  redis-6.4.3.tgz  tiller-rbac.yaml

#chart目錄結構
[root@master helm]# tree redis
redis
├── Chart.yaml            #chart元數據描述信息(版本...)
├── ci
│   ├── default-values.yaml
│   ├── dev-values.yaml
│   ├── production-values.yaml
│   ├── redisgraph-module-values.yaml
│   └── redis-lib-values.yaml
├── README.md
├── templates            #資源定義清單模板文件
│   ├── configmap.yaml
│   ├── health-configmap.yaml
│   ├── _helpers.tpl
│   ├── metrics-deployment.yaml
│   ├── metrics-prometheus.yaml
│   ├── metrics-svc.yaml
│   ├── networkpolicy.yaml
│   ├── NOTES.txt
│   ├── redis-master-statefulset.yaml
│   ├── redis-master-svc.yaml
│   ├── redis-rolebinding.yaml
│   ├── redis-role.yaml
│   ├── redis-serviceaccount.yaml
│   ├── redis-slave-deployment.yaml
│   ├── redis-slave-svc.yaml
│   └── secret.yaml
├── values-production.yaml
└── values.yaml            #為 templates中的資源定義清單設置自定義屬性值
#其他目錄結構
requirements.yaml        #當前chart是否依賴其他chart,這個文件是可選的。
charts/               #里面放置的是當前chart所要依賴的其他chart,這個是可選的。

#可以通過chart官方手冊,來了解以上每項的詳細含義: 
https://docs.helm.sh/developing_charts/#charts

二、用helm生成基礎chart示例性文件

(1)

[root@master helm]# helm create myapp
Creating myapp

[root@master helm]# ls |grep myapp
myapp

[root@master helm]# tree myapp/
myapp/
├── charts
├── Chart.yaml
├── templates
│   ├── deployment.yaml
│   ├── _helpers.tpl
│   ├── ingress.yaml
│   ├── NOTES.txt
│   └── service.yaml
└── values.yaml

#可以自己修改每個文件里的值,然后做語法檢查
[root@master helm]# helm lint myapp
==> Linting myapp
[INFO] Chart.yaml: icon is recommended

1 chart(s) linted, no failures

#打包
[root@master helm]# helm package myapp/
Successfully packaged chart and saved it to: /root/manifests/helm/myapp-0.0.1.tgz

[root@master helm]# ls |grep myapp
myapp
myapp-0.0.1.tgz

(2)啟動本地倉庫,並應用

[root@master helm]# helm repo list
NAME      URL                                             
stable    https://kubernetes-charts.storage.googleapis.com
local     http://127.0.0.1:8879/charts  

#啟動本地倉庫
[root@master helm]# helm serve 
Regenerating index. This may take a moment.
Now serving you on 127.0.0.1:8879

#查看,可見myapp已經自動保存在倉庫中了
[root@master ~]# helm search myapp
NAME           CHART VERSION    APP VERSION    DESCRIPTION                            
local/myapp    0.0.1            1.0            A Helm chart for Kubernetes myapp chart

#如果定義的沒問題,就可以部署了
[root@master ~]# helm install --name myapp1 local/myapp

#刪除
[root@master ~]# helm delete --purge myapp1

 

三、EFK日志系統

(1)添加incubator源

[root@master ~]# helm repo add incubator https://kubernetes-charts-incubator.storage.googleapis.com/
"incubator" has been added to your repositories

[root@master ~]# helm repo list
NAME         URL                                                        


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM