iT邦幫忙

第 12 屆 iThome 鐵人賽

DAY 23
0
DevOps

k8s 生態鏈 完美組合系列 第 23

Day23 istio gateway 是什麼?

istio gateway 在 istio 中扮演很重要的角色,如果沒有這東西,就沒有辦法讓外部流量導進來。

雖然說可以透過 service nodeport的模式,掛上 domain 處理。但比較好的方式,假設都是 web 服務的話,其實對外都是 80 or 443 port,這樣如果服務一多,就沒辦法都用同一個 port ,在原生 k8s 模式下有一個叫做 ingress 的東西可以處理這件事情,筆者碰 k8s 沒多久,就直接上 istio 模式了,所以就略過不介紹了,有興去了解的還是可以去參考官網文件

這間稍微簡單介紹一下 istio gateway ,他本身提供 L4 到 L6 的功能,所以 TLS... 等等相關它都辦得到,那一定會有人問 L7 呢? 在 istio 裡面它提供了一個叫 virtualservice 這東西就有了 L7 route rule 的功能,gateway 可以綁定一個 virtualservice,今天先不談 virtualservice,我們先試試 gateway

首先大家先

$ kubectl get service -n istio-system
NAME                   TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)                                                                      AGE
istiod                 ClusterIP      10.43.24.239    <none>        15010/TCP,15012/TCP,443/TCP,15014/TCP,853/TCP                                3d1h
istio-egressgateway    ClusterIP      10.43.60.110    <none>        80/TCP,443/TCP,15443/TCP                                                     3d1h
istio-ingressgateway   LoadBalancer   10.43.189.193   <pending>     15021:32461/TCP,80:32046/TCP,443:30536/TCP,31400:31695/TCP,15443:32082/TCP   3d1h
grafana                ClusterIP      10.43.128.204   <none>        3000/TCP                                                                     5m41s

上面可以看到istio-ingressgateway,這是 istio 安裝 demo profile後,預設就安裝完的 service 或是我把它稱作 gateway 代理,請大家記得這個名稱。

apiVersion: networking.istio.io/v1beta1
kind: Gateway
metadata:
  name: istio-ingressgateway #這裡就是填入上面所查到的 istio-ingressgateway,實務上如果你有多個 ip ,就會有多個 gateway 代理,然後就要描述多個 gateway 去使用 gateway 代理
spec:
  selector:
    istio: first-gateway  #對應virtualservice spec.gateways
  servers:
  - port: #加密傳輸
      number: 443
      name: https
      protocol: HTTPS
    tls:
      mode: SIMPLE
      serverCertificate: /etc/istio/ingressgateway-certs/tls.crt #設定憑證路徑
      privateKey: /etc/istio/ingressgateway-certs/tls.key  #設定憑證路徑
    hosts:
     - "*" #該服務對應domain
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
     - "*" #該服務對應domain

這樣把它部署到 istio-system , 就完成了 gateway 佈置。


上一篇
Day22 istio 模式下碰過的地雷
下一篇
Day24 什麼是 istio virtual service?
系列文
k8s 生態鏈 完美組合30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言