首页 > 系统相关 >使用kubeadm在Centos8上部署kubernetes1.18

使用kubeadm在Centos8上部署kubernetes1.18

时间:2023-12-26 13:33:06浏览次数:44  
标签:v1.18 kube kubernetes1.18 yum io kubeadm daocloud docker Centos8

// 查看系统版本
cat /etc/centos-release
CentOS Linux release 8.1.1911 (Core)

// 如果系统环境为8.0(云服务器默认最大安装环境为8.0)使用如下命令进行升级操作
sudo dnf update -y

// 配置网络
cat /etc/sysconfig/network-scripts/ifcfg-enp0s3

// 添加阿里源
rm -rfv /etc/yum.repos.d/*
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo

// 配置主机名
cat /etc/hosts

// 关闭swap,注释swap分区
swapoff -a
cat /etc/fstab

// 配置内核参数,将桥接的IPv4流量传递到iptables的链
cat > /etc/sysctl.d/k8s.conf <<EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl --system

// 安装常用包
yum install vim bash-completion net-tools gcc -y

// 使用aliyun源安装docker-ce
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum -y install docker-ce

// 安装docker-ce如果出现以下错
CentOS-8 - Base - mirrors.aliyun.com 14 kB/s | 3.8 kB 00:00
CentOS-8 - Extras - mirrors.aliyun.com 6.4 kB/s | 1.5 kB 00:00
CentOS-8 - AppStream - mirrors.aliyun.com 16 kB/s | 4.3 kB 00:00
Docker CE Stable - x86_64 40 kB/s | 22 kB 00:00
Error:
Problem: package docker-ce-3:19.03.8-3.el7.x86_64 requires containerd.io >= 1.2.2-3, but none of the providers can be installed

  • cannot install the best candidate for the job
  • package containerd.io-1.2.10-3.2.el7.x86_64 is excluded
  • package containerd.io-1.2.13-3.1.el7.x86_64 is excluded
  • package containerd.io-1.2.2-3.3.el7.x86_64 is excluded
  • package containerd.io-1.2.2-3.el7.x86_64 is excluded
  • package containerd.io-1.2.4-3.1.el7.x86_64 is excluded
  • package containerd.io-1.2.5-3.1.el7.x86_64 is excluded
  • package containerd.io-1.2.6-3.3.el7.x86_64 is excluded
    (try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)

// 解决方法
wget https://download.docker.com/linux/centos/7/x86_64/edge/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm
yum install containerd.io-1.2.6-3.3.el7.x86_64.rpm

// 然后再安装docker-ce即可成功
yum -y install docker-ce

//添加aliyundocker仓库加速器
mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://fl791z1h.mirror.aliyuncs.com"]
}
EOF
systemctl daemon-reload
systemctl restart docker

// 安装kubectl、kubelet、kubeadm
// 添加阿里kubernetes源
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

// 安装
yum install kubectl kubelet kubeadm
systemctl enable kubelet

// 初始化k8s集群
kubeadm init --kubernetes-version=1.18.0
--apiserver-advertise-address=172.21.0.14
--image-repository registry.aliyuncs.com/google_containers
--service-cidr=10.10.0.0/16 --pod-network-cidr=10.122.0.0/16

// 如果出现错误执行入下命令
kubeadm config images list

// 逐个安装
docker pull daocloud.io/daocloud/kube-apiserver:v1.18.3
docker pull daocloud.io/daocloud/kube-controller-manager:v1.18.3
docker pull daocloud.io/daocloud/kube-scheduler:v1.18.3
docker pull daocloud.io/daocloud/kube-proxy:v1.18.3
docker pull daocloud.io/daocloud/pause:3.2
docker pull daocloud.io/daocloud/etcd:3.4.3-0
docker pull daocloud.io/daocloud/coredns:1.6.7

// 给镜像打tag
docker tag daocloud.io/daocloud/kube-apiserver:v1.18.3 k8s.gcr.io/kube-apiserver:v1.18.3
docker tag daocloud.io/daocloud/kube-controller-manager:v1.18.3 k8s.gcr.io/kube-controller-manager:v1.18.3
docker tag daocloud.io/daocloud/kube-scheduler:v1.18.3 k8s.gcr.io/kube-scheduler:v1.18.3
docker tag daocloud.io/daocloud/kube-proxy:v1.18.3 k8s.gcr.io/kube-proxy:v1.18.3
docker tag daocloud.io/daocloud/pause:3.2 k8s.gcr.io/pause:3.2
docker tag daocloud.io/daocloud/etcd:3.4.3-0 k8s.gcr.io/etcd:3.4.3-0
docker tag daocloud.io/daocloud/coredns:1.6.7 k8s.gcr.io/coredns:1.6.7

// 清理原镜像
docker rmi daocloud.io/daocloud/kube-apiserver:v1.18.3
docker rmi daocloud.io/daocloud/kube-controller-manager:v1.18.3
docker rmi daocloud.io/daocloud/kube-scheduler:v1.18.3
docker rmi daocloud.io/daocloud/kube-proxy:v1.18.3
docker rmi daocloud.io/daocloud/pause:3.2
docker rmi daocloud.io/daocloud/etcd:3.4.3-0
docker rmi daocloud.io/daocloud/coredns:1.6.7

标签:v1.18,kube,kubernetes1.18,yum,io,kubeadm,daocloud,docker,Centos8
From: https://www.cnblogs.com/kwoky/p/17927947.html

相关文章

  • Centos8 硬盘挂载
    查看硬盘分区状况fdisk-l可以看到数据盘/dev/vdb大小为10Gb,目前还没有进行分区。对/dev/vdb资源盘进行分区fdisk/dev/vdb//根据提示输入信息:Command(mforhelp):输入nSelect(defaultp):输入pPartitionnumber(1-4,default1):输入1Firstsector(20......
  • 脚本 给kubeadm安装的k8s集群 进行证书的延期 从1年改成10年
    请谨慎使用先测试#!/bin/bashset-oerrexitset-opipefail#set-oxtracelog::err(){printf"[$(date+'%Y-%m-%dT%H:%M:%S.%N%z')]:\033[31mERROR:\033[0m$@\n"}log::info(){printf"[$(date+'%Y-%m-%dT%H:%M:%S.%N%z'......
  • kubernetes1.18.2安装kube-prometheus
    注:使用kube-prometheus安装非常方便,前面的prometheus+grafana+metrics-server都不用安装,已经集成在里面。1、clonegithub地址gitclonehttps://github.com/coreos/kube-prometheus.gitcdkube-prometheus2、查看manifest路径下所有的yaml文件[root@master1manifests]#lltotal......
  • kubeadm手动更新节点的kubelet证书
    问题描述在kubernetes-dev-worker-2节点某次重启服务器之后发现kubelet不可用,其/var/lib/kubelet/pki/kubelet-client-current.pem证书中的内容空了(不知道咋回事),所以不能再注册到kube-api中。处理过程:1.在master节点,执行一下,表示给kubernetes-dev-worker-2节点生成新的kubelet.......
  • [linux] [Centos8] 一台虚拟机的安装配置全过程
    今年7月的时候刚学linux,写过几篇配置,结果学得越多才发现已经过时了,这两天重装的时候被自己的文章搞晕了......
  • kubeadm更新k8s集群证书(1.23.14版本)
    1、更新证书[[email protected]]#kubeadmcertsrenewall--config=kubeadm-config.yamlcertificateembeddedinthekubeconfigfilefortheadmintouseandforkubeadmitselfrenewedcertificateforservingtheKubernetesAPIrenewedcer......
  • kubeadm续期k8s集群证书
    1、备份mkdir/opt/2023-12-09-k8s-backupcp-a/etc/kubernetes/opt/2023-12-09-k8s-backupcp-a/var/lib/etcd/opt/2023-12-09-k8s-backupcp-a/root/.kube/config/opt/2023-12-09-k8s-backup2、更新证书[root@k8s-master012023-12-09-k8s-backup]#kubeadmcer......
  • 通过kubeadm方式安装k8s
    虚拟机最少是2core,master内存最小3G,node内存最小2G.要求的Docker版本是18.03,如果不是安装的dockerce,版本是过旧的,可以选择删除后重新安装;也可以重新创建一个虚拟机执行以下命令。简单方法:使用master指定到第15步之后,克隆出两台node,在node上继续执行后面的步骤.更改ip......
  • 个人笔记:阿里云Centos8.4+ZABBIX6.2的安装配置
    ##############################1、安装zabbix仓库##############################[root@test~]#rpm-Uvhhttps://repo.zabbix.com/zabbix/6.2/rhel/8/x86_64/zabbix-release-6.2-3.el8.noarch.rpmRetrievinghttps://repo.zabbix.com/zabbix/6.2/rhel/8/x86_64/zabbix-rele......
  • 13.centos8 关闭防火墙和selinux或者防火墙开启指定端口
    1.firewalld查看防火墙状态systemctlstatusfirewalld关闭防火墙systemctlstopfirewalld开机自启关闭systemctldisablefirewalld开启防火墙   systemctlstartfirewalld开放指定端口   firewall-cmd--zone=public--add-port=1935/tcp--per......