使用 Helm Chart 部署及卸载 istio

部署 istio

1.添加 istio 官方的 helm 仓库

 
  1. helm repo add istio https://storage.googleapis.com/istio-release/releases/1.3.3/charts/

2.是否添加成功

 
  1. helm search repo istio

NAME CHART VERSION APP VERSION DESCRIPTION

istio/istio 1.3.3 1.3.3 Helm chart for all istio components

istio/istio-cni 1.3.3 1.3.3 Helm chart for istio-cni components

istio/istio-init 1.3.3 1.3.3 Helm chart to initialize Istio CRDs

3.创建 istio-system 命名空间

 
  1. kubectl create ns istio-system

4.创建 istio 所需的 crd 文件

 
  1. helm install istio-init istio/istio-init -n istio-system

5.检查 CRD 文件是否创建完成,输出为23

 
  1. kubectl get crds | grep 'istio.io' | wc -l

23

6.部署 istio

 
  1. helm install istio istio/istio -n istio-system

NAME: istio

LAST DEPLOYED: Thu Oct 24 12:05:06 2019

NAMESPACE: istio-system

STATUS: deployed

REVISION: 1

NOTES:

Thank you for installing Istio.

Your release is named Istio.

To get started running application with Istio, execute the following steps:

  1. Label namespace that application object will be deployed to by the following command (take default namespace as an example)

kubectl label namespace default istio-injection=enabled

​ kubectl get namespace -L istio-injection

  1. Deploy your applications

$ kubectl apply -f .yaml

For more information on running Istio, visit:

https://istio.io/

卸载 istio

1.卸载 istio

 
  1. helm -n istio-system uninstall istio

2.删除 istio crd 文件

 
  1. helm -n istio-system uninstall istio-init
  2. kubectl delete crd `kubectl get crd | grep istio| awk '{print $1}'`

一键部署及卸载 istio 的脚本

部署脚本

 
  1. #!/bin/bash
  2. # Add istio official repo
  3. add_repo(){
  4. VERSION=$1
  5. REPO="https://storage.googleapis.com/istio-release/releases/${VERSION}/charts/"
  6. helm repo add istio $REPO
  7. STATUS_CMD=`echo $?`
  8. CHECK_REPO_CMD=`helm repo list | grep $REPO | wc -l`
  9. echo "$STATUS_CMD"
  10. echo "$CHECK_REPO_CMD"
  11. while [[ $STATUS_CMD != 0 && $CHECK_REPO_CMD -ge 1 ]]
  12. do
  13. sleep 5
  14. helm repo add istio $REPO
  15. STATUS_CMD=`echo $?`
  16. CHECK_REPO_CMD=`helm repo list | grep $REPO | wc -l`
  17. done
  18. }
  19. # Create istio-system namespace
  20. create_namespace() {
  21. NAMESPACE=$1
  22. kubectl create ns ${NAMESPACE}
  23. STATUS_CMD=`echo $?`
  24. while [[ $STATUS_CMD != 0 ]]
  25. do
  26. sleep 5
  27. kubectl create ns ${NAMESPACE}
  28. STATUS_CMD=`echo $?`
  29. done
  30. }
  31. # Create CRD need for istio
  32. create_crd() {
  33. NAMESPACE=$1
  34. helm install istio-init istio/istio-init -n ${NAMESPACE}
  35. CRD_COUNT=`kubectl get crds | grep 'istio.i' | wc -l`
  36. while [[ ${CRD_COUNT} != 23 ]]
  37. do
  38. sleep 5
  39. CRD_COUNT=`kubectl get crds | grep 'istio.io' | wc -l`
  40. done
  41. echo 'Istio crd create successful'
  42. }
  43. # Deploy istio related components
  44. deploy_istio() {
  45. NAMESPACE=$1
  46. VERSION=$2
  47. helm install istio istio/istio -n ${NAMESPACE}
  48. check() {
  49. kubectl -n ${NAMESPACE} get deploy | grep istio | awk '{print "deployment/"$1}' | while read line ;
  50. do
  51. kubectl rollout status $line -n ${NAMESPACE};
  52. done
  53. }
  54. check
  55. echo "Istio is deployed successful"
  56. }
  57. main(){
  58. ISTIO_VERSION="1.3.3"
  59. ISTIO_NAMESPACE="istio-system"
  60. add_repo $ISTIO_VERSION
  61. if [[ `kubectl get ns | grep $ISTIO_NAMESPACE | wc -l ` == 0 && `kubectl get ns $ISTIO_NAMESPACE | grep -v NAME | wc -l` == 0 ]] ;then
  62. create_namespace $ISTIO_NAMESPACE
  63. fi
  64. create_crd $ISTIO_NAMESPACE
  65. deploy_istio $ISTIO_NAMESPACE $ISTIO_VERSION
  66. }
  67. main

卸载脚本

 
  1. #!/bin/bash
  2. helm -n istio-system uninstall istio
  3. helm -n istio-system uninstall istio-init
  4. kubectl delete crd `kubectl get crd | grep istio | awk '{print $1}'`
  5. kubectl delete ns istio-system

注意:卸载需谨慎,删除了 istio-system 的命名空间

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值