Extra Port Mapping
由於Mac在Monterey之後連tuntap都失效了,所以先前有一篇Kind in MacOS大略說明了在Mac上要用Kind
來測試的基本方式。
但要加入Istio就又多了些考量,所以在安裝上就必需做些改變。主要是extraportmapping
的增加
nodes:
- role: control-plane
kubeadmConfigPatches:
- |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
extraPortMappings:
- containerPort: 30080
hostPort: 80
protocol: TCP
- containerPort: 30443
hostPort: 443
protocol: TCP
- containerPort: 30021
hostPort: 15021
protocol: TCP
- containerPort: 31400
hostPort: 31400
protocol: TCP
- containerPort: 31443
hostPort: 31443
protocol: TCP
node-labels: "ingress-ready=true"
這部份也很重要,在Istio中的ingressgateway
上也要加上
再來就是眾多的port mapping,這裡的containerPort
也要加入到istio的安裝設定中
MetalLB
為了更方便使用Istio也要加入metallb,Kind in MacOS中也有說明。
Istio
brew
Mac要安裝直接透過brew即可。
brew install istioctl
dump
接下來因為要修改istio的安裝yaml,所以先用滙出的方式來取得基本的檔案
istioctl profile dump demo >> istio_install.yaml
主要的修改就在srvice.ports
裡,其中的nodePort
要對應方才建立kind cluster時的containerPort
ingressGateways:
- enabled: true
k8s:
...
service:
ports:
- name: status-port
port: 15021
targetPort: 15021
nodePort: 30021
- name: http2
port: 80
targetPort: 8080
nodePort: 30080
- name: https
port: 443
targetPort: 8443
nodePort: 30443
- name: tcp
port: 31400
targetPort: 31400
nodePort: 31400
- name: tls
port: 15443
targetPort: 15443
nodePort: 31443
install istio
再用方才修改完的檔案進行istio的安裝
istioctl install -f istio_install.yaml
enable inject
再來將istio-injection
開啟
kubectl label namespace default istio-injection=enabled --overwrite
install service
kubectl apply -f istio_service.yaml
因為我們先前已經用extra port mapping連到了ingressgateway
,所以用localhost:80/foobar
就能串入istio中,簡單的用browser就能看到熟悉的結果
foo
bar
相關設定檔皆置於Github
操作順序如下
kind create cluster --name mbp --config 01_kind_cluster.yaml
kubectl apply -f 02_metallb-native.yaml
kubectl apply -f 03_metallb-config.yaml
istioctl install -f 04_istio_install.yaml
kubectl label namespace default istio-injection=enabled --overwrite
kubectl apply -f 05_istio_service.yaml