通过karmadactl的方式部署karmada
Karmada可以通过helm/二进制/源码方式,或者CLI方式安装,可以参考官方的“安装概述”
karmadactl是一个完全专用于Karmada的CLI工具,这次通过karmadactl方式,将其安装到一个现有的k8s集群内。安装后的环境,仅用于测试
部分安装文件在国内网络会下载失败,可以提前下载到本地
一、安装好一个k8s集群
略
二、升级go版本,到1.19
# 系统版本 Ubuntu 20.04
add-apt-repository ppa:longsleep/golang-backports apt-get update apt-get install golang-go
二、安装karmadactl
wget https://github.com/karmada-io/karmada/releases/download/v1.4.1/karmadactl-linux-amd64.tgz tar zxvf karmadactl-linux-amd64.tgz mv karmadactl /usr/local/bin/ # 查看用法: karmadactl --help
三、开始初始化
# 安装过程中需要用到crds.tar.gz文件,国外网络不通,需要提前把crds.tar.gz下载到本地 wget https://github.com/karmada-io/karmada/releases/download/v1.4.0/crds.tar.gz -o /root/karmada/crds.tar.gz
# 开始安装Karmada karmadactl init \ --port 32444 \ --etcd-image registry.cn-hangzhou.aliyuncs.com/google_containers/etcd:3.5.3-0 \ --etcd-replicas=1 \ --karmada-apiserver-replicas 1 --etcd-replicas 1 \ --karmada-controller-manager-replicas 1 \ --karmada-kube-controller-manager-replicas 1 \ --karmada-scheduler-replicas 1 \ --karmada-webhook-replicas 1 \ --karmada-aggregated-apiserver-image karmada/karmada-aggregated-apiserver:v1.4.0 \ --karmada-apiserver-image registry.cn-hangzhou.aliyuncs.com/google_containers/kube-apiserver:v1.23.14 \ --karmada-controller-manager-image karmada/karmada-controller-manager:v1.4.0 \ --karmada-kube-controller-manager-image registry.cn-hangzhou.aliyuncs.com/google_containers/kube-controller-manager:v1.23.14 \ --karmada-scheduler-image karmada/karmada-scheduler:v1.4.0 \ --karmada-webhook-image karmada/karmada-webhook:v1.4.0 \ --crds /root/karmada/crds.tar.gz # kube-apiserver:v1.23.14 和 kube-controller-manager:v1.23.14 两个镜像的地址,是我随便写的,需要修改成正确的地址
# 初始化成功的提示
------------------------------------------------------------------------------------------------------ █████ ████ █████████ ███████████ ██████ ██████ █████████ ██████████ █████████ ░░███ ███░ ███░░░░░███ ░░███░░░░░███ ░░██████ ██████ ███░░░░░███ ░░███░░░░███ ███░░░░░███ ░███ ███ ░███ ░███ ░███ ░███ ░███░█████░███ ░███ ░███ ░███ ░░███ ░███ ░███ ░███████ ░███████████ ░██████████ ░███░░███ ░███ ░███████████ ░███ ░███ ░███████████ ░███░░███ ░███░░░░░███ ░███░░░░░███ ░███ ░░░ ░███ ░███░░░░░███ ░███ ░███ ░███░░░░░███ ░███ ░░███ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ███ ░███ ░███ █████ ░░████ █████ █████ █████ █████ █████ █████ █████ █████ ██████████ █████ █████ ░░░░░ ░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░░░░░░ ░░░░░ ░░░░░ ------------------------------------------------------------------------------------------------------ Karmada is installed successfully. Register Kubernetes cluster to Karmada control plane. Register cluster with 'Push' mode Step 1: Use "karmadactl join" command to register the cluster to Karmada control plane. --cluster-kubeconfig is kubeconfig of the member cluster. (In karmada)~# MEMBER_CLUSTER_NAME=$(cat ~/.kube/config | grep current-context | sed 's/: /\n/g'| sed '1d') (In karmada)~# karmadactl --kubeconfig /etc/karmada/karmada-apiserver.config join ${MEMBER_CLUSTER_NAME} --cluster-kubeconfig=$HOME/.kube/config Step 2: Show members of karmada (In karmada)~# kubectl --kubeconfig /etc/karmada/karmada-apiserver.config get clusters Register cluster with 'Pull' mode Step 1: Use "karmadactl register" command to register the cluster to Karmada control plane. "--cluster-name" is set to cluster of current-context by default. (In member cluster)~# karmadactl register 172.1.19.129:32444 --token o5o907.tgauc4tsr619um9a --discovery-token-ca-cert-hash sha256:ef3a8343a6fa00417e902b96e743847983c9b25c2d3b199658c65fd4851ac055 Step 2: Show members of karmada (In karmada)~# kubectl --kubeconfig /etc/karmada/karmada-apiserver.config get clusters
# 检查pod运行状态 root@JCPT-T-005:~# kubectl get pod -n karmada-system NAME READY STATUS RESTARTS AGE etcd-0 1/1 Running 0 15h karmada-aggregated-apiserver-b49685f8b-hj9gb 1/1 Running 0 15h karmada-apiserver-785f98b954-lxlcl 1/1 Running 0 15h karmada-controller-manager-78488cf74d-c2r25 1/1 Running 0 15h karmada-scheduler-66ffcd885d-5msb6 1/1 Running 0 15h karmada-webhook-85bfdcf657-knds7 1/1 Running 0 15h kube-controller-manager-6bcdd59c8d-mrwpg 1/1 Running 0 15h
四、注册集群,使用pull的方式(在member集群会部署agent) # 查看已经注册的集群 root@JCPT-T-005:~# kubectl --kubeconfig /etc/karmada/karmada-apiserver.config get cluster No resources found # 在member集群执行注册命令 karmadactl register 172.1.19.129:32444 \ --discovery-token-ca-cert-hash sha256:ef3a8343a6fa00417e902b96e743847983c9b25c2d3b199658c65fd4851ac055 \ --ca-cert-path='/etc/karmada/pki/ca.crt' \ --cert-expiration-seconds=315360000 \ --cluster-name='k8s-cilium' \ --cluster-namespace='karmada-cluster' \ --context='kubernetes-admin@k8s-cilium' \ --discovery-timeout=5m0s \ --enable-cert-rotation=true \ --karmada-agent-image='docker.io/karmada/karmada-agent:v1.4.1' \ --karmada-agent-replicas=1 \ --namespace='karmada-cluster' \ --token o5o907.tgauc4tsr619um9a # 需要提前将karmada-apiserver.config文件复制到member集群:/etc/karmada/karmada-apiserver.config
# 查看注册的集群
root@JCPT-T-005:~# kubectl --kubeconfig /etc/karmada/karmada-apiserver.config get clusters
NAME VERSION MODE READY AGE
k8s-cilium v1.19.8 Pull True 13m