环境信息
- Kubernetes:v1.20.6
- StorageClass:csi-udisk-rssd
- Helm:v3.5.2
- nginx-ingress: 0.47.0
本安装前准备工作
1. 同步海外源镜像
在国内环境部署应用,经常因为获取国外源站容器镜像超时,导致部署失败,可以提前将容器镜像同步到本地镜像仓库中,以自有镜像仓库uhub.service.ucloud.cn/ucloud_pts 为例,login仓库,执行命令: docker login uhub.service.ucloud.cn/ucloud_pts
需要同步镜像列表如下:
for IMG in \
cr.l5d.io/linkerd/proxy-init:v1.3.11 \
cr.l5d.io/linkerd/proxy:stable-2.10.2
do
echo $IMG
docker pull $IMG
docker tag $IMG uhub.service.ucloud.cn/ucloud_pts/$IMG
docker push uhub.service.ucloud.cn/ucloud_pts/$IMG
done
关于docker pull tag push 操作可以参考:
- https://docs.docker.com/engine/reference/commandline/pull/
- https://docs.docker.com/engine/reference/commandline/tag/
- https://docs.docker.com/engine/reference/commandline/push/
2. 创建 imagePullSecrets
创建容器集群访问仓库地址 uhub.service.ucloud.cn/ucloud_pts,拉取镜像需要的 secret
kubectl create namespace monitor
kubectl create secret docker-registry registry-linkerd-secret \
--namespace=linkerd \
--docker-server=uhub.service.ucloud.cn/ucloud_pts \
--docker-username='xxxxxx' \
--docker-password='xxxxxx'
3. 添加 Helm仓库
这里选用 linkerd 提供的chart仓库
helm repo add linkerd https://helm.linkerd.io/stable helm repo update
4. 为命名空间添加配置
linkerd 作为控制平面,kube-system 作为k8s组件的运行空间,均不需要ServiceMesh化
kubectl label namespace linkerd \
config.linkerd.io/admission-webhooks=disabled --overwrite
kubectl label namespace kube-system \
config.linkerd.io/admission-webhooks=disabled --overwrite
5. 创建mtls证书
使用 step 创建集群内通讯的证书
wget https://github.com/smallstep/cli/releases/download/v0.16.1/step_linux_0.16.1_amd64.tar.gz
tar -xpvf step_linux_0.16.1_amd64.tar.gz
cp step_0.16.1/bin/step /usr/bin
step certificate create root.linkerd.admin.local \
ca.crt ca.key --profile root-ca --no-password --insecure
step certificate create identity.linkerd.admin.local \
issuer.crt issuer.key --profile intermediate-ca \
--not-after 8760h \
--no-password \
--insecure \
--ca ca.crt --ca-key ca.key
6. 完成linkerd核心组件的安装
cat > linkerd-values.yaml << EOF
clusterDomain: admin.local
clusterNetworks: "10.0.0.0/8,100.64.0.0/10,172.16.0.0/12,192.168.0.0/16"
installNamespace: false
namespace: linkerd
proxy:
image:
name: harbor.onwalk.net/pts/cr.l5d.io/linkerd/proxy
version: stable-2.10.2
proxyInit:
image:
name: harbor.onwalk.net/pts/cr.l5d.io/linkerd/proxy-init
version: v1.3.11
EOF
helm upgrade --install linkerd \
--set-file identityTrustAnchorsPEM=ca.crt \
--set-file identity.issuer.tls.crtPEM=issuer.crt \
--set-file identity.issuer.tls.keyPEM=issuer.key \
--set identity.issuer.crtExpiry=$(date -d '+8760 hour' +"%Y-%m-%dT%H:%M:%SZ") \
-f linkerd-values.yaml linkerd/linkerd2 -n linkerd
7. 完成linkerd-viz Dashboard扩展组件的安装
cat > linkerd-viz-values.yaml << EOF
clusterDomain: admin.local
linkerdNamespace: linkerd
installNamespace: true
namespace: linkerd-viz
EOF
helm upgrade --install linkerd-viz \
-f linkerd-viz-values.yaml \
linkerd/linkerd-viz
网友评论