二 Istio:在Kubernetes(k8s)集群上安装部署istio1.14( 八 )

要检查命名空间是否被标记,请运行下面的命令 。microservice 命名空间应该是唯一一个启用了该值的命名空间 。
[root@k8scloude1 istioyaml]# kubectl get namespace -L istio-injectionNAMESTATUSAGEISTIO-INJECTIONapp-team1Active163dmicroserviceActive3m39senabledmy-appActive162dnetworkActive219dns1Active256d#或者这样查询[root@k8scloude1 istioyaml]# kubectl get namespace -l istio-injection=enabledNAMESTATUSAGEmicroserviceActive6m56s现在我们可以尝试在 microservice 命名空间创建一个 Deployment,并观察注入的代理 。我们将创建一个名为 mynginx 的 Deployment,使用hub.c.163.com/library/nginx:latest镜像的单一容器 。
[root@k8scloude1 istioyaml]# kubectl create deployment mynginx --image=hub.c.163.com/library/nginx:latest -n microservicedeployment.apps/mynginx created如果我们看一下 Pod,你会发现 Pod 里有两个容器 。
[root@k8scloude1 istioyaml]# kubectl get deployment -n microserviceNAMEREADYUP-TO-DATEAVAILABLEAGEmynginx1/11127s[root@k8scloude1 istioyaml]# kubectl get pod -n microserviceNAMEREADYSTATUSRESTARTSAGEmynginx-5cb948ffc5-wv29l2/2Running035s同样地,描述 Pod 时会显示 Kubernetes 同时创建了一个 nginx 容器和一个 istio-proxy 容器:
[root@k8scloude1 istioyaml]# kubectl describe pod mynginx-5cb948ffc5-wv29l -n microserviceName:mynginx-5cb948ffc5-wv29l......Events:TypeReasonAgeFromMessage-------------------------NormalScheduled12mdefault-schedulerSuccessfully assigned microservice/mynginx-5cb948ffc5-wv29l to k8scloude2NormalPulled12mkubeletContainer image "docker.io/istio/proxyv2:1.14.3" already present on machineNormalCreated12mkubeletCreated container istio-initNormalStarted12mkubeletStarted container istio-initNormalPulling12mkubeletPulling image "hub.c.163.com/library/nginx:latest"NormalPulled12mkubeletSuccessfully pulled image "hub.c.163.com/library/nginx:latest" in 2.24360029sNormalCreated12mkubeletCreated container nginxNormalStarted12mkubeletStarted container nginxNormalPulled12mkubeletContainer image "docker.io/istio/proxyv2:1.14.3" already present on machineNormalCreated12mkubeletCreated container istio-proxyNormalStarted12mkubeletStarted container istio-proxy运行下面的命令,删除deployment:
[root@k8scloude1 istioyaml]# kubectl delete deployment mynginx -n microservicedeployment.apps "mynginx" deleted[root@k8scloude1 istioyaml]# kubectl get deployment -n microserviceNo resources found in microservice namespace.[root@k8scloude1 istioyaml]# kubectl get pod -n microserviceNo resources found in microservice namespace.6.6 更新和卸载 Istio如果我们想更新当前的安装或改变配置文件,那么需要更新先前部署的 IstioOperator 资源 。
要删除安装,我们必须删除 IstioOperator,例如:
[root@k8scloude1 istioyaml]# kubectl get istiooperator -n istio-systemNAMEREVISIONSTATUSAGEdemo-istio-installHEALTHY45m[root@k8scloude1 istioyaml]# kubectl delete istiooperator demo-istio-install -n istio-system在 Operator 删除了Istio 后,运行下面的命令来删除 Operator:
[root@k8scloude1 istioyaml]# istioctl operator remove请确保在删除 Operator 之前先删除 IstioOperator 资源 。否则,可能会有剩余的 Istio 资源 。
【二 Istio:在Kubernetes(k8s)集群上安装部署istio1.14】

经验总结扩展阅读