Anh em cần coi clip của anh này là master helm liền.
https://www.youtube.com/watch?v=LWW8_S0dbG8
Không hiểu sao nó không hiện video. Rất hay các bạn tự click nhé.
Intall helm cli on linux
install helm trên ubuntu:
curl https://baltocdn.com/helm/signing.asc | sudo apt-key add -
sudo apt-get install apt-transport-https --yes
echo "deb https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list
sudo apt-get update
sudo apt-get install helm
Install helm cli on windows
https://www.youtube.com/watch?v=L3iNhrjQILM
Access this link: https://github.com/helm/helm/releases/
thế là ok.
Tạo ra 1 chart mẫu
helm create fullname-override
Câu lệnh ví dụ:
helm template generic/ --values /root/value_helm_tiki.yaml
gen ra 1 package helm
helm package ./tikici-helm-charts/common -d tikici-helm-charts/generic/charts/
Đánh index để public helm chart trên github
helm repo index ./
Các xuất file value.yaml của helm-chart
helm repo add rancher-latest https://releases.rancher.com/server-charts/latest
-->"rancher-latest" has been added to your repositories
helm search repo rancher-latest
>>output
NAME CHART VERSION APP VERSION DESCRIPTION
rancher-latest/rancher 2.6.0 v2.6.0 Install Rancher Server to manage Kuberne
helm show values rancher-latest/rancher > rancher.yaml
>>Lúc này chúng ta thấy file value được xuất ra
root@work-space-u20:~/mylab-helm-chart/value-helm# ls
rancher.yaml
Nếu bạn gõ:helm install cron-test ./ --values ./value_helm.yaml
mà gặp lỗi này: Error: cannot re-use a name that is still in use
helm ls -n <namespaces>
helm delete -n my-namespace my-release
Cách để print helm chart ra từng file.
helm search repo spinnaker
helm pull opsmx/spinnaker --untar
mkdir rendering
helm template --dry-run spinnaker <folder_helm-chart> | awk -vout=<folder_manifest-yaml> -F": " '$0~/^# Source: /{file=out"/"$2; print "Creating "file; system ("mkdir -p $(dirname "file"); echo -n "" > "file)} $0!~/^#/ && $0!="---"{print $0 >> file}'
example:
helm template --dry-run spinnaker ./spinnaker | awk -vout=./rendering -F": " '$0~/^# Source: /{file=out"/"$2; print "Creating "file; system ("mkdir -p $(dirname "file"); echo -n "" > "file)} $0!~/^#/ && $0!="---"{print $0 >> file}'
https://github.com/helm/helm/issues/4680#issuecomment-613201032
get manifest/value of helm that is installed on k8s
PS C:\Users\thang.tran> helm.exe list -A NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION aws-load-balancer-controller kube-system 1 2022-06-02 12:42:38.33274549 +0000 UTC deployed aws-load-balancer-controller-1.3.2 v2.3.0 PS C:\Users\thang.tran> helm -n kube-system get values aws-load-balancer-controller USER-SUPPLIED VALUES: clusterName: mdc-platf-dev-fed image: tag: v2.3.0 serviceAccount: create: false name: aws-load-balancer-controller >>> In order to get manifest(deploy, service, ingress,...) helm get manifest aws-load-balancer-controller -n kube-system
Use Golang language in Helm chart
mình sử dụng printf trong helm chart
cài này nó hao hao giống code golang còn trong helm chart nó gọi là:
https://helm.sh/docs/chart_template_guide/function_list/
image: "{{ .Values.linux.image.repository }}:{{ .Values.linux.image.tag | default (printf "prod-linux-%s" .Chart.AppVersion) }}"