标签:完成 googl 总结 core any 准备 如何 app com
安装kubenetes的方法有多种,本文将介绍如何用kubeadm安装kubernetes。
一 node准备
1 /etc/hosts文件
192.168.235.133 kube01 192.168.235.134 kube02 192.168.235.135 kube03
2 关闭swap
swapoff -a
注释/etc/fstab中的swap挂载
#/dev/mapper/centos-swap swap swap defaults 0 0
3 修改内核参数
cat <<EOF > /etc/sysctl.d/k8s.conf net.bridge.bridge-nf-call-ip6tables = 1 net.bridge.bridge-nf-call-iptables = 1 EOF sysctl --system
4 安装docker
yum install docker -y systemctl enable docker systemctl start docker
二 安装kubeadm
1 增加yum的repo
cat <<EOF > /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
2 安装
setenforce 0 yum install -y kubelet kubeadm kubectl systemctl enable kubelet && systemctl start kubelet
三 用kubeadm安装kubenetes集群
1 用kubeadm初始化
在master节点运行:
kubeadm init > --pod-network-cidr=10.244.0.0/16 > --apiserver-advertise-address=192.168.235.133
安装完成:
Your Kubernetes master has initialized successfully! To start using your cluster, you need to run the following as a regular user: mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/config You should now deploy a pod network to the cluster. Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at: https://kubernetes.io/docs/concepts/cluster-administration/addons/ You can now join any number of machines by running the following on each node as root: kubeadm join 192.168.235.133:6443 --token 8ojndu.qaow6tuo95psar5g --discovery-token-ca-cert-hash sha256:79c955c758bd76f02335c33540f3880039bcf9aa137c9b67366a990ccefbaead
2 安装Pod netwok
mkdir -p ~/k8s/ cd ~/k8s wget https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml kubectl apply -f kube-flannel.yml
3 将node2和node3加入到集群中
kubeadm join 192.168.235.133:6443 --token 8ojndu.qaow6tuo95psar5g --discovery-token-ca-cert-hash sha256:79c955c758bd76f02335c33540f3880039bcf9aa137c9b67366a990ccefbaead
在master节点上观察:
[root@kube01 k8s]# kubectl get nodes NAME STATUS ROLES AGE VERSION kube01 Ready master 23m v1.10.2 kube02 Ready <none> 5m v1.10.2 kube03 Ready <none> 5m v1.10.2
总结:
使用kubeadm可以方便的安装kubernetes集群。
标签:完成 googl 总结 core any 准备 如何 app com
原文地址:https://www.cnblogs.com/hengwei/p/9066545.html