<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                ## 1. 條件 - Kubernetes 集群 有關Helm 和 Kubernetes 之間支持的最大版本偏差,請[參閱Helm 版本支持策略](https://www.bookstack.cn/read/helm-3.8.0-en/625996e4776bdd15.md)。 ## 2. 安裝 ### 2.1 二進制版本安裝 helm 的每個[版本](https://github.com/helm/helm/releases)都為各種操作系統提供二進制版本 ```bash $ wget https://get.helm.sh/helm-v3.8.0-linux-amd64.tar.gz $ tar -xzvf helm-v3.8.0-linux-amd64.tar.gz $ cp linux-amd64/helm /usr/local/bin/ $ helm version version.BuildInfo{Version:"v3.8.0", GitCommit:"d14138609b01886f544b2025f5000351c9eb092e", GitTreeState:"clean", GoVersion:"go1.17.5"} ``` ### 2.2 腳本安裝 Helm 現在有一個安裝程序腳本,它會自動獲取最新版本的 Helm 并在[本地安裝](https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3)它。 ```bash $ curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 $ chmod 700 get_helm.sh $ ./get_helm.sh ``` ### 2.3 更多安裝方式 [更多安裝方式請參考這里](https://www.bookstack.cn/read/helm-3.8.0-en/6d3a31117a899d97.md) ## 3. 三大概念 - `Chart`是一個Helm 包。它包含在 Kubernetes 集群內運行應用程序、工具或服務所需的所有資源定義。可以把它想象成 Kubernetes 的 Homebrew 公式、Apt dpkg 或 Yum RPM 文件。 - `Repository` 是可以收集和共享圖表的地方。它類似于 Perl 的CPAN 存檔或Fedora 包數據庫,但用于 Kubernetes 包。 - `Release`是在 Kubernetes 集群中運行的Chart的實例。一個Chart通常可以多次安裝到同一個集群中。每次安裝時,都會創建一個新Release。考慮一個 MySQL Chart。如果您希望在集群中運行兩個數據庫,則可以將該Chart安裝兩次。每個都有自己的發行版,而發行版又會有自己的發行版名稱。 ## 4. 常用方法 ### 4.1 'helm repo':使用存儲庫 檢查[Artifact Hub](https://artifacthub.io/packages/search?kind=0)以獲取可用的 Helm 圖表存儲庫。 ```bash $ helm repo list NAME URL stable https://charts.helm.sh/stable mumoshu https://mumoshu.github.io/charts $ helm repo add bitnami https://charts.bitnami.com/bitnami ``` 由于圖表存儲庫經常更改,因此您可以隨時通過運行`helm repo update`. 可以使用 刪除存儲庫`helm repo remove`。 ### 4.2 'helm search': 查找圖表 - `helm search hub`搜索[Artifact Hub](https://artifacthub.io/),其中列出了來自數十個不同存儲庫的 helm 圖表。 - `helm search repo`搜索您添加到本地 helm 客戶端的存儲庫(使用helm repo add)。此搜索是在本地數據上完成的,不需要公共網絡連接。 ```bash $ helm search hub wordpress URL CHART VERSION APP VERSION DESCRIPTION https://hub.helm.sh/charts/bitnami/wordpress 7.6.7 5.2.4 Web publishing platform for building blogs and ... https://hub.helm.sh/charts/presslabs/wordpress-... v0.6.3 v0.6.3 Presslabs WordPress Operator Helm Chart https://hub.helm.sh/charts/presslabs/wordpress-... v0.7.1 v0.7.1 A Helm chart for deploying a WordPress site on ... ``` 以上搜索了`wordpress` Artifact Hub 上的所有圖表。 沒有過濾器,`helm search hub`向您顯示所有可用的圖表。 使用`helm search repo`,您可以在已添加的存儲庫中找到圖表的名稱: ```bash $ helm repo add brigade https://brigadecore.github.io/charts "brigade" has been added to your repositories $ helm search repo brigade NAME CHART VERSION APP VERSION DESCRIPTION brigade/brigade 1.3.2 v1.2.1 Brigade provides event-driven scripting of Kube... brigade/brigade-github-app 0.4.1 v0.2.1 The Brigade GitHub App, an advanced gateway for... brigade/brigade-github-oauth 0.2.0 v0.20.0 The legacy OAuth GitHub Gateway for Brigade brigade/brigade-k8s-gateway 0.1.0 A Helm chart for Kubernetes brigade/brigade-project 1.0.0 v1.0.0 Create a Brigade project brigade/kashti 0.4.0 v0.4.0 A Helm chart for Kubernetes ``` Helm 搜索使用模糊字符串匹配算法,因此您可以鍵入部分單詞或短語: ```bash $ helm search repo kash NAME CHART VERSION APP VERSION DESCRIPTION brigade/kashti 0.4.0 v0.4.0 A Helm chart for Kubernetes ``` ### 4.3 helm install':安裝包 在最簡單的情況下,它需要兩個參數:您選擇的版本名稱和您要安裝的圖表的名稱。 ```bash $ helm install happy-panda bitnami/wordpress NAME: happy-panda LAST DEPLOYED: Tue Jan 26 10:27:17 2021 NAMESPACE: default STATUS: deployed REVISION: 1 NOTES: ** Please be patient while the chart is being deployed ** Your WordPress site can be accessed through the following DNS name from within your cluster: happy-panda-wordpress.default.svc.cluster.local (port 80) To access your WordPress site from outside the cluster follow the steps below: 1. Get the WordPress URL by running these commands: NOTE: It may take a few minutes for the LoadBalancer IP to be available. Watch the status with: 'kubectl get svc --namespace default -w happy-panda-wordpress' export SERVICE_IP=$(kubectl get svc --namespace default happy-panda-wordpress --template "{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}") echo "WordPress URL: http://$SERVICE_IP/" echo "WordPress Admin URL: http://$SERVICE_IP/admin" 2. Open a browser and access WordPress using the obtained URL. 3. Login with the following credentials below to see your blog: echo Username: user echo Password: $(kubectl get secret --namespace default happy-panda-wordpress -o jsonpath="{.data.wordpress-password}" | base64 --decode) ``` 現在`wordpress`圖表已安裝。請注意,安裝圖表會創建一個新的發布對象。上面的版本名為`happy-panda`. (如果您希望 Helm 為您生成名稱,請省略發布名稱并使用`--generate-name`.) 在安裝過程中,helm客戶端將打印有關創建了哪些資源、發布狀態是什么以及您是否可以或應該采取其他配置步驟的有用信息。 Helm 按以下順序安裝資源: ```bash 命名空間 網絡策略 資源配額 限制范圍 PodSecurityPolicy PodDisruptionBudget 服務帳戶 秘密 秘密清單 配置映射 存儲類 持久卷 PersistentVolumeClaim 自定義資源定義 集群角色 集群角色列表 集群角色綁定 ClusterRoleBindingList 角色 角色列表 角色綁定 角色綁定列表 服務 守護程序集 在下面 復制控制器 副本集 部署 Horizo??ntalPodAutoscaler 有狀態集 工作 定時任務 入口 API服務 ``` Helm 不會等到所有資源都運行完才退出。許多圖表需要大小超過 600M 的 Docker 鏡像,并且可能需要很長時間才能安裝到集群中。 要跟蹤發布的狀態,或重新讀取配置信息,您可以使用`helm status`: ```bash $ helm status happy-panda NAME: happy-panda LAST DEPLOYED: Tue Jan 26 10:27:17 2021 NAMESPACE: default STATUS: deployed REVISION: 1 NOTES: ** Please be patient while the chart is being deployed ** Your WordPress site can be accessed through the following DNS name from within your cluster: happy-panda-wordpress.default.svc.cluster.local (port 80) To access your WordPress site from outside the cluster follow the steps below: - Get the WordPress URL by running these commands: NOTE: It may take a few minutes for the LoadBalancer IP to be available. Watch the status with: 'kubectl get svc --namespace default -w happy-panda-wordpress' export SERVICE_IP=$(kubectl get svc --namespace default happy-panda-wordpress --template "{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}") echo "WordPress URL: http://$SERVICE_IP/" echo "WordPress Admin URL: http://$SERVICE_IP/admin" - Open a browser and access WordPress using the obtained URL. - Login with the following credentials below to see your blog: echo Username: user echo Password: $(kubectl get secret --namespace default happy-panda-wordpress -o jsonpath="{.data.wordpress-password}" | base64 --decode) ``` 更多安裝方式 - 一個圖表存儲庫(正如我們在上面看到的) - 本地圖表存檔 ( `helm install foo foo-0.1.1.tgz`) - 解壓后的圖表目錄 ( `helm install foo path/to/foo`) - 完整網址 ( `helm install foo https://example.com/charts/foo-1.2.3.tgz`) ### 4.4 自定義chart 要查看圖表上可配置的選項,請使用`helm show values`: ```bash $ helm show values bitnami/wordpress ## Global Docker image parameters ## Please, note that this will override the image parameters, including dependencies, configured to use the global value ## Current available global Docker image parameters: imageRegistry and imagePullSecrets ## # global: # imageRegistry: myRegistryName # imagePullSecrets: # - myRegistryKeySecretName # storageClass: myStorageClass ## Bitnami WordPress image version ## ref: https://hub.docker.com/r/bitnami/wordpress/tags/ ## image: registry: docker.io repository: bitnami/wordpress tag: 5.6.0-debian-10-r35 [..] ``` 然后,您可以覆蓋 YAML 格式文件中的任何這些設置,然后在安裝期間傳遞該文件。 ```bash $ echo '{mariadb.auth.database: user0db, mariadb.auth.username: user0}' > values.yaml $ helm install -f values.yaml bitnami/wordpress --generate-name ``` 以上將創建一個名為 的默認 MariaDB 用戶`user0`,并授予該用戶對新創建的`user0db`數據庫的訪問權限,但將接受該圖表的所有其余默認值。 在安裝過程中有兩種方式傳遞配置數據: - `--values`(或-f):指定具有覆蓋的 YAML 文件。這可以指定多次,最右邊的文件將優先 - `--set`:在命令行上指定覆蓋 如果兩者都使用,則以更高的優先級`--set`合并值。`--values`用 指定的覆蓋`--set`將持久保存在 `ConfigMap` 中。`--set`可以使用 . 查看給定版本的值`helm get values <release-name>`。可以通過使用指定`--set`的運行來清除已被清除的值。`helm upgrade--reset-values` #### 4.4.1 格式和限制--set 該`--set`選項采用零個或多個名稱/值對。最簡單的用法是這樣的:`--set name=value.` 等效的 YAML 是: ```bash name: value ``` 多個值由,字符分隔。于是`--set a=b,c=d`變成: ```bash a: b c: d ``` 支持更復雜的表達式。例如,`--set outer.inner=value`翻譯成這樣: ```bash outer: inner: value ``` 列表可以通過將值括在{和中來表示}。例如,`--set name={a, b, c}`轉換為: ```bash name: - a - b - c ``` 從 `Helm 2.5.0` 開始,可以使用數組索引語法訪問列表項。例如,`--set servers[0].port=80`變為: ```bash servers: - port: 80 ``` 可以通過這種方式設置多個值。該行`--set servers[0].port=80,servers[0].host=example`變為: ```bash servers: - port: 80 host: example ``` 有時您需要在行中使用特殊字符`--set`。您可以使用反斜杠來轉義字符;`--set name=value1\,value2`會變成: ```bash name: "value1,value2" ``` `toYaml`同樣,您也可以轉義點序列,當圖表使用該函數解析注釋、標簽和節點選擇器時,這可能會派上用場。的語法`--set nodeSelector."kubernetes\.io/role"=master`變為: ```bash nodeSelector: kubernetes.io/role: master ``` 閱讀有關[值文件](https://www.bookstack.cn/read/helm-3.8.0-en/9adfbde68c1a44d9.md)的更多信息 ### 4.5 'helm upgrade' 和 'helm rollback':升級版本,并在失敗時恢復 當發布新版本的圖表時,或者當您想要更改發布的配置時,可以使用該helm upgrade命令。 升級采用現有版本并根據您提供的信息對其進行升級。由于 Kubernetes 圖表可能很大且很復雜,Helm 嘗試執行侵入性最小的升級。它只會更新自上次發布以來已更改的內容。 ```bash $ helm upgrade -f panda.yaml happy-panda bitnami/wordpress ``` 在上述情況下,happy-panda使用相同的圖表升級版本,但使用新的 YAML 文件: ```bash mariadb.auth.username: user1 ``` 我們可以`helm get values`用來查看新設置是否生效。 ```bash $ helm get values happy-panda mariadb: auth: username: user1 ``` 該`helm get`命令是查看集群中發布的有用工具。正如我們在上面看到的,它表明我們的新值`panda.yaml`已部署到集群中。 現在,如果在發布期間某些事情沒有按計劃進行,很容易使用`helm rollback [RELEASE] [REVISION]`. ```bash $ helm rollback happy-panda 1 ``` 以上將我們的`happy-panda` 回滾到它的第一個發布版本。發布版本是增量修訂。每次安裝、升級或回滾時,修訂號都會增加 1。第一個修訂號始終為 1。我們可以使用它`helm history [RELEASE]`來查看某個版本的修訂號。 ### 4.6 安裝/升級/回滾的有用選項 在安裝/升級/回滾期間,您可以指定其他幾個有用的選項來自定義 Helm 的行為。請注意,這不是 cli 標志的完整列表。要查看所有標志的描述,只需運行`helm <command> --help`. - `--timeout`:等待 Kubernetes 命令完成的Go 持續時間值。這默認為`5m0s`. - `--wait`:等到所有 Pod 都處于就緒狀態,PVC 被綁定,部署有最少(Desired減號maxUnavailable)的 Pod 處于就緒狀態并且服務有一個 IP 地址(如果是 a 則為 `Ingress LoadBalancer`),然后才將發布標記為成功。只要`--timeout`值,它將等待。如果達到超時,釋放將被標記為`FAILED`。注意:在`Deploymentreplicas`設置為 1 并且`maxUnavailable`作為滾動更新策略的一部分未設置為 0的情況下,--wait將返回就緒狀態,因為它滿足了處于就緒狀態的最小 Pod。 - `--no-hooks`:這會跳過命令的運行鉤子 - `--recreate-pods`(僅適用于upgrade和rollback):此標志將導致重新創建所有 Pod(屬于部署的 Pod 除外)。(在 Helm 3 中已棄用) ### 4.7 'helm uninstall':卸載版本 ```bash $ helm uninstall happy-panda $ helm list NAME VERSION UPDATED STATUS CHART inky-cat 1 Wed Sep 28 12:59:46 2016 DEPLOYED alpine-0.1.0 ``` 在以前的 `Helm` 版本中,當一個版本被刪除時,它的刪除記錄將保留。在 `Helm 3` 中,刪除也會刪除發布記錄。如果您希望保留刪除版本記錄,請使用`helm uninstall --keep-history`. Using `helm list --uninstalled`將僅顯示使用該`--keep-history`標志卸載的版本。 該`helm list --all`標志將顯示 Helm 保留的所有發布記錄,包括失敗或已刪除項目的記錄(如果`--keep-history`已指定): ```bash $ helm list --all NAME VERSION UPDATED STATUS CHART happy-panda 2 Wed Sep 28 12:47:54 2016 UNINSTALLED wordpress-10.4.5.6.0 inky-cat 1 Wed Sep 28 12:59:46 2016 DEPLOYED alpine-0.1.0 kindred-angelf 2 Tue Sep 27 16:16:10 2016 UNINSTALLED alpine-0.1.0 ``` 請注意,由于現在默認刪除版本,因此無法再回滾已卸載的資源。 有時,當 Helm 運行`helm uninstall.` chart開發人員可以為資源添加注釋以防止其被卸載。 ```bash kind: Secret metadata: annotations: "helm.sh/resource-policy": keep [...] ``` 注釋`"helm.sh/resource-policy": keep`指示 Helm 在 helm 操作(例如`helm uninstall`、`helm upgrade`或`helm rollback`)導致其刪除時跳過刪除此資源。但是,此資源成為孤立資源。Helm 將不再以任何方式管理它。`helm install --replace`如果在已卸載但保留資源的版本上使用,這可能會導致問題。 ### 4.8 創建自己的chart [圖表開發指南](https://www.bookstack.cn/read/helm-3.8.0-en/89342c804d7c3b76.md)解釋了如何開發您自己的圖表。`helm create`但是您可以使用以下命令快速入門: ```bash $ helm create deis-workflow Creating deis-workflow ``` 當您編輯圖表時,您可以通過運行來驗證它的格式是否正確`helm lint`。 當需要打包圖表以進行分發時,您可以運行以下`helm package`命令: ```bash $ helm package deis-workflow deis-workflow-0.1.0.tgz ``` 現在可以通過以下方式輕松安裝該圖表helm install: ```bash $ helm install deis-workflow ./deis-workflow-0.1.0.tgz ``` 打包的圖表可以加載到圖表存儲庫中。有關更多詳細信息,請[參閱Helm 圖表存儲庫的文檔](https://www.bookstack.cn/read/helm-3.8.0-en/11c72f6ac43a81ed.md)。 --- ?<font color= #FF4500 size=4 style="font-family:Courier New">推薦閱讀:</font> - [helm官網](https://helm.sh/docs/) - [helm 3.8.0 gitbook](https://www.bookstack.cn/read/helm-3.8.0-en/eb6c7d10673f4231.md) - [helm charts 入門指南](https://ghostwritten.blog.csdn.net/article/details/123400829)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看