istio 安裝與bookinfo示例運行


 

目的

本文旨在幫助想了解istio安裝和運行bookinfo示例的同學快速入門

 

前置准備

安裝k8s和helm

1、k8s安裝

修改主機名
hostnamectl set-hostname k8s-master
hostnamectl set-hostname k8s-node
配置阿里雲yum源環境和gpg校驗配置
docker-ce
/etc/yum.repos.d目錄下
wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

kubernetes
/etc/yum.repos.d目錄下

vim kubenetes.repo 

[kubernetes]
name=Kubernetes Repo
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
gpgcheck=1 
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
enabled=1 

gpg校驗配置

wget https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
wget https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
rpm --import rpm-package-key.gpg
rpm --import yum-key.gpg
根據官方示例安裝kubeadm(安裝1.15.4版本k8s)

 

yum install -y docker-ce kubelet-1.15.4 kubeadm-1.15.4 kubectl-1.15.4 

 

按照官方示例設置環境參數

https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/

https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/

 

kubeadm init運行使用阿里雲鏡像

kubeadm init \
--image-repository registry.aliyuncs.com/google_containers \
--pod-network-cidr=10.244.0.0/16

其中10.244.0.0/16是 flannel網絡必加參數

 

2、helm安裝

1.下載安裝
wget https://get.helm.sh/helm-v2.14.3-linux-amd64.tar.gz
tar -zxf helm-v2.14.3-linux-amd64.tar.gz
cd linux-amd64
chmod +x helm
mv helm /usr/local/bin
2.確保您擁有一個為Tiller定義了集群管理員角色的服務帳戶
kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.3/install/kubernetes/helm/helm-service-account.yaml
3.使用阿里鏡像安裝tiller,同時將repo 改為微軟提供的helm repo
helm init --upgrade -i registry.cn-hangzhou.aliyuncs.com/google_containers/tiller:v2.14.3 --stable-repo-url http://mirror.azure.cn/kubernetes/charts/ --service-account=tiller

Istio安裝

1.下載安裝包

參考地址:https://istio.io/docs/setup/#downloading-the-release

curl -L https://git.io/getLatestIstio | ISTIO_VERSION=1.3.1 sh -
cd istio-1.3.1
export PATH=$PWD/bin:$PATH

2.通過helm install與Helm和Tiller一起安裝istio

參考地址: https://istio.io/docs/setup/install/helm/

使用kubectl apply安裝所有Istio自定義資源定義(CRD),並等待幾秒鍾以在Kubernetes API服務器中提交CRD:

helm install install/kubernetes/helm/istio-init --name istio-init --namespace istio-system --set gateways.istio-ingressgateway.type=NodePort

使用以下命令驗證是否已將所有23個Istio CRD都提交給Kubernetes api服務器:

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

選擇一個配置文件,然后安裝與您選擇的文件相對應的istio圖表:

helm install install/kubernetes/helm/istio --name istio --namespace istio-system \
--values install/kubernetes/helm/istio/values-istio-demo.yaml \
--set gateways.istio-ingressgateway.type=NodePort

3.運行bookinfo示例

參考地址: https://istio.io/docs/examples/bookinfo/

kubectl label namespace default istio-injection=enabled
kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml
kubectl get pods
kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml
export INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].nodePort}')
export SECURE_INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="https")].nodePort}')
export INGRESS_HOST=<k8s-node ip>
export GATEWAY_URL=$INGRESS_HOST:$INGRESS_PORT

瀏覽器訪問http://${GATEWAY_URL}/productpage

更多示例參考:https://istio.io/docs/tasks/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM