该篇文章结合了网络上零散的的资料整理出来的,亲测可用有效,有问题欢迎大家可以提出来
1永久禁用swap分区,注释掉/etc/fstab中swap那一行
sudo vim /etc/fstab
2 关闭防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service
setenforce 0
3 kubelet安装与启动
执行命令
1:
cat < /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF
2:
yum install -y kubelet kubeadm kubectl
4、创建初始化配置文件init.yml
apiVersion: kubeadm.k8s.io/v1alpha3
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
pod-infra-container-image: registry.aliyuncs.com/google_containers/pause-amd64:3.1
apiVersion: kubeadm.k8s.io/v1alpha3
kind: ClusterConfiguration
imageRepository: registry.aliyuncs.com/google_containers
kubernetesVersion: v1.13.2
networking:
podSubnet: 10.244.0.0/16
5、初始化集群
正常日志显示如下
kubeadm init --config init.yml
[init] Using Kubernetes version: v1.13.2
[preflight] Running pre-flight checks
[WARNING Hostname]: hostname “dev-k8s” could not be reached
[WARNING Hostname]: hostname “dev-k8s”: lookup dev-k8s on 192.168.12.6:53: server misbehaving
[preflight] Pulling images required for setting up a Kubernetes cluster
[preflight] This might take a minute or two, depending on the speed of your internet connection
[preflight] You can also perform this action in beforehand using ‘kubeadm config images pull’
[kubelet-start] Writing kubelet environment file with flags to file “/var/lib/kubelet/kubeadm-flags.env”
[kubelet-start] Writing kubelet configuration to file “/var/lib/kubelet/config.yaml”
[kubelet-start] Activating the kubelet service
[certs] Using certificateDir folder “/etc/kubernetes/pki”
[certs] Generating “ca” certificate and key
[certs] Generating “apiserver” certificate and key
[certs] apiserver serving cert is signed for DNS names [dev-k8s kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 192.168.12.149]
[certs] Generating “apiserver-kubelet-client” certificate and key
[certs] Generating “front-proxy-ca” certificate and key
[certs] Generating “front-proxy-client