kubeadm安装最新版K8S

一、初始化


sudo yum install -y yum-utils
sudo yum-config-manager \
--add-repo \
https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i -re '/^\s*SELINUX=/s/^/#/' -e '$i\\SELINUX=disabled'  /etc/selinux/config
swapoff -a
sed -i 's/.*swap.*/#&/' /etc/fstab


echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf

cat <<EOF >  /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl --system

二、安装docker

​​​​​​​yum install docker-ce

修改/etc/docker/daemon.json文件
{
 "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"],
  "exec-opts": ["native.cgroupdriver=systemd"]

}

systemctl start docker.service
systemctl enable docker.service

三、安装kubeadm

cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg


yum install -y kubelet kubeadm kubectl
systemctl enable kubelet
systemctl start kubelet

四、初始化

kubeadm init --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=192.168.207.133 --service-cidr=10.96.0.0/12 --ignore-preflight-errors=Swap --image-repository registry.aliyuncs.com/google_containers

初始化成功返回结果

Your Kubernetes control-plane has initialized successfully!

To start using your cluster, you need to run the following as a regular user:

  mkdir -p $HOME/.kube
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  sudo chown $(id -u):$(id -g) $HOME/.kube/config

Alternatively, if you are the root user, you can run:

  export KUBECONFIG=/etc/kubernetes/admin.conf

You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
  https://kubernetes.io/docs/concepts/cluster-administration/addons/

Then you can join any number of worker nodes by running the following on each as root:

kubeadm join 192.168.207.133:6443 --token vtulbn.0awdx1n9h977qt17 \
    --discovery-token-ca-cert-hash sha256:2d849e3dccefc1c624be7670a371794ed7cad0fc0d4f11e8c7ccfe9a3b32dcfd 

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

五、安装网络插件

wget https://docs.projectcalico.org/v3.20/manifests/calico.yaml --no-check-certificate
grep image calico.yaml 
sed -i 's/docker.io/quay.io/g' calico.yaml 
grep image calico.yaml 
kubectl apply -f calico.yaml 

六、node节点加入集群

yum -y install kubelet kubeadm # node 上安装

kubeadm join 192.168.207.133:6443 --token vtulbn.0awdx1n9h977qt17 \
    --discovery-token-ca-cert-hash sha256:2d849e3dccefc1c624be7670a371794ed7cad0fc0d4f11e8c7ccfe9a3b32dcfd

七、kubectl命令补全

yum -y install bash-completion
source /usr/share/bash-completion/bash_completion

source <(kubectl completion bash)
echo "source <(kubectl completion bash)" >> ~/.bashrc 

八、部署metrics-server

metrics-serveryaml文件-kubernetes文档类资源-CSDN下载

下载完成后kubectl apply -f metrics-server.yaml

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值