标签:istio
istio 安装kubernetes 1.7.3及以上,并开启RBAC
kubernetes 1.9 以上,支持自动安装sidecar injection
1、开启serviceaccount
2、网络组件
3、有dns
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
所有项目在namespace istio-system查看
image名称,可以提前下载
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
查看是否安装成功
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)
kubectl delete -f install/kubernetes/istio-sidecar-injector-with-ca-bundle.yaml
kubectl delete -f install/kubernetes/istio.yaml
kubectl delete -f install/kubernetes/istio-auth.yaml
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
发现规则是轮询到每个节点
1、只能访问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
2、只能访问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
标签:istio
原文地址:http://blog.51cto.com/foxhound/2108516