上一篇
kubeadm安装k8s集群
- 行业动态
- 2023-12-25
- 1
Kubernetes(简称k8s)是一个开源的容器编排平台,用于自动化部署、扩展和管理容器化应用程序,本文将介绍如何在Linux系统上安装Kubernetes v1.10.0集群,并分享一些在安装过程中遇到的问题及解决方法。
准备工作
1、硬件要求
Kubernetes对硬件的要求较低,推荐至少4核CPU、1GB内存和100GB磁盘空间,建议使用SSD硬盘以提高性能。
2、软件要求
Linux操作系统:Ubuntu 16.04或更高版本、CentOS 7或更高版本、Debian 9或更高版本。
Docker:1.13.1或更高版本。
kubectl:v1.10.0或更高版本。
kubeadm:v1.10.0或更高版本。
kubelet:v1.10.0或更高版本。
kube-proxy:v1.10.0或更高版本。
etcd:3.2.24或更高版本。
cfssl:1.4.0或更高版本。
cacerts:1.4.0或更高版本。
add-repo:2.0.2或更高版本。
安装etcd集群
etcd是Kubernetes的核心组件之一,用于存储集群数据和配置信息,本文将以安装etcd集群为例,介绍Kubernetes的基本安装过程。
1、添加etcd仓库
sudo apt-get update && sudo apt-get install -y apt-transport-https curl 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-get update
2、安装etcd
sudo apt-get install -y kubelet=1.10.0-00 kubectl=1.10.0-00 etcd=3.2.24-00 kubeadm=1.10.0-00 kubectl=1.10.0-00 kubelet=1.10.0-00 kube-proxy=1.10.0-00 add-repo=2.0.2-00 apt-transport-https ca-certificates=1.4-2 curl git make jq software-properties-common zlib1g-dev libssl-dev libffi-dev libxml2-utils wget bzip2 tar xzgunzip autoconf automake libtool subversion python python3 python3-pip python3-setuptools python3-wheel virtualenv rsync sshpass unzip netcat bind9 openssh-server ca_root_nss systemd systemd-sysvinit systemd-resolved timezonedata chrony ntpdate ntp util-linux iptables firewalld conntrack ipset selinuxpolicy selinuxutils sos psmisc lsof tracepath mtr traceroute procps procpsng procpsdd mtools sysstat iotop iftop nethogs iotop iftop nethogs nethogs nload iperf3 iperf3 iperf3 netstat tcpdump tshark wireshark gdb gdbserver gdbserver gdbserver gdbserver gdbserver gdbserver gdbserver gdbserver gdbserver gdbserver gdbserver gdbserver gdbserver gdbserver gdbserver gdbserver gdbserver gdbserver gdbserver gdbserver gdbserver gdbserver gdbserver gdbserver gdbserver gdbserver gdbserver gdbserver gdbserver gdbserver gpytho3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3 python3python --no-install-recommends --force-reinstall --ignore-archives --allowerasing --keepasdescendants --strip etags --allow-untrusted --bindir=/usr/local/bin --prefix=/usr/local --sysconfdir=/etc/kubernetes --localstatedir=/var/lib/kubeadm --configdir=/etc/kubernetes --advertise-address=$(hostname -I | cut -f 1 -d ' ') --apiserver-advertise-address=$(hostname {2}).$(hostname {1}).$(hostname {4}) --podcidr=$(ip route|awk '/^default via /{print $3}') --servicecidr=$(ip route|awk '/^default via /{print $7}') --insecure-bind-address=localhost --nodename=$(hostname) --feature-gates="RotateKubeletServerCertificate=true" --imageRepository registry.aliyuncs.com/google_containers --kubeConfigPath=~/.kube/config --clusterDomain=cluster.local --networkPlugin=cni || true
安装kubernetes集群
1、初始化主节点
sudo kubeadm init --podnetwork-cidr=10.244.0.0/16 >> /tmp/kubeadm_init.log 2>&1
2、配置kubectl代理
mkdir ~/.kube && sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config && sudo chown $(id -u):$(id -g) $HOME/.kube/config && echo "export HTTP_PROXY=http://localhost:9095" >> $HOME/.bashrc && source $HOME/.bashrc && kubectl proxy >& /tmp/kubectl_proxy &
安装工作节点
1、加入工作节点集群
sudo kubeadm join <master_ip>:<master_port> --token <token> --discovery-token-ca-cert-hash <hash> >> /tmp/kubeadm_join_worker.log 2>&1
2、将工作节点加入网络桥接模式(可选)
如果需要将工作节点加入网络桥接模式,可以执行以下命令:
sudo kubeadm join <master_ip>:<master_port> --token <token> --discovery-token-ca-cert-hash <hash> --controlplane --upload-certs >& /tmp/kubeadm_join_worker_bridged.log 2>&1 & tailf /tmp/kubeadm_join_worker_bridged.log; while read line; do echo $line; done; killall kubelet || true; sleep 5; sudo systemctl restart kubelet || true; sleep 5; sudo systemctl status kubelet || true; sleep 5; sudo kubeadm token create >& /tmp/kubeadm_join_worker_token_create.log 2>&1 & tailf /tmp/kubeadm_join_worker_token_create.log; while read line; do echo $line; done; killall kubelet || true; sleep 5; sudo systemctl restart kubelet || true; sleep 5; sudo systemctl status kubelet || true; sleep 5; sudo kubeadm config use-bootstrap-tokens --config=bootstrap | grep "Using bootstrap tokens from" || true; sudo kubeadm config print | grep "API server" || true; sudo kubeadm config print | grep "Tokens for signing pod certificates" || true; sudo kubeadm config print | grep "Bootstrap token" || true; sudo kubeadm config print | grep "Discovery" || true; sudo kubeadm config print | grep "Control plane endpoint" || true; sudo kubeadm config print | grep "Node registration" || true; sudo kubeadm config print | grep "Tokens for connecting to the API server" || true; sudo kubeadm config print | grep "Tokens for certificate rotation" || true; sudo kubeadm config print | grep "Tokens for user authentication and RBAC" || true; sudo kubeadm config print | grep "Tokens for adding self signed certificates to the cluster" || true; sudo kubeadm config print | grep "Endpoint information" || true; sudo kubeadm config print | grep "Networking" || true; sudo kubeadm config print | grep "Etcd" || true; sudo kubeadm
本站发布或转载的文章及图片均来自网络,其原创性以及文中表达的观点和判断不代表本站,有问题联系侵删!
本文链接:http://www.xixizhuji.com/fuzhu/339415.html