通过docker+cri-dockerd部署k8s集群环境(含harbor镜像仓库)

这篇具有很好参考价值的文章主要介绍了通过docker+cri-dockerd部署k8s集群环境(含harbor镜像仓库)。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

目录

一.虚拟机准备

二.基础环境配置(各个节点都做)

1.IP和hosts解析

2.防火墙和selinux

3.安装基本软件

4.配置时间同步

5.禁用swap分区

6.修改内核参数并重载

7.配置ipvs

三.docker环境(各个节点都做)

1.配置软件源并安装docker-ce

2.配置docker加速

四.cri环境配置(各个节点都做)

1.下载查看版本

2.配置服务启动

五.harbor环境(只有register节点做)

1.安装harbor配置

2.验证

 六.集群初始化

1.下载k8s所需软件(各个节点都做)

2.拉取所需镜像(各个节点做)

3.master节点初始化 (只在master节点做)

4.执行成功后出现此界面后进行权限设置 

5.各个节点根据master初始化成功后的参数来加入(各个节点都做)

七.收尾工作(master节点做)

1.命令补全配置

2.网络配置

(1)flannel

(2)calico


一.虚拟机准备

主机(我的主机名) IP
master(node1-190.com) 192.168.2.190
node1(node2-191.com) 192.168.2.191
node2(node3-192.com) 192.168.2.192
node3(node4-193.com) 192.168.2.193

register(node5-196.com)

192.168.2.196

二.基础环境配置(各个节点都做)

1.IP和hosts解析

[root@node1-190 ~]# vim /etc/hosts

192.168.2.190 node1-190.com
192.168.2.191 node2-191.com
192.168.2.192 node3-192.com
192.168.2.193 node4-193.com
192.168.2.196 node5-196.com

2.防火墙和selinux

[root@node1-190 ~]# systemctl status firewalld.service;getenforce 
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)
Disabled

#临时
systemctl stop firewalld
setenforce 0
#禁用
systemctl disable firewalld
sed -i '/^SELINUX=/ c SELINUX=disabled' /etc/selinux/config

3.安装基本软件

[root@node1-190 ~]# yum install -y wget tree bash-completion lrzsz psmisc net-tools vim chrony

4.配置时间同步

[root@node1-190 ~]# vim /etc/chrony.conf
:3,6 s/^/#      #注释掉原有行
server ntp1.aliyun.com iburst

[root@node1-190 ~]# systemctl restart chronyd

[root@node1-190 ~]# chronyc sources
210 Number of sources = 1
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
^* 120.25.115.20                 2   8   341   431   -357us[ -771us] +/-   20ms

5.禁用swap分区

[root@node1-190 ~]# swapoff -a && sed -i 's/.*swap.*/#&/' /etc/fstab && free -m
              total        used        free      shared  buff/cache   available
Mem:          10376         943        8875          11         557        9178
Swap:             0           0           0

6.修改内核参数并重载

[root@node1-190 ~]# cat >> /etc/sysctl.d/k8s.conf << EOF
 vm.swappiness=0
 net.bridge.bridge-nf-call-ip6tables = 1
 net.bridge.bridge-nf-call-iptables = 1
 net.ipv4.ip_forward = 1
 EOF

[root@node1-190 ~]# modprobe br_netfilter &&  modprobe overlay && sysctl -p /etc/sysctl.d/k8s.conf
vm.swappiness = 0
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1

7.配置ipvs

[root@node1-190 ~]# yum install ipset ipvsadm -y

[root@node1-190 ~]# cat <<EOF>  /etc/sysconfig/modules/ipvs.modules
#!/bin/bash
modprobe -- ip_vs
modprobe -- ip_vs_rr
modprobe -- ip_vs_wrr
modprobe -- ip_vs_sh
modprobe -- nf_conntrack
EOF

[root@node1-190 ~]# chmod +x /etc/sysconfig/modules/ipvs.modules && /bin/bash /etc/sysconfig/modules/ipvs.modules && lsmod | grep -e ip_vs -e nf_conntrack_ipv4
nf_conntrack_ipv4      15053  2 
nf_defrag_ipv4         12729  1 nf_conntrack_ipv4
ip_vs_sh               12688  0 
ip_vs_wrr              12697  0 
ip_vs_rr               12600  0 
ip_vs                 145458  6 ip_vs_rr,ip_vs_sh,ip_vs_wrr
nf_conntrack          139264  7 ip_vs,nf_nat,nf_nat_ipv4,xt_conntrack,nf_nat_masquerade_ipv4,nf_conntrack_netlink,nf_conntrack_ipv4
libcrc32c              12644  4 xfs,ip_vs,nf_nat,nf_conntrack

三.docker环境(各个节点都做)

1.配置软件源并安装docker-ce

[root@node1-190 ~]# yum install -y yum-utils device-mapper-persistent-data lvm2

[root@node1-190 ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

[root@node1-190 ~]# yum install -y docker-ce

2.配置docker加速

#自建harbor仓库情况
[root@node1-190 ~]# cat <<EOF> /etc/docker/daemon.json 
{
 "registry-mirrors": [
 "http://74f21445.m.daocloud.io",
 "https://registry.docker-cn.com",
 "http://hub-mirror.c.163.com",
 "https://docker.mirrors.ustc.edu.cn" ], 
 "insecure-registries": ["node5-196.com"],    #写register的域名,各个节点都写register的域名
 "exec-opts": ["native.cgroupdriver=systemd"]
}
EOF

#没有自建仓库
[root@node1-190 ~]# cat <<EOF> /etc/docker/daemon.json 
{
 "registry-mirrors": [
 "http://74f21445.m.daocloud.io",
 "https://registry.docker-cn.com",
 "http://hub-mirror.c.163.com",
 "https://docker.mirrors.ustc.edu.cn" ], 
 "exec-opts": ["native.cgroupdriver=systemd"]
}
EOF


[root@node1-190 ~]# systemctl daemon-reload && systemctl start docker

四.cri环境配置(各个节点都做)

1.下载查看版本

链接:https://pan.baidu.com/s/1rRIqV-GO6ETe4N9glNs2cg 
提取码:km17

[root@node1-190 ~]# tar -xf cri-dockerd-0.3.4.amd64.tgz -C /usr/local/
[root@node1-190 local]# ll
total 0
drwxr-xr-x. 2 root    root     6 Apr 11  2018 bin
drwxrwxr-x  2 sulibao sulibao 25 Jun 30 03:31 cri-dockerd
drwxr-xr-x. 2 root    root     6 Apr 11  2018 etc
drwxr-xr-x. 2 root    root     6 Apr 11  2018 games
drwxr-xr-x. 2 root    root     6 Apr 11  2018 include
drwxr-xr-x. 2 root    root     6 Apr 11  2018 lib
drwxr-xr-x. 2 root    root     6 Apr 11  2018 lib64
drwxr-xr-x. 2 root    root     6 Apr 11  2018 libexec
drwxr-xr-x. 2 root    root     6 Apr 11  2018 sbin
drwxr-xr-x. 5 root    root    49 Jul 23 08:59 share
drwxr-xr-x. 2 root    root     6 Apr 11  2018 src

[root@node1-190 local]# mv cri-dockerd/cri-dockerd /usr/local/bin/

[root@node1-190 local]# cri-dockerd --version
cri-dockerd 0.3.4 (e88b1605)

2.配置服务启动

[root@node1-190 local]# vim /etc/systemd/system/cri-dockerd.service
[Unit]
Description=CRI Interface for Docker Application Container Engine
Documentation=https://docs.mirantis.com
After=network-online.target firewalld.service docker.service
Wants=network-online.target
 
[Service]
Type=notify
ExecStart=/usr/local/bin/cri-dockerd --pod-infra-container-image=registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.9 --network-plugin=cni --cni-conf-dir=/etc/cni/net.d --cni-bin-dir=/opt/cni/bin --container-runtime-endpoint=unix:///var/run/cri-dockerd.sock --cri-dockerd-root-directory=/var/lib/dockershim --docker-endpoint=unix:///var/run/docker.sock --cri-dockerd-root-directory=/var/lib/docker
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always
StartLimitBurst=3
StartLimitInterval=60s
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
TasksMax=infinity
Delegate=yes
KillMode=process
[Install]
WantedBy=multi-user.target

[root@node1-190 local]# vim /etc/systemd/system/cri-dockerd.socket
[Unit]
Description=CRI Docker Socket for the API
PartOf=cri-docker.service
[Socket]
ListenStream=/var/run/cri-dockerd.sock
SocketMode=0660
SocketUser=root
SocketGroup=docker
[Install]
WantedBy=sockets.target

[root@node1-190 ~]# systemctl daemon-reload
[root@node1-190 ~]# systemctl start cri-dockerd.service
[root@node1-190 ~]# systemctl enable cri-dockerd.service

五.harbor环境(只有register节点做)

1.安装harbor配置

[root@node5-196 ~]# mv docker-compose-linux-x86_64 /usr/local/bin/docker-compose

[root@node5-196 ~]# chmod +x /usr/local/bin/docker-compose 

[root@node5-196 ~]# tar -xf harbor-offline-installer-v2.8.4.tgz -C /usr/local/
[root@node5-196 ~]# cd /usr/local/
[root@node5-196 local]# ll

[root@node5-196 local]# cd harbor/
[root@node5-196 harbor]# ll
total 597536
-rw-r--r-- 1 root root      3639 Aug 15 17:53 common.sh
-rw-r--r-- 1 root root 611834153 Aug 15 17:54 harbor.v2.8.4.tar.gz
-rw-r--r-- 1 root root     12499 Aug 15 17:53 harbor.yml.tmpl
-rwxr-xr-x 1 root root      2725 Aug 15 17:53 install.sh
-rw-r--r-- 1 root root     11347 Aug 15 17:53 LICENSE
-rwxr-xr-x 1 root root      1881 Aug 15 17:53 prepare

[root@node5-196 harbor]# cp harbor.yml.tmpl harbor.yml

[root@node5-196 harbor]# vim harbor.yml
# Configuration file of Harbor
 
# The IP address or hostname to access admin UI and registry service.
# DO NOT use localhost or 127.0.0.1, because Harbor needs to be accessed by external clients.
hostname: node5-196.com  #修改为自己的主机名
 
# http related config
http:
  # port for http, default is 80. If https enabled, this port will redirect to https port
  port: 80    #注意端口
 
# https related config
#https:      #https区块全部注释
  # https port for harbor, default is 443
  #port: 443
  # The path of cert and key files for nginx
  #certificate: /your/certificate/path
  #private_key: /your/private/key/path

[root@node5-196 harbor]# ./install.sh   #安装
[root@node5-196 harbor]# docker images
REPOSITORY                      TAG       IMAGE ID       CREATED       SIZE
goharbor/harbor-exporter        v2.8.4    b8d33e28ec68   2 weeks ago   97.7MB
goharbor/redis-photon           v2.8.4    7b7324d651ca   2 weeks ago   120MB
goharbor/trivy-adapter-photon   v2.8.4    91d8e9f0b21a   2 weeks ago   464MB
goharbor/notary-server-photon   v2.8.4    a46f91560454   2 weeks ago   113MB
goharbor/notary-signer-photon   v2.8.4    da66bd8d944b   2 weeks ago   110MB
goharbor/harbor-registryctl     v2.8.4    805b38ca6bee   2 weeks ago   141MB
goharbor/registry-photon        v2.8.4    756769e94123   2 weeks ago   79MB
goharbor/nginx-photon           v2.8.4    375018db778b   2 weeks ago   116MB
goharbor/harbor-log             v2.8.4    8a2045fb24d2   2 weeks ago   124MB
goharbor/harbor-jobservice      v2.8.4    97808fc10f64   2 weeks ago   141MB
goharbor/harbor-core            v2.8.4    c26fcd0714d8   2 weeks ago   164MB
goharbor/harbor-portal          v2.8.4    4a8b0205c0f9   2 weeks ago   124MB
goharbor/harbor-db              v2.8.4    5b8af16d7420   2 weeks ago   174MB
goharbor/prepare                v2.8.4    bdbf974d86ce   2 weeks ago   166MB

[root@node5-196 harbor]# cat /etc/docker/daemon.json 
{
"registry-mirrors": [
"http://74f21445.m.daocloud.io",
"https://registry.docker-cn.com",
"http://hub-mirror.c.163.com",
"https://docker.mirrors.ustc.edu.cn"
 ],
  "insecure-registries": ["192.168.2.196"], 
  "insecure-registries": ["node5-196.com"],
  "exec-opts": ["native.cgroupdriver=systemd"]
}
[root@node5-196 harbor]# tail -1 /etc/hosts
192.168.2.196 node5-196.com

[root@node5-196 harbor]# systemctl restart docker
[root@node5-196 harbor]# docker-compose up -d

2.验证

[root@node5-196 harbor]# docker login http://node5-196.com   #进行harbor上镜像的推送和拉取验证
Username: admin
Password: 
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded

[root@node5-196 harbor]# docker tag busybox:latest node5-196.com/library/busybox:latest

[root@node5-196 harbor]# docker push node5-196.com/library/busybox:latest 
The push refers to repository [node5-196.com/library/busybox]
3d24ee258efc: Layer already exists 
latest: digest: sha256:023917ec6a886d0e8e15f28fb543515a5fcd8d938edb091e8147db4efed388ee size: 528

[root@node5-196 harbor]# docker pull node5-196.com/library/busybox:latest 
latest: Pulling from library/busybox
Digest: sha256:023917ec6a886d0e8e15f28fb543515a5fcd8d938edb091e8147db4efed388ee
Status: Image is up to date for node5-196.com/library/busybox:latest
node5-196.com/library/busybox:latest
[root@node5-196 harbor]# docker images
REPOSITORY                      TAG       IMAGE ID       CREATED       SIZE
goharbor/harbor-exporter        v2.8.4    b8d33e28ec68   2 weeks ago   97.7MB
goharbor/redis-photon           v2.8.4    7b7324d651ca   2 weeks ago   120MB
goharbor/trivy-adapter-photon   v2.8.4    91d8e9f0b21a   2 weeks ago   464MB
goharbor/notary-server-photon   v2.8.4    a46f91560454   2 weeks ago   113MB
goharbor/notary-signer-photon   v2.8.4    da66bd8d944b   2 weeks ago   110MB
goharbor/harbor-registryctl     v2.8.4    805b38ca6bee   2 weeks ago   141MB
goharbor/registry-photon        v2.8.4    756769e94123   2 weeks ago   79MB
goharbor/nginx-photon           v2.8.4    375018db778b   2 weeks ago   116MB
goharbor/harbor-log             v2.8.4    8a2045fb24d2   2 weeks ago   124MB
goharbor/harbor-jobservice      v2.8.4    97808fc10f64   2 weeks ago   141MB
goharbor/harbor-core            v2.8.4    c26fcd0714d8   2 weeks ago   164MB
goharbor/harbor-portal          v2.8.4    4a8b0205c0f9   2 weeks ago   124MB
goharbor/harbor-db              v2.8.4    5b8af16d7420   2 weeks ago   174MB
goharbor/prepare                v2.8.4    bdbf974d86ce   2 weeks ago   166MB
busybox                         latest    a416a98b71e2   6 weeks ago   4.26MB
node5-196.com/library/busybox   latest    a416a98b71e2   6 weeks ago   4.26MB

windows端作域名映射

Windows PowerShell
版权所有(C) Microsoft Corporation。保留所有权利。

安装最新的 PowerShell,了解新功能和改进!https://aka.ms/PSWindows

PS C:\WINDOWS\system32> cd .\drivers\etc\
PS C:\WINDOWS\system32\drivers\etc> notepad .\hosts
PS C:\WINDOWS\system32\drivers\etc>

 k8s 配置,Linux,# k8s,kubernetes,容器,云原生,k8s,harbor

k8s 配置,Linux,# k8s,kubernetes,容器,云原生,k8s,harbor

k8s 配置,Linux,# k8s,kubernetes,容器,云原生,k8s,harbor

推送后的结果 

k8s 配置,Linux,# k8s,kubernetes,容器,云原生,k8s,harbor

 六.集群初始化

1.下载k8s所需软件(各个节点都做)

[root@node4-193 ~]#  cat << EOF> /etc/yum.repos.d/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

[root@node4-193 ~]# yum install kubeadm kubectl kubelet -y
[root@node1-190 ~]# systemctl start kubelet

2.拉取所需镜像(各个节点做)

(1)有自建harbor情况

k8s 配置,Linux,# k8s,kubernetes,容器,云原生,k8s,harbor

[root@node1-190 ~]# vim dockerimages.sh 
#!/bin/bash
images=$(kubeadm config images list --kubernetes-version=1.28.0 | awk -F '/' '{print $NF}')
for i in ${images}
do
  docker pull registry.aliyuncs.com/google_containers/$i
  docker tag registry.aliyuncs.com/google_containers/$i node5-196.com/google_containers/$i    #需要修改为刚创建的harbor的仓库地址
  docker push node5-196.com/google_containers/$i
  docker rmi registry.aliyuncs.com/google_containers/$i
done

[root@node1-190 ~]# docker login node5-196.com
Username: admin 
Password: 
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded

[root@node1-190 ~]# bash dockerimages.sh

[root@node1-190 ~]# docker images
REPOSITORY                                                TAG       IMAGE ID       CREATED         SIZE
node5-196.com/google_containers/kube-apiserver            v1.28.0   bb5e0dde9054   2 weeks ago     126MB
node5-196.com/google_containers/kube-scheduler            v1.28.0   f6f496300a2a   2 weeks ago     60.1MB
node5-196.com/google_containers/kube-controller-manager   v1.28.0   4be79c38a4ba   2 weeks ago     122MB
node5-196.com/google_containers/kube-proxy                v1.28.0   ea1030da44aa   2 weeks ago     73.1MB
node5-196.com/google_containers/etcd                      3.5.9-0   73deb9a3f702   3 months ago    294MB
node5-196.com/google_containers/coredns                   v1.10.1   ead0a4a53df8   6 months ago    53.6MB
node5-196.com/google_containers/pause                     3.9       e6f181688397   10 months ago   744kB

k8s 配置,Linux,# k8s,kubernetes,容器,云原生,k8s,harbor

(2)无harbor情况

#没有自建情况
[root@node1-190 ~]# vim dockerimages.sh 
#!/bin/bash
images=$(kubeadm config images list --kubernetes-version=1.28.0 | awk -F '/' '{print $NF}')
for i in ${images}
do
  docker pull registry.aliyuncs.com/google_containers/$i
  docker tag registry.aliyuncs.com/google_containers/$i node5-196.com/google_containers/$i
  docker push registry.aliyuncs.com/google_containers/$i
  docker rmi registry.aliyuncs.com/google_containers/$i
done

3.master节点初始化 (只在master节点做)

执行完脚本无误后执行以下命令

#master节点做,有自建harbor情况
kubeadm init --kubernetes-version=1.28.2 \   #一定要是真实版本
--apiserver-advertise-address=192.168.2.190 \    #自己master节点的IP
--image-repository node5-196.com/google_containers \    #镜像地址,自建harbor就写harbor的地址,没有就用阿里云的
--service-cidr=10.96.0.0/12 \
--pod-network-cidr=10.244.0.0/16 \
--ignore-preflight-errors=Swap \
--cri-socket=unix:///var/run/cri-dockerd.sock

#没harbor情况
kubeadm init --kubernetes-version=1.28.2 \
--apiserver-advertise-address=192.168.2.180 \
--image-repository registry.aliyuncs.com/google_containers \
--service-cidr=10.96.0.0/12 \
--pod-network-cidr=10.244.0.0/16 \
--ignore-preflight-errors=Swap \
--cri-socket=unix:///var/run/cri-dockerd.sock

4.执行成功后出现此界面后进行权限设置 

k8s 配置,Linux,# k8s,kubernetes,容器,云原生,k8s,harbor

# master节点为普通用户时
[root@node1-190 ~]# mkdir -p $HOME/.kube && cp -i /etc/kubernetes/admin.conf $HOME/.kube/config && chown $(id -u):$(id -g) $HOME/.kube/config 

# master节点为root用户时
[root@node1-190 ~]# export KUBECONFIG=/etc/kubernetes/admin.conf

5.各个节点根据master初始化成功后的参数来加入(各个节点都做)

kubeadm join 192.168.2.190:6443 --token m5mkth.rb2e9rb3892fsu37 \
	--discovery-token-ca-cert-hash sha256:1209d580742d411fb4406953185ef9f27522b3ba150b8726fd39f364628d0942 \
	--cri-socket=unix:///var/run/cri-dockerd.sock 

#注意:初始化完成后弹出的加入节点命令在节点上执行时会报找不到socket文件,手动指定自己的socket文件“--cri-socket=unix:///var/run/cri-dockerd.sock”

出现此界面即成功 

k8s 配置,Linux,# k8s,kubernetes,容器,云原生,k8s,harbor

[root@node1-190 ~]# kubectl get nodes
NAME            STATUS     ROLES           AGE    VERSION
node1-190.com   Ready      control-plane   121m   v1.28.1
node2-191.com   Ready      <none>          104m   v1.28.1
node3-192.com   Ready      <none>          96m    v1.28.1
node4-193.com   Ready      <none>          11m    v1.28.1
node5-196.com   Ready      <none>          9s     v1.28.1

七.收尾工作(master节点做)

1.命令补全配置

[root@node1-190 ~]# echo "source <(kubectl completion bash)" >> ~/.bashrc && echo "source <(kubeadm completion bash)" >> ~/.bashrc && source ~/.bashrc

2.网络配置

(1)flannel

链接:https://pan.baidu.com/s/1TRUyPxbBZRcyyyqojquhBw 
提取码:wvap

[root@node1-190 ~]# vim flannel.sh
#!/bin/bash
for i in $(grep image kube-flannel.yml | grep -v '#' | awk -F '/' '{print $NF}')
do
  docker pull flannel/$i
  docker tag flannel/$i node5-196.com/google_containers/$i   #需要修改为刚创建的harbor的仓库地址
  docker push node5-196.com/google_containers/$i
  docker rmi flannel/$i
done

#注意:如果没有自建harbor,需要将node5-196.com改为registry.aliyuncs.com,后面的内容都如此
[root@node1-190 ~]# bash flannel.sh
[root@node1-190 ~]# docker images
REPOSITORY                                                  TAG       IMAGE ID       CREATED         SIZE
node5-196.com/google_containers/flannel                     v0.22.2   d73868a08083   13 days ago     70.2MB
node5-196.com/google_containers/kube-apiserver              v1.28.0   bb5e0dde9054   2 weeks ago     126MB
node5-196.com/google_containers/kube-controller-manager     v1.28.0   4be79c38a4ba   2 weeks ago     122MB
node5-196.com/google_containers/kube-scheduler              v1.28.0   f6f496300a2a   2 weeks ago     60.1MB
node5-196.com/google_containers/kube-proxy                  v1.28.0   ea1030da44aa   2 weeks ago     73.1MB
node5-196.com/google_containers/flannel-cni-plugin          v1.2.0    a55d1bad692b   5 weeks ago     8.04MB
node5-196.com/google_containers/etcd                        3.5.9-0   73deb9a3f702   3 months ago    294MB
node5-196.com/google_containers/coredns                     v1.10.1   ead0a4a53df8   6 months ago    53.6MB
node5-196.com/google_containers/pause                       3.9       e6f181688397   10 months ago   744kB
registry.cn-hangzhou.aliyuncs.com/google_containers/pause   3.9       e6f181688397   10 months ago   744kB


[root@node1-190 ~]# sed -i '/ image:/s#docker.io/flannel#node5-196.com/google_containers#' kube-flannel.yml

[root@node1-190 ~]# kubectl apply -f kube-flannel.yml   #应用
[root@node1-190 ~]# kubectl get pod -n kube-system   #验证
NAME                                    READY   STATUS    RESTARTS      AGE
coredns-6845c5578-g6dnk                 1/1     Running   0             159m
coredns-6845c5578-z5cj4                 1/1     Running   0             159m
etcd-node1-190.com                      1/1     Running   0             160m
kube-apiserver-node1-190.com            1/1     Running   0             160m
kube-controller-manager-node1-190.com   1/1     Running   0             160m
kube-proxy-5k8gg                        1/1     Running   0             134m
kube-proxy-b7kcg                        1/1     Running   0             159m
kube-proxy-h5zrz                        1/1     Running   0             142m
kube-proxy-h9gs5                        1/1     Running   1 (35m ago)   38m
kube-proxy-vfx9x                        1/1     Running   0             49m
kube-scheduler-node1-190.com            1/1     Running   0             160m

(2)calico

链接:百度网盘 请输入提取码 提取码:tswi

[root@master ~]# wget --no-check-certificate https://projectcalico.docs.tigera.io/archive/v3.25/manifests/calico.yaml
[root@master ~]# vim calico.yaml 
  • 找到CLUSTER_TYPE那行,添加后两行,ens33处填写你自己的网卡名称
- name: IP_AUTODETECTION_METHOD
  value: "interface=ens33"

k8s 配置,Linux,# k8s,kubernetes,容器,云原生,k8s,harbor

  • 将这两行取消注释,修改地址
- name: CALICO_IPV4POOL_CIDR
  value: "10.244.0.0/16"

 k8s 配置,Linux,# k8s,kubernetes,容器,云原生,k8s,harbor文章来源地址https://www.toymoban.com/news/detail-744437.html

  •  应用文件并查看
[root@master ~]# kubectl apply -f calico.yaml 
[root@master ~]# kubectl get pods -A
NAMESPACE     NAME                                       READY   STATUS    RESTARTS   AGE
kube-system   calico-kube-controllers-658d97c59c-k27lr   1/1     Running   0          18s
kube-system   calico-node-bzq6k                          1/1     Running   0          18s
kube-system   calico-node-dcb9c                          1/1     Running   0          18s
kube-system   calico-node-v97ll                          1/1     Running   0          18s
kube-system   coredns-66f779496c-nfxfr                   1/1     Running   0          4m9s
kube-system   coredns-66f779496c-q8s6j                   1/1     Running   0          4m9s
kube-system   etcd-k8s-master                            1/1     Running   12         4m16s
kube-system   kube-apiserver-k8s-master                  1/1     Running   12         4m16s
kube-system   kube-controller-manager-k8s-master         1/1     Running   13         4m16s
kube-system   kube-proxy-7gsls                           1/1     Running   0          4m10s
kube-system   kube-proxy-szdqz                           1/1     Running   0          2m54s
kube-system   kube-proxy-wgrpb                           1/1     Running   0          2m58s
kube-system   kube-scheduler-k8s-master                  1/1     Running   13         4m16s

到了这里,关于通过docker+cri-dockerd部署k8s集群环境(含harbor镜像仓库)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 通过kubeadm部署k8s 1.27高可有集群

    本次部署使用外部etcd集群+LB+K8S集群方案。如下图: 软件列表及软件版本:CentOS7U9, Linux kernel 5.4,docker-ce 23.0.6,cri-dockerd v0.3.1,k8s集群为1.27.1 所有主机均需要操作。 所有主机均需要操作。 所有主机均需要操作。 修改完成后需要重启操作系统,如不重启,可临时关闭,命令为s

    2024年02月13日
    浏览(40)
  • 基于Docker的K8s(Kubernetes)集群部署

    开始搭建k8s集群 三台服务器修改主机名称 关闭对话窗口,重新连接 三台主机名称呢就修改成功了。 接下来修改每台节点的 hosts 文件 所有节点关闭 setLinux 查看是否关闭成功 为每个节点添加 k8s 数据源 如果安装docker数据源找不到yum-config 所有节点安装kubelet kubelet安装中… k

    2024年02月08日
    浏览(97)
  • 使用docker部署rancher并导入k8s集群

    前言:鉴于我已经部署了k8s集群,那就在部署rancher一台用于管理k8s,这是一台单独的虚拟环境,之前在k8s的master节点上进行部署并未成功,有可能端口冲突了,这个问题我并没有深究,如果非要通过修改端口等操作部署上去后续可能带来的问题我处理不了,也很浪费时间,所

    2024年02月09日
    浏览(46)
  • K8S最新版本集群部署(v1.28) + 容器引擎Docker部署(上)

    🔼上一集:win11+vmware17+centos7.9环境搭建 *️⃣主目录:温故知新专栏 🔽下一集:K8S最新版本集群部署(v1.28) + 容器引擎Docker部署(下) 之前部署过dolphinscheduler3.1.8,看页面增加了K8S模块,所以想着部署一下K8S,学习一下,而且海豚调度也提供了K8S部署方式,经过一番了解,发现

    2024年02月11日
    浏览(53)
  • K8S最新版本集群部署(v1.28) + 容器引擎Docker部署(下)

    🔼上一集:K8S最新版本集群部署(v1.28) + 容器引擎Docker部署(上) *️⃣主目录:温故知新专栏 🔽下一集:Kubernetes可视化管理工具Kuboard部署使用及k8s常用命令梳理记录 kubectl 是使用 Kubernetes API 与 Kubernetes 集群的控制面进行通信的命令行工具。详见官网安装步骤 📕下载kube

    2024年02月09日
    浏览(51)
  • 通过containerd部署k8s集群环境及初始化时部分报错解决

    目录 一.基础环境配置(每个节点都做) 1.hosts解析 2.防火墙和selinux 3.安装基本软件并配置时间同步 4.禁用swap分区 5.更改内核参数 6.配置ipvs 7.k8s下载 (1)配置镜像下载相关软件 (2)配置kubelet上的cgroup 二.下载containerd(每个节点都做) 1.下载基本软件 2.添加软件仓库信息 3.更

    2024年02月07日
    浏览(44)
  • Gitlab+Jenkins+Docker+Harbor+K8s集群搭建CICD平台(持续集成部署Hexo博客Demo)

    目录 涉及内容: 一、CICD服务器环境搭建 1、docker 环境安装 (1)、拉取镜像,启动并设置开机自启 (2)、配置docker加速器 2、安装并配置GitLab (1)、创建共享卷目录 (2)、创建 gitlab 容器 (3)、关闭容器修改配置文件 (4)、修改完配置文件之后。直接启动容器 (5)、相关

    2024年03月15日
    浏览(70)
  • Win Docker Desktop + WSL2 部署PyTorch-CUDA服务至k8s算力集群

    首先根据你的操作系统版本 安装WSL ,记得切换WSL2,其次 安装Docker Desktop,如果Docker安装后一直无法加载WSL,卸载后重新安装时不要勾选WSL,安装后去设置里面勾上WSL即可。 Windows中运行以上代码,WSL中安装Ubuntu是为了方便在docker容器中挂载数据。 去WSL-Ubuntu系统中运行以上命

    2024年01月21日
    浏览(44)
  • 浅谈 K8s CRI

    进入 K8s 的世界,会发现有很多方便扩展的 Interface,包括 CRI, CSI, CNI 等,将这些接口抽象出来,是为了更好的提供开放、扩展、规范等能力。 K8s CRI(Container Runtime Interface) 是 K8s 定义的一组与容器运行时进行交互的接口,用于将 K8s 平台与特定的容器运行时实现解耦。CRI 在 K

    2024年02月04日
    浏览(33)
  • k8s入门:裸机部署 k8s 集群

    系列文章 第一章:✨ k8s入门:裸机部署 k8s 集群 第二章:✨ k8s入门:部署应用到 k8s 集群 第三章:✨ k8s入门:service 简单使用 第四章:✨ k8s入门:StatefulSet 简单使用 第五章:✨ k8s入门:存储(storage) 第六章:✨ K8S 配置 storageclass 使用 nfs 动态申领本地磁盘空间 第七章:

    2023年04月20日
    浏览(45)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包