发布时间: 2023-6-15 文章作者: myluzh 分类名称: Kubernetes 朗读文章
hostnamectl set-hostname master hostnamectl set-hostname node1 hostnamectl set-hostname node2
vim /etc/hosts 10.206.0.7 master 10.206.0.15 node1 10.206.0.11 node2
setenforce 0 sed -i --follow-symlinks 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
systemctl status firewalld systemctl stop firewalld systemctl disable firewalld
cat <<EOF > kubernetes.repo [kubernetes] name=Kubernetes baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64 enabled=1 gpgcheck=0 repo_gpgcheck=0 gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg EOF mv kubernetes.repo /etc/yum.repos.d/
yum -y install yum-utils yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install -y kubelet-1.22.4 kubectl-1.22.4 kubeadm-1.22.4 docker-ce
systemctl enable kubelet systemctl start kubelet systemctl enable docker systemctl start docker
cat <<EOF > daemon.json { "exec-opts": ["native.cgroupdriver=systemd"], "registry-mirrors": ["https://ud6340vz.mirror.aliyuncs.com"] } EOF mv daemon.json /etc/docker/
systemctl daemon-reload systemctl restart docker
kubeadm init --image-repository=registry.aliyuncs.com/google_containers
mkdir -p $HOME/.kube cp -i /etc/kubernetes/admin.conf $HOME/.kube/config chown $(id -u):$(id -g) $HOME/.kube/config# 在其他机器上创建 ~/.kube/config 文件也能通过 kubectl 访问到集群
kubeadm join 10.206.0.7:6443 --token xxx --discovery-token-ca-cert-hash xxx
[root@master ~]# kubectl get node NAME STATUS ROLES AGE VERSION master NotReady control-plane,master 15m v1.22.4 node1 NotReady <none> 2m52s v1.22.4 node2 NotReady <none> 104s v1.22.4
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
kubectl apply -f https://github.com/weaveworks/weave/releases/download/v2.8.1/weave-daemonset-k8s.yaml kubectl apply -f http://static.corecore.cn/weave.v2.8.1.yaml
标签: k8s kubeadm kubernetes
发表评论