赞
踩
wget https://github.com/kubesphere/kubekey/releases/download/v3.1.5/kubekey-v3.1.5-linux-amd64.tar.gz
tar -xf kubekey-v*-linux-amd64.tar.gz -C /usr/local/bin
echo "export PATH=$PATH:/usr/local/bin/kk" >> ~/.bashrc
source ~/.bashrc
echo "source <(kk completion -t bash)" >> ~/.bashrc
source ~/.bashrc
示例:
kk create config --name config-cluster-example
# 会生成一个config-cluster-example.yaml的配置文件
vim config-cluster-example.yaml
apiVersion: kubekey.kubesphere.io/v1alpha2 kind: Cluster metadata: name: config-cluster-example spec: hosts: #配置集群的所有node信息,name是node的主机名,会自动把节点主机名改为name的值,address是节点ip,internalAddress是节点内网ip,user和password是登陆节点的用户名和密码,如果配置了ssh密钥登陆,可以删除user和password字段。 - {name: node1, address: 172.16.0.2, internalAddress: 172.16.0.2, user: ubuntu, password: "Qcloud@123"} - {name: node2, address: 172.16.0.3, internalAddress: 172.16.0.3} roleGroups: # 指定节点的身份 etcd: - node1 control-plane: - node1 worker: - node1 - node2 controlPlaneEndpoint: ## Internal loadbalancer for apiservers # internalLoadbalancer: haproxy domain: lb.kubesphere.local # apiServer监听的域名,默认即可 address: "172.16.0.2" # apiServer监听的ip,需要自己指定 port: 6443 # apiServer监听的端口号,默认即可 kubernetes: version: v1.23.15 # 需要安装的集群版本,没有需求默认即可 clusterName: cluster.local autoRenewCerts: true containerManager: docker etcd: type: kubekey network: plugin: calico kubePodsCIDR: 10.233.64.0/18 kubeServiceCIDR: 10.233.0.0/18 ## multus support. https://github.com/k8snetworkplumbingwg/multus-cni multusCNI: enabled: false registry: privateRegistry: "" namespaceOverride: "" registryMirrors: [] insecureRegistries: [] addons: []
# 所有node都需要执行
apt install -y socat ipset conntrack chrony ipvsadm ebtables
kk create cluster -yf config-cluster-example.yaml
# 命令自动补全
echo "source <(kubectl completion bash)" >> ~/.bashrc
source ~/.bashrc
kk delete cluster <clusterName>
kk version
kk upgrade -y --with-kubernetes <version> <clusterName> 或
kk upgrade -y -f <config>.yaml # 推荐
kk delete node <nodeName>
kk add -y nodes <nodeName>或
kk add -y nodes -f <config>.yaml # 推荐
mkdir -p .kube/config
scp root@<master>:/etc/kubernetes/admin.conf ~/.kube/config # 从master上拷贝 集群管理员的权限
echo "export KUBECONFIG=.kube/config/admin.conf" >> .bashrc
source .bashrc
# KubeKey 默认不会启用 kubectl 自动补全功能。
# 将 completion 脚本添加到你的 ~/.bashrc 文件
echo "source <(kubectl completion bash)" >> ~/.bashrc
source ~/.bashrc
# 将 completion 脚本添加到 /etc/bash_completion.d 目录
kubectl completion bash >/etc/bash_completion.d/kubect
例如 --with-kubesphere v3.1.0
kk create config --with-kubesphere --name <clusterName>
例如 --with-kubesphere v3.1.0
kk create cluster --with-kubesphere v3.1.0
kk create config --from-cluster cluster1 -f cluster2.yaml
可选:docker, crio, containerd and isula
kk create cluster --container-manager <container_runtime> -f <config>.yaml
kk version --show-supported-k8s
kubectl apply -f https://github.com/kubesphere/ks-installer/releases/download/v3.4.1/kubesphere-installer.yaml
kubectl apply -f https://github.com/kubesphere/ks-installer/releases/download/v3.4.1/cluster-configuration.yaml
kubectl delete --force -f https://github.com/kubesphere/ks-installer/releases/download/v3.4.1/kubesphere-installer.yaml
kubectl delete --force -f https://github.com/kubesphere/ks-installer/releases/download/v3.4.1/cluster-configuration.yaml
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。