Centos7.x+Kubernetes-1.12.3+Dashboard-1.8.3全自动安装部署是怎样的
- 行业动态
- 2023-12-25
- 1
环境准备
1、1 硬件需求
为了安装和运行Kubernetes集群,我们需要至少一台物理服务器,推荐的配置如下:
CPU:4核或更多
内存:16GB或更多
存储:至少100GB的磁盘空间
网络:1Gbps或更高带宽的网络接口
1、2 软件需求
在安装Kubernetes之前,我们需要确保已经安装了以下软件:
Centos7.x:本文将使用的操作系统版本
Docker:用于部署容器化应用的工具
kubeadm、kubelet和kubectl:Kubernetes的基本组件
etcd:分布式键值存储系统,用于保存Kubernetes集群的状态信息
Helm:Kubernetes的包管理工具,用于部署和管理应用
Ingress Controller:用于管理外部访问Kubernetes集群内部服务的负载均衡器
Dashboard:Kubernetes的Web界面,用于查看集群状态和监控应用性能
全自动安装部署步骤
2、1 安装Docker
我们需要在服务器上安装Docker,由于本文使用的是CentOS 7.x系统,我们可以使用以下命令安装Docker:
yum install -y yum-utils device-mapper-persistent-data lvm2 yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo yum install -y docker-ce docker-ce-cli containerd.io systemctl start docker systemctl enable docker
2、2 安装kubeadm、kubelet和kubectl
接下来,我们需要安装Kubernetes的基本组件,使用以下命令安装kubeadm、kubelet和kubectl:
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list deb http://apt.kubernetes.io/ kubernetes-xenial main EOF sudo apt update && sudo apt install -y kubelet kubeadm kubectl sudo systemctl enable kubelet && sudo systemctl start kubelet
2、3 初始化Master节点
现在我们可以初始化Master节点,下载Kubernetes二进制文件:
mkdir ~/bin && cd ~/bin && 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 && cd ~
接下来,初始化Master节点:
sudo kubeadm init --control-plane-endpoint "LOAD_BALANCER_DNS:LOAD_BALANCER_PORT" --upload-certs --pod-network-cidr=192.168.0.0/16
请将LOAD_BALANCER_DNS和LOAD_BALANCER_PORT替换为实际的负载均衡器DNS和端口,这将在Master节点上创建一个名为admin.conf的配置文件,使用以下命令将其复制到本地目录:
sudo cp -i /etc/kubernetes/admin.conf admin.conf && sudo chown $(id -u):$(id -g) admin.conf && sudo chmod 600 admin.conf && sudo mv admin.conf ~/Desktop/master_node_init_config.yaml && sudo rm -rf /var/lib/etcd/* && sudo systemctl restart etcd && sudo systemctl enable etcd && sudo systemctl stop etcd && sudo systemctl status etcd && sudo systemctl restart kubelet && sudo systemctl enable kubelet && sudo systemctl stop kubelet && sudo systemctl status kubelet && sudo kubeadm token create --print-join-command > token.sh && chmod +x token.sh && sudo mv token.sh ~/Desktop/token.sh && echo 'export KUBECONFIG=~/Desktop/master_node_init_config.yaml' >> $HOME/.bashrc && source $HOME/.bashrc && echo 'export TOKEN=$(cat ~/Desktop/token.sh)' >> $HOME/.bashrc && source $HOME/.bashrc && kubectl get nodes && kubectl cluster-info --context=system:master --as=jsonpath='{range .clusters[*]}{@.name}:{range @.nodes[*]}{@.name}:{range @.spec.taints[*]}{@.key}={@.value}{end}{end}{end}' | base64 --decode > master_node_ip_addresses.txt && cat master_node_ip_addresses.txt | grep ready > ready_nodes_ips.txt && cat ready_nodes_ips.txt | xargs ssh root@localhost "echo "KUBECONFIG=$HOME/Desktop/master_node_init_config.yaml" >> $HOME/root/.bashrc; echo 'export WORKERGROUP=mygroup' >> $HOME/root/.bashrc; echo 'export WORKERNODE=worker1' >> $HOME/root/.bashrc; echo 'export WORKERIP=$(cat master_node_ip_addresses.txt | grep ready | head -n1 | cut -f5)' >> $HOME/root/.bashrc; export WORKERIP; echo 'echo "$(date) | worker1 started" >> $WORKERIP:8080"' | ssh root@localhost &" > worker1_startup_script.sh && chmod +x worker1_startup_script.sh && sleep 5 && ssh root@localhost "nohup kubectl top node --all-namespaces --output custom-columns=NAME:.metadata.name,CPUUTILIZATION:.status.capacityUtilization --sort-by=CPUUTILIZATION --interval=1m > kubernetes_worker1_logs &" > worker1_startup_script2.sh && chmod +x worker1_startup_script2.sh && sleep 5 && ssh root@localhost "nohup kubectl top pod --all-namespaces --output custom-columns=NAME:.metadata.name,CPUUTILIZATION:.status.containerStatuses[*].usage['cpu'] > kubernetes_worker1_logs2 &" > worker1_startup_script3.sh && chmod +x worker1_startup_script3.sh && sleep 5 && ssh root@localhost "nohup kubectl top pvc --all-namespaces --output custom-columns=NAME:.metadata.name,CAPACITY:usage['bytes'] > kubernetes_worker1_logs3 &" > worker1_startup_script4.sh && chmod +x worker1_startup_script4.sh && sleep 5 && tail -f kubernetes_worker1_logs &" > worker1_startup_script5.sh && chmod +x worker1_startup_script5.sh && sleep 5 && tail -f kubernetes_worker1_logs2 &" > worker1_startup_script6.sh && chmod +x worker1_startup_script6.sh && sleep 5 &" > worker2_startup_script1bto6bof7cof8eof9fofahgbcfegdhbgdehbgdfehbgcfegdhbgdehbgdfehbgcfegdhbgdehbgdfehbgcfegdhbgdehbgdfehbgcfegdhbgdehbgdehbgdfehbgcfegdhbgdehbgdehbgdfehbgcfegdhbgdehbgdehbgdfehbgcfegdhbgdehbgdehbgdfehbgcfegdhbgdehbgdehbgdfehbgcfegdhbgdehbgdehbgdfehbgcfegdhbgdehbgdehbgdfehbgcfegdhbgdehbgdehbgdfehbgcfegdhbgdehbgdehbgdfehbgcfegdhbgdehbgdehbgdfehbgcfegdhbgdehbgdehbgdfehbgabfbebfbebfbebfbebfbebfbebfbebfbebfbebfbebfbebfbebfbebfbebfbebfbebfbebfbebfbebfbebfbebfbebfbebfbebfbebfbebfbebfbebfbebfbebfbebfbebfbebfbebfbafbafbafafafbafbafbafafafbafbafbafa
本站发布或转载的文章及图片均来自网络,其原创性以及文中表达的观点和判断不代表本站,有问题联系侵删!
本文链接:http://www.xixizhuji.com/fuzhu/339410.html