安装
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
kubectl version --client
搭建环境
修改hostname
#k8s-master
radish ➜ ~ cat /etc/hostname
k8s-masterradish
➜ ~ cat /etc/hosts | grep k8s
10.211.55.7 k8s-master
10.211.55.9 k8s-worker
#k8s-wirker
❯ cat /etc/hostname
k8s-worker
~❯ cat /etc/hosts | grep k8s
10.211.55.7 k8s-master
10.211.55.9 k8s-worke
禁用交换分区
~ cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda1 during installation
UUID=25559f82-b8b2-4983-9223-ff1c2cb36099 / ext4 errors=remount-ro 0 1
#/swapfile none swap sw 0 0
安装kubelet kubeadm kubectl
先是更新源
然后复制到
/usr/share/keyrings/kubernetes-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] http://mirrors.ustc.edu.cn/kubernetes/apt kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubelet kubeadm kubectl
master操作
生成初始化文件
kubeadm config print init-defaults > kubeadm-init.yaml
kubeadm init --config kubeadm-init.yaml
kubeadm join 10.211.55.7:6443 --token abcdef.0123456789abcdef \
--discovery-token-ca-cert-hash sha256:c181874c3695bba453a696928392bfc7b40cdf90f0d105f24f2d057305b320ae