K8S Getting Started: 1. Getting Started Installation

First prepare a virtual machine, install CentOS7 and above systems

The following officially starts

  1. The first step is to update the yum source and install Docker
更新
yum update -y && yum install -y   containerd.io-1.2.13   docker-ce-19.03.8   docker-ce-cli-19.03.8

安装
yum install docker

启动
 systemctl enable docker && systemctl start docker
  1. The second step is to disable the firewall, etc.
禁用防火墙
systemctl disable firewalld && systemctl stop firewalld

禁用selinux
vi /etc/selinux/config
SELINUX=disabled

关闭swapoff
swapoff -a

注释掉配置文件中的swap
vi /etc/fstab

  1. The third step is to set up k8s mirror source and installation
设置k8s配置文件
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
EOF

安装k8s相关工具
yum install -y kubelet-1.14.0 kubeadm-1.14.0 kubectl-1.14.0 --disableexcludes=kubernetes

启动kubelet
systemctl enable kubelet && systemctl start kubelet
  1. The fourth step is to generate k8s configuration file
生成配置文件
kubeadm config print init-defaults > init.default.yaml

通过生成出来的文件再创建一个简洁的文件
cp init.default.yaml init.config.yaml

文件内容
apiVersion: kubeadm.k8s.io/v1beta1
imageRepository: registry.aliyuncs.com/google_containers
kind: ClusterConfiguration
kubernetesVersion: v1.14.0
networking:
  podSubnet: "192.168.0.0/16"
  1. Download image, install k8s
下载镜像
kubeadm config images pull --config=init.config.yaml 

安装k8s
kubeadm init --config=init.config.yaml

成功,根据提示执行下面的三条命令
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
Published 38 original articles · praised 17 · views 8993

Guess you like

Origin blog.csdn.net/cainiao1412/article/details/105604526