环境准备
-
virtualBox安装
直接官网下载后安装即可,网上也有详细教程。镜像使用的centos7。
链接(不保证还可用):http://big.dxiazaicc.com/bigfile/100/virtualbox_v6.1.26_downcc.com.zip?auth_key=1730185635-pWBtV8LynsxPD0-0-d13becdfe4fd4b856024d0bb6ff7aee0
镜像:
https://mirrors.aliyun.com/centos/7/isos/x86_64/CentOS-7-x86_64-DVD-2009.iso?spm=a2c6h.25603864.0.0.3e182d1cZ5FDr7 -
网络配置
使用桥接的方式 -
docker安装
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo查看所有仓库中docker版本yum list docker-ce --showduplicates | sort -r选择安装18.06.1版本的yum install docker-ce-18.06.1.ce启动start docker enable docker docker version
- docker配置换源
dig @114.114.114.114 registry-1.docker.io
查看IP
vim /etc/hosts
输入内容:IP地址 registry-1.doker.io.
vi /etc/docker/daemon.json
{
"registry-mirrors": ["https://docker.registry.cyou",
"https://docker-cf.registry.cyou",
"https://dockercf.jsdelivr.fyi",
"https://docker.jsdelivr.fyi",
"https://dockertest.jsdelivr.fyi",
"https://mirror.aliyuncs.com",
"https://dockerproxy.com",
"https://mirror.baidubce.com",
"https://docker.m.daocloud.io",
"https://docker.nju.edu.cn",
"https://docker.mirrors.sjtug.sjtu.edu.cn",
"https://docker.mirrors.ustc.edu.cn",
"https://mirror.iscas.ac.cn",
"https://docker.rainbond.cc"]
}
sudo systemctl daemon-reload
sudo systemctl restart docker
- kubectl安装
下载文件到本地后直接安装
sudo install kubectl /usr/local/bin/kubectl
chmod +x kubectl
mv kubectl /usr/local/bin/kubectl
链接:
https://storage.googleapis.com/kubernetes-release/release/v1.16.0/bin/linux/amd64/kubectl
minikube安装
链接:https://objects.githubusercontent.com/github-production-release-asset-2e65be/56353740/77c29600-f756-11e9-8405-40d193dba8b7?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20241029%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20241029T084730Z&X-Amz-Expires=300&X-Amz-Signature=6284e06a96943dbb3b4520e1cddf8172a43874bb64d578baf50a53dd4ec67448&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Dminikube-linux-amd64&response-content-type=application%2Foctet-stream
同样,下载文件到本地后,拉到虚拟机:
chmod +x minikube
sudo install minikube /usr/local/bin/minikube
mv minikube /usr/local/bin/minikube
minikube start --registry-mirror=https://registry.docker-cn.com --image-repository=registry.cn-hangzhou.aliyuncs.com/google_containers --vm-driver=none
启动成功的截图:
查看状态:
kubectl get node
istio安装
链接:https://objects.githubusercontent.com/github-production-release-asset-2e65be/74175805/30d61900-e3d8-11ea-8264-82ef154f0aae?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20241030%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20241030T125845Z&X-Amz-Expires=300&X-Amz-Signature=9c4a02b8bce2b3b9d40a0186ed8ff68be5f641472c08548e15a16ad2cc4ec9a4&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Distio-1.7.0-linux-amd64.tar.gz&response-content-type=application%2Foctet-stream
下载安装包,拉到机器上(github)
将下列环境变量添加etc/profile后source /etc/profile:
export ISTIO_HOME=/root/istio-1.11.1/bin
export PATH= I S T I O H O M E : ISTIO_HOME: ISTIOHOME:PATH
验证:
istioctl version(需启动K8S)
安装:
istioctl install --set profile=demo -y
有问题:
查看日志:
kubectl describe pod istiod-5b9d44c58b-nnkdj -n istio-system
日志显示拉不到镜像,推测是网络问题,通过上文4.的docker源配置修改,先用docker拉到这些镜像后,再次启动,成功了:
查看状态:
kubectl get pods --all-namespaces
配置自动注入envoy:
kubectl label namespace default istio-injection=enabled
bookinfo测试
运行官方demo:
kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml
启动成功:
查看状态:
kubectl get svc,po -o wide
验证:
kubectl exec "$(kubectl get pod -l app=ratings -o jsonpath='{.items[0].metadata.name}')" -c ratings -- curl -sS productpage:9080/productpage | grep -o "<title>.*</title>"
出现响应则启动成功。
- 对外访问
关联网关:
kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml
查看端口映射:
kubectl get svc istio-ingressgateway -n istio-systemNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
istio-ingressgateway LoadBalancer 10.200.138.202 10.0.0.150 15021:30531/TCP,80:31380/TCP,443:31390/TCP,31400:31345/TCP,15443:30249/TCP 2m10s
如果EXTERNAL-IP设置了该值,则您的环境具有可用于入口网关的外部负载平衡器。如果EXTERNAL-IP值是(或永久),则您的环境不为入口网关提供外部负载平衡器。在这种情况下,您可以使用服务的节点端口来访问网关。
这里80对应的端口是Http服务的端口,映射的主机端口31380;
这里443对应的端口是Https服务的端口,映射的主机端口31390;
确定IP:
可以通过下面命令找个hostIP。
[root@k8s-master istio-1.4.2]# kubectl get po -l istio=ingressgateway -n istio-system -o yaml | grep hostIP: -C3
---state:running:startedAt: "2019-12-24T06:46:29Z"hostIP: 192.168.43.239phase: RunningpodIP: 10.244.3.136qosClass: Burstable
---
本机IP:192.168.43.239
在虚拟机外部通过IP+端口+uri访问服务:
启动kiali
部署:
kubectl apply -f samples/addons
查看部署状态,镜像较大,需要都running:
kubctl get pods -n istio-system
拉不到镜像的情况,在docker中手动拉取(由于源和超时时间等原因)
docker pull quay.io/kiali/kiali:v1.22
关键!!!
将kali service 的服务类型设置为 nodeport,以供外部浏览器访问:
kubectl patch svc -n istio-system kiali -p '{"spec": {"type": "NodePort"}}'istioctl dashboard kiali --address 192.168.43.239
通过上文查看20001的映射端口,虚拟机外部浏览器通过IP+端口+uri访问:
虚拟机重启后重新部署
1、启动minikube
2、启动istio
3、启动bookinfo
4、启动kiali
kubectl delete pod kiali-89fd7f87b-tb2rp -n istio-system
参考链接:
https://baijiahao.baidu.com/s?id=1764144114247192969&wfr=spider&for=pc
https://www.cnblogs.com/yinzhengjie/p/18064053#3%E4%B8%8B%E8%BD%BD%E6%8C%87%E5%AE%9A%E7%89%88%E6%9C%AC%E7%9A%84istio
https://blog.csdn.net/wzy_168/article/details/103717671