IstioのIngressGatewayの検証
[MEMO] katacodaでService Mesh with Istio: ver2 Istioctl - だいごろうのブログ こっちのブログポストで気になったので、 ingress gatewayを試してみようと思います。環境作成を前のブログを参考にしてください。
Ingress Gateway
KubernetesのIngress Controllerと似たような機能を Istioとかで利用できるようにするのがIngress Gatewayっぽい。
とりあえず、ここを理解してみよう。 Istio / Ingress Gateways
Istio on Minikube
Istio / Minikube どうやら、デフォルトだとメモリやCPUが全然足りないみたいなので、増やす。最初、これをしてなくて、全然、podが起動しなくて、困った。 とりあえず、メモリとCPUを倍に増やしてみる。(まだ、足りないかも)あと、minikubeのデフォルトのVMがいっぱいいっぱいになってきたので、profile変えてみる。
minikube start --memory=4096 --cpus=4 -p istio
後で気づいたが、tunnelでistioにLoadBalancerを提供できるみたい。 後日検証。
sudo minikube tunnel
Istioの確認
kubectl get svc istio-ingressgateway -n istio-system NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE istio-ingressgateway LoadBalancer 10.110.94.62 <pending> 15020:32200/TCP,80:31380/TCP,443:31390/TCP,31400:31400/TCP,15029:32445/TCP,15030:30505/TCP,15031:30605/TCP,15032:31662/TCP,15443:30531/TCP 7d
このEXTERNAL-IPがNoneやpendingの場合は、NodePortでアクセスしてくれって書いてあるな。たぶん、LoadBalancer立ててないのと、minikubeのせいで、pendingになってんのかな。 external load balancer for the ingress gateway
がないと、あかんっぽいな。
minikube + nodeportの場合は、IPとポートをこんな感じで取得
export INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].nodePort}') export SECURE_INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="https")].nodePort}') export INGRESS_HOST=$(minikube ip -p istio)
公式に沿って、istio GatewayとVirtualService立てる
Gateway
kubectl apply -n istio-tutorial -f - <<EOF apiVersion: networking.istio.io/v1alpha3 kind: Gateway metadata: name: httpbin-gateway namespace: istio-tutorial spec: selector: istio: ingressgateway # use Istio default gateway implementation servers: - port: number: 80 name: http protocol: HTTP hosts: - "istio.tutorial.com" EOF
VirtualService
kubectl apply -n istio-tutorial -f - <<EOF apiVersion: networking.istio.io/v1alpha3 kind: VirtualService metadata: name: httpbin spec: hosts: - "istio.tutorial.com" gateways: - httpbin-gateway http: - match: - uri: prefix: / route: - destination: port: number: 8080 host: customer EOF
確認
# ちゃんと設定できているかを確認 curl -I -HHost:istio.tutorial.com http://$INGRESS_HOST:$INGRESS_PORT/ -v # アクセスを確認 kubectl logs pod/customer-59975dcff6-jwc7c -n istio-tutorial --all-containers=true -f
Ingress gateway と ingress resources
Ingress gateway と ingress resourcesの違いをちゃんと理解したい。今、認識ているところだと、ingress gatewayを使うと、Istioの旨味をGatewayでも利用できる点と、 既存のingress resourcesだとhttp/httpsしか、ハンドルできないんじゃないかな。
これも後でちゃんとよむ。 Ingress - Kubernetes
感想
思ったとおり、動いた!でも、Istioのインストールのときに、なぜか数分間いくつかのpodがうまく起動できなかったり、ちょっとハマった。まだ、わかってない点がおおいなぁ。kubernetes のingressでも思ったが、簡単に使える点は良い。理解しなければいけないことは多いが、便利。