1、helm 安装 karmada(2023-11-12)
k8s版本:k8s-1.28.2
器运行时版本:containerd-1.6.24
网络插件:calico-v3.26.1
istio版本:istio-1.19.3
karmada版本:v1.7.1
这里准备四个 k8s 集群(假设四个集群分别部署运行在北上广深区域)
前提条件:四个集群的API-SERVER(kube-apiserver)需要互通!!!
每一个集群的istio都有独立的控制平面、独立的网络
helm repo add karmada-charts https://raw.githubusercontent.com/karmada-io/karmada/master/charts
helm search repo karmada
helm --namespace karmada-system upgrade -i karmada karmada-charts/karmada --version=v1.7.1 --create-namespace \
--set cfssl.image.registry=ccr.ccs.tencentyun.com/huanghuanhui \
--set cfssl.image.repository=cfssl \
--set cfssl.image.tag=v1.6.4 \
--set etcd.internal.image.registry=registry.aliyuncs.com/google_containers \
--set etcd.internal.nodeSelector=kubernetes.io/hostname=k8s-master-beijing \
--set etcd.internal.tolerations[0].key=node-role.kubernetes.io/k8s-master-beijing \
--set etcd.internal.tolerations[0].operator=Exists \
--set etcd.internal.tolerations[0].effect=NoSchedule
--set apiServer.image.registry=registry.aliyuncs.com/google_containers \
--set kubeControllerManager.image.registry=registry.aliyuncs.com/google_containers \
--set apiServer.hostNetwork=false \
--set apiServer.serviceType=NodePort \
--set apiServer.nodePort=32443 \
--set certs.auto.hosts[0]="kubernetes.default.svc" \
--set certs.auto.hosts[1]="*.etcd.karmada-system.svc.cluster.local" \
--set certs.auto.hosts[2]="*.karmada-system.svc.cluster.local" \
--set certs.auto.hosts[3]="*.karmada-system.svc" \
--set certs.auto.hosts[4]="localhost" \
--set certs.auto.hosts[5]="127.0.0.1" \
--set certs.auto.hosts[6]="192.168.1.201"
镜像使用腾讯云镜像仓库(公开)(dockerhub同步过来的)
etcd固定k8s-master-beijing上
kubectl get secret karmada-kubeconfig \
-n karmada-system \
-o jsonpath={.data.kubeconfig} | base64 -d > karmada-config
sed -i '/https/s/\(https.*\)/https:\/\/192.168.1.201:32443/g' karmada-config
# 使用kubectl加上karmada的config文件操作karmada集群(直接使用karmadactl命令还是有点区别的)
kubectl get clusters --kubeconfig=/root/karmada-config
cd && wget https://github.com/karmada-io/karmada/releases/download/v1.7.1/karmadactl-linux-amd64.tgz
cd && wget https://gh-proxy.com/https://github.com/karmada-io/karmada/releases/download/v1.7.1/karmadactl-linux-amd64.tgz --no-check-certificate
tar xf ~/karmadactl-linux-amd64.tgz && mv ~/karmadactl /usr/local/sbin/
# 临时
alias karmadactl='karmadactl --kubeconfig=/root/karmada-config'
unalias karmadactl
alias
# 永久
cat >> ~/.bashrc << 'EOF'
alias karmadactl='karmadactl --kubeconfig=/root/karmada-config'
EOF
mkdir -p ~/kubeconfig
scp k8s-master-beijing:~/.kube/config ~/kubeconfig/k8s-master-beijing-kubeconfig
scp k8s-master-shanghai:~/.kube/config ~/kubeconfig/k8s-master-shanghai-kubeconfig
scp k8s-master-guangzhou:~/.kube/config ~/kubeconfig/k8s-master-guangzhou-kubeconfig
scp k8s-master-shenzhen:~/.kube/config ~/kubeconfig/k8s-master-shenzhen-kubeconfig
karmadactl join k8s-master-beijing --kubeconfig=karmada-config --cluster-kubeconfig=/root/kubeconfig/k8s-master-beijing-kubeconfig
karmadactl join k8s-master-shanghai --kubeconfig=karmada-config --cluster-kubeconfig=/root/kubeconfig/k8s-master-shanghai-kubeconfig
karmadactl join k8s-master-guangzhou --kubeconfig=karmada-config --cluster-kubeconfig=/root/kubeconfig/k8s-master-guangzhou-kubeconfig
karmadactl join k8s-master-shenzhen --kubeconfig=karmada-config --cluster-kubeconfig=/root/kubeconfig/k8s-master-shenzhen-kubeconfig
kubectl get clusters --kubeconfig=/root/karmada-config
# 卸载
karmadactl unjoin k8s-master-beijing --kubeconfig=karmada-config
karmadactl unjoin k8s-master-shanghai --kubeconfig=karmada-config
karmadactl unjoin k8s-master-guangzhou --kubeconfig=karmada-config
karmadactl unjoin k8s-master-shenzhen --kubeconfig=karmada-config