配置说明

  • 系统:win10
  • 内存:16G
  • docker desktop:2.3.0.3
  • kubernetes:v1.16.5
  • istio:1.6.4

环境搭建

安装k8s

视频教程:https://www.bilibili.com/video/av96585506

下载安装包:https://www.docker.com/products/docker-desktop

1
git clone https://github.com/AliyunContainerService/k8s-for-docker-desktop

获取登录token:

1
2
3
4
$TOKEN=((kubectl -n kube-system describe secret default | Select-String "token:") -split " +")[1]
kubectl config set-credentials docker-for-desktop --token="${TOKEN}"
echo $TOKEN
kubectl proxy

访问:http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/

安装istio

安装istio:

下载istio-1.6.4-win.zip,添加环境变量

1
istioctl install --set profile=demo

启用kiali:

1
istioctl dashboard kiali

访问:http://localhost:2978/kiali

其它监控可以通过dashboard命令查看:istioctl dashboard

1
istioctl dashboard 

域名访问:${serviceName}.${namespace}.svc.cluster.local

构建镜像

打包和构建镜像:

1
.\gradlew build&&docker-compose build

部署demo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
kubectl create namespace sg-exam

kubectl config set-context $(kubectl config current-context) --namespace=sg-exam

kubectl create configmap config-repo-auth-service --from-file=config-repo/application.yml --from-file=config-repo/auth-service.yml --save-config
kubectl create configmap config-repo-exam-service --from-file=config-repo/application.yml --from-file=config-repo/exam-service.yml --save-config
kubectl create configmap config-repo-msc-service --from-file=config-repo/application.yml --from-file=config-repo/msc-service.yml --save-config
kubectl create configmap config-repo-user-service --from-file=config-repo/application.yml --from-file=config-repo/user-service.yml --save-config

kubectl create secret generic config-server-secrets --from-literal=ENCRYPT_KEY=my-very-secure-encrypt-key --from-literal=SPRING_SECURITY_USER_NAME=dev-usr --from-literal=SPRING_SECURITY_USER_PASSWORD=dev-pwd --save-config

kubectl label namespace sg-exam istio-injection=enabled

kubectl -n istio-system get secret istio-ingressgateway-certs

kubectl create -n istio-system secret tls istio-ingressgateway-certs --key kubernetes/cert/tls.key --cert kubernetes/cert/tls.crt

kubectl create secret tls tls-certificate --key kubernetes/cert/tls.key --cert kubernetes/cert/tls.crt

kubectl apply -k kubernetes/services/overlays/dev

kubectl apply -k kubernetes/services/base/dev

kubectl get svc istio-ingressgateway -n istio-system

取消部署

1
kubectl delete namespace sg-exam