一、准备centos7环境,可上互联网,以下为基础配置,每一台均执行
ssh-keygen -t rsa
ssh-copy-id 主机名
systemctl stop firewalld
systemctl disable firewalld
sed -i 's/enforcing/disabled/' /etc/selinux/config
setenforce 0
sed -i 's/.*swap.*/#&/' /etc/fstab
swapoff -a
hostnamectl set-hostname k8s-master
hostnamectl set-hostname k8s-node1
hostnamectl set-hostname k8s-node1
cat >> /etc/hosts <<EOF
192.168.2.8 k8s-master
192.168.2.59 k8s-node1
192.168.2.86 k8s-node2
192.168.2.8 apiserver.demo
EOF
二、安装kubelet
export REGISTRY_MIRROR=https://registry.cn-hangzhou.aliyuncs.com
curl -sSL https://kuboard.cn/install-script/v1.19.x/install\_kubelet.sh | sh -s 1.19.5
```bash
三、其中一个master节点执行集群初始化
```bash
export MASTER_IP=192.168.2.8
export APISERVER_NAME=apiserver.demo
export POD_SUBNET=10.100.0.1/16
curl -sSL https://kuboard.cn/install-script/v1.19.x/init\_master.sh | sh -s 1.19.5
此命令会返回其他节点接入到集群的命令
四、其他master节点加入集群
kubeadm join apiserver.demo:6443 --token bphtmu.cplm6qphq73p19hd --discovery-token-ca-cert-hash sha256:194450249fabbbadc5119c99df4d444dba8a9f750751e19af2d144c820fb2363 --control-plane --certificate-key 0881e00971310ff7f2205c0ced5c87578287f5a86d3da64a7009b092b5cf7c2a
五、其他node节点接入集群
kubeadm join apiserver.demo:6443 --token bphtmu.cplm6qphq73p19hd --discovery-token-ca-cert-hash sha256:194450249fabbbadc5119c99df4d444dba8a9f750751e19af2d144c820fb2363
六、检查安装情况
kubectl get nodes
kubectl get nodes -o wide
kubectl get pod
kubectl get pod -A
kubectl get pod -n kube-system -o wide
七、根据情况开关可调度到master
允许调度到k8s-master
kubectl taint node k8s-master node-role.kubernetes.io/master-
禁止调度到k8s-master
kubectl taint node k8s-master node-role.kubernetes.io/master="":NoSchedule
八、测试创建容器
kubectl run net-test1 --image=alpine sleep 360000
kubectl get pod -o wide
kubectl exec -it net-test1 sh
ping 10.100.36.65
ping www.baidu.com
标签:node,kubectl,get,--,安装,master,k8s,快速
From: https://www.cnblogs.com/tanll/p/17759072.html