iT邦幫忙

2019 iT 邦幫忙鐵人賽

DAY 24
1
Kubernetes

15 分鐘學習系列 - 第一次學 Kubernetes 就上手系列 第 24

Day 24 - 使用 Helm 部署應用程式到 Kubernetes

上一篇筆記介紹如何安裝 Helm, 這一篇筆記將介紹如何簡單地用 Helm 部署應用程式.

使用 Helm 部署應用程式到 Kubernetes

  1. 編輯 values yaml 檔案, values 檔案中定義 Helm 樣版中的參數值
# values.yaml
replicaCount: 3
wishlistImage:
  repository: karthequian/wishlist
  tag: "1.0"
  pullPolicy: IfNotPresent
authImage:
  repository: karthequian/wishlist-auth
  tag: "1.0"
  pullPolicy: IfNotPresent
catalogImage:
  repository: karthequian/wishlist-catalog
  tag: "1.0"
  pullPolicy: IfNotPresent

service:
  type: NodePort
  wishlistPortName: wishlist-port
  wishlistPortValue: 8080
  catalogPortName: catalog-port
  catalogPortValue: 8082
  authPortName: auth-port
  authPortValue: 8081
  port: 80
  1. 使用命令 helm install -n wishlist-chart -f .\values.yaml 安裝 Chart
PS C:\k8s\helm\wishlist> helm install -n wishlist-chart -f .\values.yaml .
NAME:   wishlist-chart
LAST DEPLOYED: Wed Oct 24 13:51:54 2018
NAMESPACE: default
STATUS: DEPLOYED

RESOURCES:
==> v1/Service
NAME            AGE
wishlist-chart  0s

==> v1/Deployment
wishlist-chart  0s

==> v1/Pod(related)

NAME                             READY  STATUS   RESTARTS  AGE
wishlist-chart-69796586bb-2st6r  0/3    Pending  0         0s
wishlist-chart-69796586bb-6ntlf  0/3    Pending  0         0s
wishlist-chart-69796586bb-8jlzr  0/3    Pending  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 wishlist-chart)
  export NODE_IP=$(kubectl get nodes --namespace default -o jsonpath="{.items[0].status.addresses[0].address}")
  echo http://$NODE_IP:$NODE_PORT
  1. 部署完成後, 使用命令 kubectl get deployments 檢查 deployment 是否完成?
PS C:\k8s\helm\wishlist> kubectl get deployments
NAME                               DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
aspnetapp-deployment               2         2         2            2           13d
aspnetapp-interactive-delopyment   3         3         3            3           13d
wishlist-chart                     3         3         3            3           2m
wishlist-deployment                3         3         3            3           12h
  1. 也可以使用命令 helm ls, 列出已經部署的 helm chart
PS C:\k8s\helm\wishlist> helm ls
NAME            REVISION        UPDATED                         STATUS          CHART               APP VERSION     NAMESPACE
wishlist-chart  1               Wed Oct 24 13:51:54 2018        DEPLOYED        wishlist-0.1.0      1.0             default
PS C:\k8s\helm\wishlist> kubectl get svc
NAME                               TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                                        AGE
kubernetes                         ClusterIP   10.96.0.1        <none>        443/TCP                                        14d
wishlist-chart                     NodePort    10.105.185.182   <none>        8080:31584/TCP,8082:31679/TCP,8081:30676/TCP   4m
wishlist-service                   NodePort    10.97.103.43     <none>        8080:30480/TCP,8081:32207/TCP,8082:32379/TCP   12h

是不是很簡單就將應用程式部署完成了?


參考資料:


上一篇
Day 23 - 安裝 Helm
下一篇
Day 25 - 使用 Prometheus 進行 Kubernetes 量測
系列文
15 分鐘學習系列 - 第一次學 Kubernetes 就上手30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言