k8s Kubernetes v1.10.0 集群安装以及踩坑过程

2023-04-14 00:33:00 集群 过程 安装

.

k8s Kubernetes v1.10.0 集群安装以及踩坑过程

1. 安装依赖

yum -y install epel-release

yum -y install bash-completion net-tools vim wget curl

2. 关闭 SELinux

setenforce 0

sed -i 's/^SELINUX=enforcing$/SELINUX=disabled/' /etc/selinux/config

3. 关闭防火墙

systemctl disable firewalld

systemctl stop firewalld

4. 安装 docker-ce

yum install -y yum-utils

yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

yum makecache fast

yum -y install docker-ce

systemctl enable docker

systemctl start docker

5. 安装 kubelet kubeadm kubectl

cat < /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

setenforce 0

yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes

systemctl enable kubelet

systemctl start kubelet

6. 配置主机名

hostnamectl set-hostname master

7. 初始化 kubernetes 集群

kubeadm init --pod-network-cidr=10.244.0.0/16 --service-cidr=10.96.0.0/12

8. 配置 kubectl

mkdir -p $HOME/.kube

cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

chown $(id -u):$(id -g) $HOME/.kube/config

9. 安装 pod 网络

kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

10. 安装完成

kubectl get pods --all-namespaces

11. 验证集群

kubectl run nginx --image=nginx

kubectl get pods

12. 部署dashboard

kubectl create -f https://raw.githubusercontent.com/kubernetes/dashboard/master/aio/deploy/recommended/kubernetes-dashboard.yaml

kubectl proxy

相关文章