kubernetes-v1.12.2环境安装
程序员文章站
2022-03-01 17:25:02
...
参考版本:
Centos 7.6
kubernetes-v1.12.2
参考官方文档:
Creating a single master cluster with kubeadm
准备
设置SELinux模式为Permissive
setenforce 0
sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
关闭Swap
检查Swap是否启用
cat /proc/meminfo | grep Swap
关闭Swap
swapoff -a
删除/etc/fstab中swap相关的内容,并重新mount
mount -a
关闭firewalld
systemctl stop firewalld
systemctl disable firewalld
安装kubeadm
新增yum repository
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOF
注:官方文档中exclude=kube*
行需要删除
更新yum cache (如果需要)
yum clean all && yum makecache fast
获取可安装的版本列表
yum --showduplicates list kubeadm
安装kubeadm,kubelet,kubectl
(以1.12.2为例)
yum install kubeadm-1.12.2-0 kubelet-1.12.2-0 kubectl-1.12.2-0
配置服务
systemctl enable kubelet.service
检查安装
kubeadm version
kubectl version
kubelet --version
安装master节点
下载镜像(可以跳过。如果跳过,将在init时下载)
(以1.12.2为例)
kubeadm config images pull --kubernetes-version=v1.12.2
初始化Master
(以1.12.2为例)
kubeadm init --pod-network-cidr=10.244.0.0/16 --kubernetes-version=v1.12.2
输出结果
Your Kubernetes master 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
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/
You can now join any number of machines by running the following on each node
as root:
kubeadm join 192.168.3.101:6443 --token uuduxx.3x2h3dw8vogwb0eo --discovery-token-ca-cert-hash sha256:ca2a9bca1621f9bc25667832f7823f3e3fef68c220ed55104599803bfcbc8071
复制kubectl连接配置
mkdir ~/.kube
cp /etc/kubernetes/admin.conf ~/.kube/config
检查安装
kubectl get nodes
安装Minion节点
下载镜像(可以跳过。如果跳过,将在init时下载)
(以1.12.2为例)
kubeadm config images pull --kubernetes-version=v1.12.2
初始化Minion节点
需要根据kubeadm init的输出修改
kubeadm join 192.168.3.101:6443 --token uuduxx.3x2h3dw8vogwb0eo --discovery-token-ca-cert-hash sha256:ca2a9bca1621f9bc25667832f7823f3e3fef68c220ed55104599803bfcbc8071
检查安装
kubectl get nodes
安装flannel
下载flannel部署文件
wget https://raw.githubusercontent.com/coreos/flannel/bc79dd1505b0c8681ece4de4c0d86c5cd2643275/Documentation/kube-flannel.yml
修改配置文件(暂不需要修改)
部署
kubectl apply -f kube-flannel.yml
上一篇: ubuntu下安装微信小程序开发工具