kubernetes 1.7.3及以上,並開啓RBAC
kubernetes 1.9 以上,支持自動安裝sidecar injectionnode
一、開啓serviceaccount
二、網絡組件
三、有dnslinux
cd /usr/local/src/ wget https://github.com/istio/istio/releases/download/0.7.1/istio-0.7.1-linux.tar.gz tar -zxf istio-0.7.1-linux.tar.gz
cd istio-0.7.1 cp bin/istioctl /usr/local/sbin/ kubectl apply -f install/kubernetes/istio.yaml
kubectl apply -f install/kubernetes/istio-auth.yaml
git
全部項目在namespace istio-system查看github
image名稱,能夠提早下載docker
docker.io/istio/proxy:0.7.1 docker.io/istio/mixer:0.7.1 docker.io/istio/pilot:0.7.1 docker.io/istio/istio-ca:0.7.1
查看是否安裝成功json
kubectl get svc -n istio-system NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE istio-ingress LoadBalancer 10.111.150.31 <pending> 80:31691/TCP,443:30512/TCP 4h istio-mixer ClusterIP 10.100.150.25 <none> 9091/TCP,15004/TCP,9093/TCP,9094/TCP,9102/TCP,9125/UDP,42422/TCP 4h istio-pilot ClusterIP 10.108.203.112 <none> 15003/TCP,15005/TCP,15007/TCP,15010/TCP,8080/TCP,9093/TCP,443/TCP 4h
kubectl get pods -n istio-system NAME READY STATUS RESTARTS AGE istio-ca-5d495f8897-dvpg6 1/1 Running 0 4h istio-ingress-5b5db76895-wqndc 1/1 Running 0 4h istio-mixer-db9f8d47d-7gn9h 3/3 Running 0 4h istio-pilot-84fcc8d4d7-lk9n2 2/2 Running 0 4h
kubectl label namespace <namespace> istio-injection=enabled kubectl create -n <namespace> -f <your-app>.yaml
若是沒安裝Istio-sidecar-injector,必須手動添加kubectl create -f <(istioctl kube-inject -f <your-app>.yaml)
api
kubectl delete -f install/kubernetes/istio-sidecar-injector-with-ca-bundle.yaml
網絡
kubectl delete -f install/kubernetes/istio.yaml
app
kubectl delete -f install/kubernetes/istio-auth.yaml
curl
istioctl kube-inject -f helloworld.yaml -o helloworld-istio.yaml
使用新的yaml文件,部署服務kubectl create -f helloworld-istio.yaml
獲取ingress url 和端口
export HELLOWORLD_URL=$(kubectl get po -l istio=ingress -o 'jsonpath={.items[0].status.hostIP}'):$(kubectl get svc istio-ingress -o 'jsonpath={.spec.ports[0].nodePort}')
查看服務是否正常curl http://$HELLOWORLD_URL/hello
獲取node ipkubectl get po -l istio=ingress -n istio-system -o 'jsonpath={.items[0].status.hostIP}'
獲取node portkubectl get svc istio-ingress -n istio-system -o 'jsonpath={.spec.ports[0].nodePort}'
如今訪問curl http://$HELLOWORLD_URL/hello
發現規則是輪詢到每一個節點
一、只能訪問v1, route-rule-all-v1.yaml
apiVersion: config.istio.io/v1alpha2 kind: RouteRule metadata: name: helloword-default spec: destination: name: helloworld route: - labels: version: v1
二、只能訪問v2, route-rule-all-v2.yaml
apiVersion: config.istio.io/v1alpha2 kind: RouteRule metadata: name: helloword-default spec: destination: name: helloworld route: - labels: version: v2
刪除規則istioctl delete routerules helloword-default
查看規則istioctl get routerules