Centos8 使用kubeadm部署k8s集群
趁着春节体验了把Centos8,用着感觉和7没有太大变化,由于重新安装了Centos8,以前配置的k8s环境要重新配置了,在Centos8上配置docker和k8s遇到了不少坑,记录一下部署过程。卸载podman,centos8默认安装了podman容器,它和docker有冲突需要卸载掉yum delete podman配置yum国内镜像https://blog.csdn.net/...
趁着春节体验了把Centos8,用着感觉和7没有太大变化,由于重新安装了Centos8,以前配置的k8s环境要重新配置了,在Centos8上配置docker和k8s遇到了不少坑,记录一下部署过程。
卸载podman,centos8默认安装了podman容器,它和docker有冲突需要卸载掉
yum delete podman
配置yum国内镜像
https://blog.csdn.net/wohendatou/article/details/102028632 参考
vim /etc/hostname 修改主机名k8sserver
关闭防火墙
systemctl disable firewalld
systemctl stop firewalld
关闭selinux
vim /etc/selinux/config 如下
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
setenforce 0
关闭swap
swapoff -a
vim /etc/fstab 注释掉swap项
/dev/mapper/cl_zhangqiang-root / xfs defaults 0 0
UUID=bbb5a6be-17cd-4c28-8772-7bf5416ab16f /boot ext4 defaults 1 2
/dev/mapper/cl_zhangqiang-home /home xfs defaults 0 0
#/dev/mapper/cl_zhangqiang-swap swap swap defaults 0 0
配置docker安装国内yum源
先安装yum-utils,centos8默认没有安装这个库,否则无法使用yum-config-manager命令。
yum install yum-utils
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
安装docker
yum install docker-ce 安装最新版,也可以根据需要指定版本。
配置docker 国内yum源
vim /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
安装kubeadm、kubectl、kubelet
yum install -y kubelet kubeadm kubectl
启动kubelet服务
systemctl enable kubelet
systemctl start kubelet
初始化kubernetes集群
kubeadm init \
--apiserver-advertise-address=当前机器的IP \
--image-repository registry.aliyuncs.com/google_containers \
--kubernetes-version v1.17.2 \
--pod-network-cidr=10.244.0.0/16
配置集群配置文件
mkdir -p $HOME/.kube
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
chown $(id -u):$(id -g) $HOME/.kube/config
等待一段时间集群安装完成。
安装网络插件flannel(网络插件有很多)
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
查看集群状态
NAME STATUS ROLES AGE VERSION
zhangqiang Ready master 73m v1.17.2
kube-system pod状态
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
coredns-9d85f5447-756wh 1/1 Running 1 74m 10.244.0.5 zhangqiang <none> <none>
coredns-9d85f5447-c4gsf 1/1 Running 1 74m 10.244.0.4 zhangqiang <none> <none>
etcd-zhangqiang 1/1 Running 5 75m 192.168.124.134 zhangqiang <none> <none>
kube-apiserver-zhangqiang 1/1 Running 5 75m 192.168.124.134 zhangqiang <none> <none>
kube-controller-manager-zhangqiang 1/1 Running 5 75m 192.168.124.134 zhangqiang <none> <none>
kube-flannel-ds-amd64-h8g62 1/1 Running 1 63m 192.168.124.134 zhangqiang <none> <none>
kube-proxy-cjss4 1/1 Running 5 74m 192.168.124.134 zhangqiang <none> <none>
kube-scheduler-zhangqiang 1/1 Running 5 75m 192.168.124.134 zhangqiang <none> <none>
kubernetes 单机集群部署完成........
更多推荐
所有评论(0)