Helm

a package management on k8s

Kubneretes 系列教材 A.1 v1.0

前言

k8s 最常用的軟體部署, 還是透過 kubectl, 搭配 yaml 檔來安裝或刪除. 但有些成熟或簡易的工具, 就不需那個麻煩, 直接交給 helm 來管理

所以, 我用它在 k8s 安裝工具

  • traefik
  • keycloak
  • keycloak-gatekeeper
  • lamp
  • elasticsearch
  • logstash
  • kibana
  • filebeat
  • elastalert
  • 等等 ...

我也用它來刪除所有 packages

➜  helm list -q | xargs helm delete


release "hissing-worm" deleted
release "historical-wolf" deleted
release "masked-woodpecker" deleted
release "named-condor" deleted
release "viable-ladybird" deleted
release "wanton-bison" deleted

prod 不要嘗試 !!!, 會全部刪除

helm 環境安裝

包含 tiller

helm 指令集

除安裝及包裝 chart 以外的指令

helm 指令介紹 - search

用來搜尋有哪些工具軟體可以利用 helm 來安裝

➜  helm search beat

 

NAME   CHART VERSION   APP VERSION DESCRIPTION

stable/auditbeat      1.1.0        6.7.0      A lightweight shipper to audit the activities of users an...

stable/filebeat          3.1.0        7.0.1      A Helm chart to collect Kubernetes logs with filebeat

stable/heartbeat      1.2.0        6.7.0      A Helm chart to periodically check the status of your ser...

stable/metricbeat    1.7.0        6.7.0      A Helm chart to collect Kubernetes logs with metricbeat

stable/dmarc2logstash 1.2.0        1.0.3      Provides a POP3-polled DMARC XML report injector into

helm 指令介紹 - install

用來將軟體或工具的 chart 更新到 k8s

➜  helm install --name keycloak stable/keycloak  --tiller-

namespace tiller-world --namespace tiller-world

 

NAME:   keycloak
LAST DEPLOYED: Sat Oct 12 02:04:10 2019
NAMESPACE: tiller-world
STATUS: DEPLOYED

kubectl port-forward 指令

➜  export POD_NAME=$(kubectl get pods --namespace tiller-world -l app=keycloak,release=keycloak -o jsonpath="{.items[0].metadata.name}")
➜  echo "Visit http://127.0.0.1:8080 to use Keycloak"
➜  kubectl port-forward --namespace tiller-world $POD_NAME 8080

➜  ngrok http 8080

Forwarding                    https://016c0276.ngrok.io -> http://localhost:8080

https://016c0276.ngrok.io

kubectl port-forward 指令

➜  export POD_NAME=$(kubectl get pods --namespace tiller-world -l app=keycloak,release=keycloak -o jsonpath="{.items[0].metadata.name}")
➜  echo "Visit http://<public IP>:8003 to use Keycloak"

➜  kubectl port-forward --namespace tiller-world $POD_NAME

➜  ngrok http 8080

Forwarding                    https://016c0276.ngrok.io -> http://localhost:8080

 8003:8080 --address 0.0.0.0

helm 指令介紹 - list

用來列出 k8s 上已經用 helm 安裝的軟體

➜  helm list -q --tiller-namespace tiller-world
keycloak

 

➜  helm list --tiller-namespace tiller-world

 

NAME    REVISION UPDATED                  STATUS  CHART          APP VERSION NAMESPACE

keycloak 1        Sat Oct 12 02:04:10 2019 DEPLOYED keycloak-4.10.1 5.0.0      tiller-world

helm 指令介紹 - delete, del

用來刪除 k8s 上已安裝的軟體

➜  helm --tiller-namespace tiller-world del --purge keycloak


release "keycloak" deleted

helm 指令介紹 - repo list

用來列出 local 所有 chart repos URL 的清單

➜  helm repo list

 

NAME        URL

stable      https://kubernetes-charts.storage.googleapis.com

local      http://127.0.0.1:8879/charts

codecentric https://codecentric.github.io/helm-charts

gabibbo97  https://gabibbo97.github.io/charts/

helm 指令介紹 - repo add

用來增加一個新的 chart repo 的參考 URL

➜  helm repo add gabibbo97 https://gabibbo97.github.io/charts/


"gabibbo97" has been added to your repositories

helm 指令介紹 - repo update

用來更新參考的 chart repos

➜  helm repo update


Hang tight while we grab the latest from your chart repositories...
...Skip local chart repository
...Successfully got an update from the "codecentric" chart repository
...Successfully got an update from the "gabibbo97" chart repository
...Successfully got an update from the "stable" chart repository
Update Complete.

helm 指令介紹 - repo remove

用來刪除 local 某一個 chart repo 的 URL

➜  helm repo remove codecentric


"codecentric" has been removed from your repositories

helm 指令介紹 - repo

還有其他 help repo 副指令: remove, list, index

Usage:
  helm repo [command]

Available Commands:
  add         add a chart repository
  index       generate an index file given a directory containing packaged charts
  list        list chart repositories
  remove      remove a chart repository
  update      update information of available charts locally from chart repositories

自己做 chart

打包 hello world 安裝包

chart 是什麼?

簡單說就是 k8s 部署的 yaml 懶人包. 所以要先會用 kubectl 部署你的軟體, 再把 yaml 打包, 並做版號管理之. 未來可以用 helm 安裝不同版本, 升版或降版

helm 指令總複習

helm init

helm version

helm repo list

helm repo add

helm repo update

helm repo remove

helm search

helm install

helm list

helm delete

helm upgrade

helm 指令的一些選項

 -f, --values

 --set

 --name

 --version

Helm

By Ming-der Wang

Helm

  • 1,245