kubeadm安装Kubernetes实践过程

2023-04-14 00:50:00 过程 实践 安装

kubeadm安装Kubernetes实践过程

1、下载安装包

在官网下载安装包,我这里下载的是v1.11.3。

2、安装依赖包

yum install -y yum-utils device-mapper-persistent-data lvm2

3、设置yum源

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

4、安装Docker

yum install docker-ce

5、启动Docker

systemctl start docker

6、配置防火墙

firewall-cmd --permanent --add-port=6443/tcp firewall-cmd --permanent --add-port=2379-2380/tcp firewall-cmd --permanent --add-port=10250/tcp firewall-cmd --permanent --add-port=10251/tcp firewall-cmd --permanent --add-port=10252/tcp firewall-cmd --reload

7、关闭SELinux

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

8、下载并安装Kubernetes

curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl chmod +x ./kubectl mv ./kubectl /usr/local/bin/kubectl curl -Lo kubeadm https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubeadm chmod +x ./kubeadm mv ./kubeadm /usr/local/bin/kubeadm

9、启动master节点

kubeadm init --pod-network-cidr=10.244.0.0/16

10、配置kubelet

vim /etc/systemd/system/kubelet.service.d/10-kubeadm.conf Environment="KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf" Environment="KUBELET_CONFIG_ARGS=--config=/var/lib/kubelet/config.yaml"

11、启动kubelet

systemctl daemon-reload systemctl restart kubelet systemctl enable kubelet

12、配置集群网络

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

13、启动dashboard

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

14、创建dashboard用户

kubectl create serviceaccount dashboard -n default kubectl create clusterrolebinding dashboard-admin -n default --clusterrole=cluster-admin --serviceaccount=default:dashboard

15、获取dashboard用户的token

kubectl get secrets -n default | grep dashboard-token

输出类似于:

dashboard-token-x5v6k

16、登录dashboard

kubectl proxy

访问:http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/

点击“登录”,选择“Token”,在“令牌”中输入上一步获取的token,点击“登录”即可。

相关文章