系列导航
- Istio Mixer Adapter开发 (一)K8S环境搭建
- Istio Mixer Adapter开发 (二)Istio环境搭建
- Istio Mixer Adapter开发 (三)自定义Mixer Grpc Adapter部署
概述
上篇,我们从一个全新安装的VM,安装了kubeadm + Kubernetes + K8S dashboard
本篇将基于搭建好的K8S环境继续Istio的环境搭建
动手安装Istio
首先安装helm,helm是K8S下的包安装组件,如果想对helm有进一步了解,请移步helm官网
参考如下两篇文章安装helm
docs.helm.sh/using_helm/…
docs.helm.sh/using_helm/…
下载istio-1.0.5,使用helm生成istio安装的K8S yaml文件,如下所示:
➜ istio wget wget https://github.com/istio/istio/releases/download/1.0.5/istio-1.0.5-linux.tar.gz
➜ istio tar -xvf istio-1.0.5-linux.tar.gz
➜ istio cd istio-1.0.5
复制代码
参考如下官网链接安装Istio
istio.io/docs/setup/…
参考如下链接设置Istio的各种功能启用情况
注意:其实并不是可以任意指定,笔者就因为关掉了security.enabled导致pilot启动不起来 istio.io/docs/refere…
➜ istio-1.0.5 helm template install/kubernetes/helm/istio --name istio --namespace istio-system \
--set gateways.istio-egressgateway.enabled=false \
--set galley.enabled=false \
--set prometheus.enabled=false \
--set global.enableTracing=false \
--set global.proxy.envoyStatsd.enabled=false \
--set security.enabled=true \
--set gateways.enabled=true \
--set gateways.istio-ingressgateway.enabled=true \
--set sidecarInjectorWebhook.enabled=true \
--set mixer.enabled=true \
--set pilot.sidecar=true > ./istio-helm.yaml
复制代码
开始安装Istio
➜ istio-1.0.5 kubectl create namespace istio-system
➜ istio-1.0.5 kubectl apply -f istio-helm.yaml
➜ istio-1.0.5 kubectl get pods -n istio-system
NAME READY STATUS RESTARTS AGE
istio-citadel-7dd558dcf-6vg6f 1/1 Running 0 8m
istio-cleanup-secrets-dq2fz 0/1 Completed 0 8m
istio-ingressgateway-58c77897cc-x2x6c 1/1 Running 0 16h
istio-pilot-868cdfb5f7-zfq2n 2/2 Running 0 1m
istio-policy-56c4579578-4qkhk 2/2 Running 0 16h
istio-security-post-install-5vwk5 0/1 Completed 0 8m
istio-sidecar-injector-d7f98d9cb-7wn9m 1/1 Running 0 16h
istio-telemetry-7fb48dc68b-pdqrv 2/2 Running 0 16h
复制代码
至此,基于K8S的Istio安装好了,下面我们安装官方的demo验证下
参考这篇文章
istio.io/docs/exampl…
执行下述命令启用namespace为default的istio-sidecar自动注入:
➜ istio-1.0.5 kubectl label namespace default istio-injection=enabled
复制代码
接下来我们部署Istio的官方demo应用验证下我们的部署:
➜ istio-1.0.5 kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml
➜ istio-1.0.5 kubectl get pods
NAME READY STATUS RESTARTS AGE
details-v1-6764bbc7f7-k9sd4 2/2 Running 0 6m
productpage-v1-54b8b9f55-hx2x9 2/2 Running 0 6m
ratings-v1-7bc85949-mqdcp 2/2 Running 0 6m
reviews-v1-fdbf674bb-n9kcf 2/2 Running 0 6m
reviews-v2-5bdc5877d6-9vtj8 2/2 Running 0 6m
reviews-v3-dd846cc78-bc7pl 2/2 Running 0 6m
➜ istio-1.0.5 kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
details ClusterIP 10.108.102.13 9080/TCP 6m
kubernetes ClusterIP 10.96.0.1 443/TCP 19h
productpage ClusterIP 10.97.96.61 9080/TCP 6m
ratings ClusterIP 10.96.196.120 9080/TCP 6m
reviews ClusterIP 10.97.215.227 9080/TCP 6m
复制代码
我们只是安装了服务,还没有配置gateway及virtualserivce等使其能被访问
参考:
istio.io/docs/tasks/…
➜ istio-1.0.5 kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml
复制代码
我们发现Type:LoadBalancer的service:istio-ingressgateway并没有外部IP,这是因为LoadBalancer其实依赖与提供Kubernetes服务的云平台的实现,我们是虚拟机安装,所以需要修改为NodePort类型
➜ istio-1.0.5 kubectl edit svc istio-ingressgateway -n istio-system
...
type: NodePort
...
复制代码
执行下述命令验证应用:
➜ istio-1.0.5 export INGRESS_HOST=$(kubectl get po -l istio=ingressgateway -n istio-system -o 'jsonpath={.items[0].status.hostIP}')
➜ istio-1.0.5 export INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].nodePort}')
➜ istio-1.0.5 export SECURE_INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="https")].nodePort}')
➜ istio-1.0.5 export GATEWAY_URL=$INGRESS_HOST:$INGRESS_PORT
➜ istio-1.0.5 curl -o /dev/null -s -w "%{http_code}\n" http://$GATEWAY_URL/productpage
200
➜ istio-1.0.5 echo $GATEWAY_URL
192.168.101.6:31380
复制代码
可以看到返回结果code为200,说明http通信没有问题,我们到浏览器上验证一下
如图,验证成功,至此我们已经安装好了Kubernetes + Istio的基础环境,下一步我们来将一个已经开发好的Custom Mixer Adapter安装到环境中