iT邦幫忙

第 12 屆 iThome 鐵人賽

DAY 24
0
Software Development

Go Distributed & Go Consistently系列 第 24

Day24 Istio (Install & Simple Usage)

我們今天飛遠一點,來介紹一下 Istio。Istio 可以提供我們更好的 load balance 能力,特別是在使用 gRPC 連線時,當前版本的 Kubernetes 本身是無法對 gRPC 連線進行 load balance 的,我們需要自己實作 sidecar 來完成 load balance 的目的,而 Istio 正好提供了我們所需要的功能。

Istio

Istio makes it easy to create a network of deployed services with load balancing, service-to-service authentication, monitoring, and more, with few or no code changes in service code.

就如同官方所聲稱的一樣,它提供了我們一個較無痛低成本的方式,進行 load balance 或 service-to-service 的溝通,甚至可以對 mircoserives 的 flow 進行 tracing。

  • 自動在 HTTP, gRPC, WebSocket, 與 TCP 連線時進行 load balance
  • 可彈性地調整連線的 routing rules, re-try 次數限制, 呼叫頻率限制, 錯誤轉導等
  • 提供像是快速插拔的設定 API,完成配置的熱更新
  • 完整追蹤 cluster 的資訊流動,並提供 metrics logs 用於狀況查詢與分析
  • 自動提供 service-to-service 安全憑證溝通方式

Istio

Install

依照官方安裝流程
istio

完成後應顯示

> istioctl install --set profile=demo

✔ Istio core installed
✔ Istiod installed
✔ Egress gateways installed
✔ Ingress gateways installed
✔ Installation complete

看一下我們先前裝部署的範例所在的 Namespace

> kubectl describe deployments.apps

Name:                   nginx-deployment
Namespace:              default
CreationTimestamp:      Tue, 29 Sep 2020 16:55:01 +0800
Labels:                 app=nginx
Annotations:            deployment.kubernetes.io/revision=1
Selector:               app=nginx
Replicas:               2 desired | 2 updated | 2 total | 2 available | 0 unavailable
StrategyType:           RollingUpdate
MinReadySeconds:        0
RollingUpdateStrategy:  25% max unavailable, 25% max surge
Pod Template:
  Labels:  app=nginx
  Containers:
   nginx:
    Image:        nginx:1.14.2
    Port:         80/TCP
    Host Port:    0/TCP
    Environment:  <none>
    Mounts:       <none>
  Volumes:        <none>
Conditions:
  Type           Status  Reason
  ----           ------  ------
  Available      True    MinimumReplicasAvailable
  Progressing    True    NewReplicaSetAvailable
OldReplicaSets:  <none>
NewReplicaSet:   nginx-deployment-574b87c764 (2/2 replicas created)
Events:          <none>

依照我們在 Namespace : default 的部份,掛上 Istio sidecar

> kubectl label namespace default istio-injection=enabled

namespace/default labeled

掛上 Istio proxy 前

> kubectl get pods

NAME                                READY     STATUS    RESTARTS   AGE
nginx-deployment-574b87c764-82cm2   1/1       Running   0          47h
nginx-deployment-574b87c764-pvkt7   1/1       Running   0          47h

掛上 Istio proxy 後

> > kubectl get pods

NAME                                READY     STATUS    RESTARTS   AGE
nginx-deployment-574b87c764-64jlq   2/2       Running   0          3m19s
nginx-deployment-574b87c764-95r7r   2/2       Running   0          3m19s

可以看到在我們完成部署後,原先 Pods 內的 containers 從 1/1 變成 2/2,這個多出來的 container 便是 Istio proxy container,負責跟 Istio Control Plane 進行溝通,完成服務發現、health check、 load balance 等工作。


上一篇
Day23 Kubernetes (Kubernetes on Docker Desktop & Pod Lifetime)
下一篇
Day25 Istio (Load Balance gRPC)
系列文
Go Distributed & Go Consistently30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言