云计算实训48——k8s环境搭建(详细版)

news2024/9/25 21:27:53

1.创建主机、设置ip、设置hostname

2.设置免密登录

# 生成私钥
[root@k8s-master ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
/root/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:qPjjmx9h67dJe6NWbrudmEoqt+9M5TZ/12xCqZZU6+s root@k8s-master
The key's randomart image is:
+---[RSA 2048]----+
|                 |
|                 |
|                 |
|       .      .  |
|      + S .  . o |
|   . o o o. . +  |
|  . . o +o+. = ..|
|   .oo.Bo+=*+.+ =|
|   .=*=*X*==+oE= |
+----[SHA256]-----+

# 免密登录
[root@k8s-master ~]# ssh-copy-id root@192.168.1.77
[root@k8s-master ~]# ssh-copy-id root@192.168.1.88

3.yum源配置

1)配置docker源

[root@k8s-master yum.repos.d]# vim docker-ce.repo

[docker-ce-stable]
name=Docker CE Stable - $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-stable-debuginfo]
name=Docker CE Stable - Debuginfo $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/debug-$basearch/stable
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-stable-source]
name=Docker CE Stable - Sources
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/source/stable
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-test]
name=Docker CE Test - $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/$basearch/test
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-test-debuginfo]
name=Docker CE Test - Debuginfo $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/debug-$basearch/test
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-test-source]
name=Docker CE Test - Sources
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/source/test
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-nightly]
name=Docker CE Nightly - $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/$basearch/nightly
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-nightly-debuginfo]
name=Docker CE Nightly - Debuginfo $basearch
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/debug-$basearch/nightly
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

[docker-ce-nightly-source]
name=Docker CE Nightly - Sources
baseurl=https://mirrors.aliyun.com/docker-ce/linux/centos/$releasever/source/nightly
enabled=0
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

2)配置k8s源

[root@k8s-master yum.repos.d]# vim 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

3)清空及创建缓存

[root@k8s-master ~]# yum clean all && yum makecache

4.主机映射

# 配置主机映射
[root@k8s-master ~]# vim /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.66    k8s-master
192.168.1.77    k8s-node1
192.168.1.88    k8s-node2

[root@k8s-master ~]# scp /etc/hosts root@192.168.1.77:/etc/hosts
hosts                                                   100%  228   159.0KB/s   00:00    
[root@k8s-master ~]# scp /etc/hosts root@192.168.1.88:/etc/hosts
hosts                                                   100%  228   107.4KB/s   00:00 

# 验证主机映射
[root@k8s-master ~]# ping k8s-node1
PING k8s-node1 (192.168.1.77) 56(84) bytes of data.
64 bytes from k8s-node1 (192.168.1.77): icmp_seq=1 ttl=64 time=0.970 ms
64 bytes from k8s-node1 (192.168.1.77): icmp_seq=2 ttl=64 time=0.524 ms
^C
[root@k8s-master ~]# ping k8s-node2
PING k8s-node2 (192.168.1.88) 56(84) bytes of data.
64 bytes from k8s-node2 (192.168.1.88): icmp_seq=1 ttl=64 time=0.484 ms
64 bytes from k8s-node2 (192.168.1.88): icmp_seq=2 ttl=64 time=0.481 ms
^C

5.安装常用软件

[root@k8s-master ~]# yum install wget jq psmisc vim net-tools telnet yum-utils device-mapper-persistent-data lvm2 git tree -y

# wget: 一个下载工具,用于从网络上下载文件。
# jq: 一个 JSON 处理器,用于解析和操作 JSON 数据。
# psmisc: 提供进程管理和系统信息查看工具,例如 ps、top 等。
# vim: 一个强大的文本编辑器,支持多种编程语言和脚本。
# net-tools: 提供网络管理工具,例如 ifconfig、netstat 等。
# telnet: 一个远程登录工具,用于连接到远程主机。
# yum-utils: 提供一些辅助工具,用于管理 yum 软件包管理器。
# device-mapper-pers: 一个设备映射工具,用于创建和管理逻辑卷。

6.关闭防火墙、NetworkManger、 selinux、swap虚拟分区

[root@k8s-master ~]# systemctl disable --now firewalld
[root@k8s-master ~]# systemctl disable --now NetworkManger

[root@k8s-master ~]# setenforce 0
[root@k8s-master ~]# vim /etc/selinux/config 
#将第七行内容修改为
SELINUX=disabled

#关闭swap分区
[root@k8s-master ~]# swapoff -a && sysctl -w vm.swappiness=0
vm.swappiness = 0
[root@k8s-master ~]# sed -ri '/^[^#]*swap/s@^@#@' /etc/fstab

7.同步时间

[root@k8s-node1 ~]# yum -y install ntpdate

[root@k8s-node1 ~]# ntpdate time2.aliyun.com
11 Sep 10:20:25 ntpdate[1443]: adjust time server 203.107.6.88 offset -0.004160 sec
[root@k8s-node1 ~]# crontab -e

* 5 * * * /usr/sbin/ntpdate time2.aliyun.com

8.配置limit

[root@k8s-master ~]# ulimit -SHn 65535
[root@k8s-master ~]# vim /etc/security/limits.conf 

#在最后一行添加下列内容
 * soft nofile 65536
 * hard nofile 131072
 * soft nproc 65535
 * hard nproc 655350
 * soft memlock unlimited
 * hard memlock unlimited

9.下载yaml文件——从gitee 上下载

[root@k8s-master ~]# cd /root/
[root@k8s-master ~]# git clone https://gitee.com/dukuan/k8s-ha-install.git

10.三个节点ipvs配置

[root@k8s-master ~]# yum install ipvsadm ipset sysstat conntrack libseccomp -y

[root@k8s-master ~]# modprobe -- ip_vs # 使用 modprobe 命令加载内核模块,核心 IPVS 模块

[root@k8s-master ~]# modprobe -- ip_vs_rr # IPVS 负载均衡算法 rr

[root@k8s-master ~]# modprobe -- ip_vs_wrr # IPVS 负载均衡算法 wrr

[root@k8s-master ~]# modprobe -- ip_vs_sh # 用于源端负载均衡的模块

[root@k8s-master ~]# modprobe -- nf_conntrack # 用于网络流量过滤和跟踪的模块
[root@k8s-master ~]# vim /etc/modules-load.d/ipvs.conf 

# 在系统启动时加载下列 IPVS 和相关功能所需的模块
#ip_vs                                  # 负载均衡模块
#ip_vs_lc                       # 用于实现基于连接数量的负载均衡算法
#ip_vs_wlc                      # 用于实现带权重的最少连接算法的模块
#ip_vs_rr                       # 负载均衡rr算法模块
#ip_vs_wrr                      # 负载均衡wrr算法模块
#ip_vs_lblc             # 负载均衡算法,它结合了最少连接(LC)算法和基于偏置的轮询(Round Robin with Bias)算法
#ip_vs_lblcr            # 用于实现基于链路层拥塞状况的最少连接负载调度算法的模块
#ip_vs_dh                       # 用于实现基于散列(Hashing)的负载均衡算法的模块
#ip_vs_sh                       # 用于源端负载均衡的模块
#ip_vs_fo                       # 用于实现基于本地服务的负载均衡算法的模块
#ip_vs_nq                       # 用于实现NQ算法的模块
#ip_vs_sed                      # 用于实现随机早期检测(Random Early Detection)算法的模块
#ip_vs_ftp                      # 用于实现FTP服务的负载均衡模块
#ip_vs_sh
#nf_conntrack   # 用于跟踪网络连接的状态的模块
#ip_tables                      # 用于管理防护墙的机制
#ip_set                         # 用于创建和管理IP集合的模块
#xt_set                         # 用于处理IP数据包集合的模块,提供了与iptables等网络工具的接口
#ipt_set                                # 用于处理iptables规则集合的模块
#ipt_rpfilter   # 用于实现路由反向路径过滤的模块
#ipt_REJECT             # iptables模块之一,用于将不符合规则的数据包拒绝,并返回特定的错误码
#ipip                                   # 用于实现IP隧道功能的模块,使得数据可以在两个网络之间进行传输
# 开机自启systemd默认提供的网络管理服务
[root@k8s-master ~]# systemctl enable --now systemd-modules-load.service 
# 查看已写入加载的模块
[root@k8s-master ~]# lsmod | grep -e ip_vs -e nf_conntrack
ip_vs                 141432  0 
nf_conntrack_ipv6      18935  10 
nf_defrag_ipv6         35104  1 nf_conntrack_ipv6
nf_conntrack_ipv4      15053  11 
nf_defrag_ipv4         12729  1 nf_conntrack_ipv4
nf_conntrack          133053  9 ip_vs,nf_nat,nf_nat_ipv4,nf_nat_ipv6,xt_conntrack,nf_nat_masquerade_ipv4,nf_nat_masquerade_ipv6,nf_conntrack_ipv4,nf_conntrack_ipv6
libcrc32c              12644  4 xfs,ip_vs,nf_nat,nf_conntrack

11.三个节点k8s的内核加载

[root@k8s-master ~]# vim /etc/sysctl.d/k8s.conf 

# 写入k8s所需内核模块
net.bridge.bridge-nf-call-iptables = 1          # 控制网络桥接与iptables之间的网络转发行为
net.bridge.bridge-nf-call-ip6tables = 1         # 用于控制网络桥接(bridge)的IP6tables过滤规则。当该参数设置为1时,表示启用对网络桥接的IP6tables过滤规则
fs.may_detach_mounts = 1                # 用于控制文件系统是否允许分离挂载,1表示允许
net.ipv4.conf.all.route_localnet = 1            # 允许本地网络上的路由。设置为1表示允许,设置为0表示禁止。
vm.overcommit_memory=1          # 控制内存分配策略。设置为1表示允许内存过量分配,设置为0表示不允许。
vm.panic_on_oom=0               # 决定当系统遇到内存不足(OOM)时是否产生panic。设置为0表示不产生panic,设置为1表示产生panic。
fs.inotify.max_user_watches=89100               # inotify可以监视的文件和目录的最大数量。
fs.file-max=52706963            # 系统级别的文件描述符的最大数量。
fs.nr_open=52706963                     # 单个进程可以打开的文件描述符的最大数量。
net.netfilter.nf_conntrack_max=2310720          # 网络连接跟踪表的最大大小。
net.ipv4.tcp_keepalive_time = 600               # TCP保活机制发送探测包的间隔时间(秒)。
net.ipv4.tcp_keepalive_probes = 3               # TCP保活机制发送探测包的最大次数。
net.ipv4.tcp_keepalive_intvl =15                # TCP保活机制在发送下一个探测包之前等待响应的时间(秒)。
net.ipv4.tcp_max_tw_buckets = 36000     # TCP TIME_WAIT状态的bucket数量。
net.ipv4.tcp_tw_reuse = 1               # 允许重用TIME_WAIT套接字。设置为1表示允许,设置为0表示不允许。
net.ipv4.tcp_max_orphans = 327680               # 系统中最大的孤套接字数量。
net.ipv4.tcp_orphan_retries = 3                 # 系统尝试重新分配孤套接字的次数。
net.ipv4.tcp_syncookies = 1             # 用于防止SYN洪水攻击。设置为1表示启用SYN cookies,设置为0表示禁用。
net.ipv4.tcp_max_syn_backlog = 16384            # SYN连接请求队列的最大长度。
net.ipv4.ip_conntrack_max = 65536               # IP连接跟踪表的最大大小。
net.ipv4.tcp_max_syn_backlog = 16384            # 系统中最大的监听队列的长度。
net.ipv4.tcp_timestamps = 0             # 用于关闭TCP时间戳选项。
net.core.somaxconn = 16384              # 用于设置系统中最大的监听队列的长度

# 保存后,所有节点重启,保证重启后内核依然加载
[root@k8s-master ~]# reboot

12.三个节点卸载podman 安装 docker-ce docker-ce-cli containerd

# 卸载之前的containerd
[root@k8s-master ~]# yum remove -y podman runc containerd 
# 安装Docker和containerd
[root@k8s-master ~]# yum install docker-ce docker-ce-cli containerd.io -y 

13.配置containerd需要的核心模块 overlay, br_netfilter

[root@k8s-master ~]# cat <<EOF | sudo tee /etc/modules-load.d/containerd.conf
> overlay
> br_netfilter
> EOF
overlay
br_netfilter
[root@k8s-master ~]# modprobe overlay
[root@k8s-master ~]# modprobe br_netfilter

[root@k8s-master ~]# cat <<EOF | sudo tee /etc/sysctl.d/99-kubernetescri.conf

# tee:读取的数据写入到一个或多个文件中,同时还将其复制到标准输出

> net.bridge.bridge-nf-call-iptables  = 1 

# 用于控制网络桥接是否调用iptables进行包过滤和转发。

> net.ipv4.ip_forward                 = 1 
# 路由转发,1为开启

> net.bridge.bridge-nf-call-ip6tables = 1
# 控制是否在桥接接口上调用IPv6的iptables进行数据包过滤和转发。

> EOF

[root@k8s-master ~]# sysctl --system 

14.containerd配置文件

[root@k8s-master ~]# mkdir -p /etc/containerd
# 读取containerd的配置并保存到/etc/containerd/config.toml

[root@k8s-master ~]# containerd config default | tee /etc/containerd/config.toml

[root@k8s-master ~]# vim /etc/containerd/config.toml 

# 找到第63行修改为sandbox_image = "registry.cnhangzhou.aliyuncs.com/google_containers/pause:3.9"
#找到containerd.runtimes.runc.options模块,添加SystemdCgroup = false,如果已经存在则直接修改(在第127行)

# 添加sandbox_image = "registry.cnhangzhou.aliyuncs.com/google_containers/pause:3.9"(第128行)
# 加载systemctl控制脚本

[root@k8s-master ~]# systemctl daemon-reload
# 启动containerd并设置开机启动

[root@k8s-master ~]# systemctl start containerd.service

[root@k8s-master ~]# systemctl enable containerd.service

15.配置 crictl 客户端连接的运⾏位置

# 配置容器运⾏环境的crictl.yml⽂件

[root@k8s-master ~]# vim /etc/crictl.yaml

runtime-endpoint: unix:///run/containerd/containerd.sock 

# 指定了容器运⾏时的地址为:unix://...

image-endpoint: unix:///run/containerd/containerd.sock 

# 指定了镜像运⾏时的地址为:unix://...

timeout: 10 

# 设置了超时时间为10秒

debug: false 

# 关闭调试模式

16.三个节点安装 Kubernetes 组件

# 安装 Kubeadm、Kubelet 和 Kubectl
# 查询最新的Kubernetes版本号

[root@k8s-master ~]# yum list kubeadm.x86_64 --showduplicates | sort -r
# 安装1.28最新版本kubeadm、kubelet和kubectl

[root@k8s-master ~]# yum install kubeadm-1.28* kubelet-1.28* kubectl-1.28* -y

[root@k8s-master ~]# systemctl daemon-reload
# 允许开机⾃启kubelet

[root@k8s-master ~]# systemctl enable --now kubelet
# 查看当前安装的kubeadm版本号

[root@k8s-master ~]# kubeadm version

kubeadm version: &version.Info{Major:"1", Minor:"28", GitVersion:"v1.28.2", 
GitCommit:"89a4ea3e1e4ddd7f7572286090359983e0387b2f", GitTreeState:"clean", 
BuildDate:"2023-09-13T09:34:32Z", GoVersion:"go1.20.8", Compiler:"gc", 
Platform:"linux/amd64"}

如果Kubelet无法正常启动,检查swap是否已经取消 虚拟分区,查看/var/log/message

如果是没有/var/lib/kublet/cofig.yaml文件,可能需要重新安装

yum -y remove kubelet-1.28*
yum -y install kubelet-1.28*
systemctl daemon-reload
system enable --now kubelet
yum -y install kubelet-1.28*

# kubelet端口是10248 10250 10255三个端口

17.Kubernetes 集群初始化

1)Kubeadm 配置⽂件

[root@k8s-master ~]# vim kubeadm-config.yaml

- groups:               # 定义了与此token关联的组
  - system:bootstrappers:kubeadm:default-node-token
  token: 7t2weq.bjbawausm0jaxury                # bootstrap token的值
  ttl: 24h0m0s          # token的生存时间,这里设置为24小时
  usages:                       # 定义token的用途
  - signing             # 数字签名
  - authentication              # 身份验证
kind: InitConfiguration         # 指定配置对象的类型,InitConfiguration:表示这是一个初始化配置
localAPIEndpoint:               # 定义本地API端点的地址和端口
  advertiseAddress: 192.168.1.66
  bindPort: 6443
nodeRegistration:               # 定义节点注册时的配置
  criSocket: unix:///var/run/containerd/containerd.sock         # 容器运行时(CRI)的套接字路径
  name: k8s-master              # 节点的名称
  taints:               # 标记
  - effect: NoSchedule          # 免调度节点
    key: node-role.kubernetes.io/control-plane          # 该节点为控制节点
---
apiServer:              # 定义了API服务器的配置
  certSANs:             # 为API服务器指定了附加的证书主体名称(SAN),指定IP即可
  - 192.168.1.66
  timeoutForControlPlane: 4m0s          # 控制平面的超时时间,这里设置为4分钟
apiVersion: kubeadm.k8s.io/v1beta3              # 指定API Server版本
certificatesDir: /etc/kubernetes/pki    # 指定了证书的存储目录
clusterName: kubernetes         # 定义了集群的名称为"kubernetes"
controlPlaneEndpoint: 192.168.1.66:6443                # 定义了控制节点的地址和端口
controllerManager: {}           # 控制器管理器的配置,为空表示使用默认配置
etcd:           # 定义了etcd的配置
  local:                # 本地etcd实例
    dataDir: /var/lib/etcd              # 数据目录
imageRepository: registry.cn-hangzhou.aliyuncs.com/google_containers            # 指定了Kubernetes使用的镜像仓库的地址,阿里云的镜像仓库。
kind: ClusterConfiguration              # 指定了配置对象的类型,ClusterConfiguration:表示这是一个集群配置
kubernetesVersion: v1.28.2              # 指定了kubernetes的版本
networking:             # 定义了kubernetes集群网络设置
  dnsDomain: cluster.local              # 定义了集群的DNS域为:cluster.local
  podSubnet: 172.16.0.0/16              # 定义了Pod的子网
  serviceSubnet: 10.96.0.0/16   # 定义了服务的子网
scheduler: {}           # 使用默认的调度器行为
     

2)下载组件镜像

# 通过新的配置⽂件new.yaml从指定的阿⾥云仓库拉取kubernetes组件镜像

[root@k8s-master ~]# kubeadm config images pull --config /root/new.yaml 

3)集群初始化

[root@k8s-master ~]# kubeadm init --config /root/new.yaml --upload-certs

# 等待初始化后保存这些命令
[root@k8s-master ~]# vim token

# 当需要加⼊新node节点时,只复制这执行即可
kubeadm join 192.168.1.66:6443 --token 7t2weq.bjbawausm0jaxury \

--discovery-token-ca-cert-hash sha256:c567ec201a370bfbec3b28ee4bcffedc94a5566bae0fd86f36334f3aed879c5e \

# 当需要⾼可⽤master集群时,将整个token复制下来
--control-plane --certificate-key e19750aecb2ce36344016c864530b31e4f6a3125d14d242b4bf9089839666780

18.将工作节点加入到集群

[root@k8s-node1 ~]# systemctl stop kubelet.service
[root@k8s-node1 ~]# echo 1 > /proc/sys/net/ipv4/ip_forward
[root@k8s-node1 ~]# kubeadm join 192.168.1.66:6443 --token 7t2weq.bjbawausm0jaxury --discovery-token-ca-cert-hash sha256:b7ec8962bfa0847311cba6f4e79aca5e4dc263a0bad29b72f40e5123fe448da8 

[root@k8s-node2 ~]# systemctl stop kubelet.service
[root@k8s-node2 ~]# echo 1 > /proc/sys/net/ipv4/ip_forward
[root@k8s-node2 ~]# kubeadm join 192.168.1.66:6443 --token 7t2weq.bjbawausm0jaxury --discovery-token-ca-cert-hash sha256:b7ec8962bfa0847311cba6f4e79aca5e4dc263a0bad29b72f40e5123fe448da8

#查看节点 查看在集群中的主机的状态
[root@k8s-master calico]# kubectl get nodes
NAME         STATUS     ROLES           AGE   VERSION
k8s-master   NotReady   control-plane   19m   v1.28.2
k8s-node1    NotReady   <none>          12m   v1.28.2
k8s-node2    NotReady   <none>          11m   v1.28.2

# 查看所有的pod的状态
[root@k8s-master ~]# kubectl get po -A
NAMESPACE     NAME                                       READY   STATUS     RESTARTS   AGE
kube-system   calico-kube-controllers-6d48795585-66rq4   0/1     Pending    0          120m
kube-system   calico-node-c2d7c                          0/1     Init:0/3   0          120m
kube-system   calico-node-d44cc                          0/1     Init:0/3   0          120m
kube-system   calico-node-dg5rh                          0/1     Init:0/3   0          120m
kube-system   coredns-6554b8b87f-ss2xb                   0/1     Pending    0          130m
kube-system   coredns-6554b8b87f-xmgr7                   0/1     Pending    0          130m
kube-system   etcd-k8s-master                            1/1     Running    2          130m
kube-system   kube-apiserver-k8s-master                  1/1     Running    2          130m
kube-system   kube-controller-manager-k8s-master         1/1     Running    2          130m
kube-system   kube-proxy-4wvm7                           1/1     Running    0          123m
kube-system   kube-proxy-8hrp4                           1/1     Running    0          130m
kube-system   kube-proxy-q2ss2                           1/1     Running    0          123m
kube-system   kube-scheduler-k8s-master                  1/1     Running    2          130m
          132m   192.168.1.66   k8s-master   <none>           <none>

status:

19.Calico 组件安装

1)切换 git 分⽀

[root@k8s-master ~]# cd /root/k8s-ha-install
[root@k8s-master k8s-ha-install]# git checkout manual-installation-v1.28.x
分支 manual-installation-v1.28.x 设置为跟踪来自 origin 的远程分支 manualinstallation-v1.28.x。
切换到一个新分支'manual-installation-v1.28.x'

2)修改 Pod ⽹段

[root@k8s-master k8s-ha-install]# cd calico/
# 获取已定义的Pod⽹段

[root@k8s-master calico]# POD_SUBNET=`cat /etc/kubernetes/manifests/kubecontroller-manager.yaml
 | grep cluster-cidr= | awk -F= '{print $NF}'` 

[root@k8s-master calico]# echo $POD_SUBNET

172.16.0.0/16

# 修改calico.yml⽂件中的pod⽹段

[root@k8s-master calico]# sed -i "s#POD_CIDR#${POD_SUBNET}#g" calico.yaml
# 创建calico的pod

[root@k8s-master calico]# kubectl apply -f calico.yaml 

3)查看容器和节点状态

[root@k8s-master calico]# kubectl get po -n kube-system
NAME                                       READY   STATUS     RESTARTS   AGE
calico-kube-controllers-6d48795585-66rq4   0/1     Pending    0          38s
calico-node-c2d7c                          0/1     Init:0/3   0          38s
calico-node-d44cc                          0/1     Init:0/3   0          38s
calico-node-dg5rh                          0/1     Init:0/3   0          38s
coredns-6554b8b87f-ss2xb                   0/1     Pending    0          11m
coredns-6554b8b87f-xmgr7                   0/1     Pending    0          11m
etcd-k8s-master                            1/1     Running    2          11m
kube-apiserver-k8s-master                  1/1     Running    2          11m
kube-controller-manager-k8s-master         1/1     Running    2          11m
kube-proxy-4wvm7                           1/1     Running    0          4m29s
kube-proxy-8hrp4                           1/1     Running    0          11m
kube-proxy-q2ss2                           1/1     Running    0          3m53s
kube-scheduler-k8s-master                  1/1     Running    2          11m

[root@k8s-master ~]# kubectl get nodes
NAME         STATUS     ROLES           AGE    VERSION
k8s-master   NotReady   control-plane   147m   v1.28.2
k8s-node1    NotReady   <none>          140m   v1.28.2
k8s-node2    NotReady   <none>          139m   v1.28.2
[root@k8s-master ~]# kubectl describe po -n kube-system calico

20.使用ifconfig或者 ip a s指令查看虚拟网卡

[root@k8s-master ~]# ip a s
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:15:b8:67 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.66/24 brd 192.168.1.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever
    inet6 fe80::fc98:e5e8:a000:88c2/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2126057.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

智能化转型的基石:精心策划楼宇自控系统的选择与部署

智能化转型的基石&#xff1a;精心策划楼宇自控系统的选择与部署 在智慧城市的宏伟蓝图中&#xff0c;建筑智能化已成为推动城市进步的强劲动力。楼宇自控系统&#xff0c;作为这一进程中的核心组件&#xff0c;其选择与部署策略不仅关乎建筑内部的运营效率与能源管理&#xff…

十大排序算法的特点及应用场景

一.十大经典排序算法介绍 1. 冒泡排序&#xff08;Bubble Sort&#xff09; 原理&#xff1a;通过重复遍历要排序的数列&#xff0c;一次比较两个元素&#xff0c;如果它们的顺序错误就把它们交换过来。遍历数列的工作是重复进行的&#xff0c;直到没有再需要交换的元素为止。…

视频编辑SDK解决方案,完整的前端代码+SDK功能交付

繁琐的视频编辑过程往往成为创作者们提升作品质量的瓶颈&#xff0c;美摄科技凭借其深厚的AI技术积累与创新的移动端视频编辑SDK解决方案&#xff0c;正引领着视频编辑领域的新潮流&#xff0c;让每一位创作者都能轻松驾驭创意&#xff0c;实现从灵感闪现到作品呈现的无缝对接。…

点餐小程序实战教程05登录界面搭建

目录 1 设置tab栏2 添加页面3 搭建登录界面3.1 显示头像3.2 显示昵称3.3 注册按钮 总结 上一篇我们讲解了如何在首页加载的时候获取用户信息&#xff0c;一般小程序会在底部放置tab栏&#xff0c;将不同的菜单放置在tab栏中。我们的用户注册逻辑是&#xff0c;如果用户点击了底…

Java码农人生开启手册——多态与重写

一、多态 概念&#xff1a;通俗来说&#xff0c;就是多种形态&#xff1b;具体点&#xff0c;就是去完成某个行为&#xff0c;当不同的对象去完成时会产生不同的状态。 1、多态的实现条件 三个条件&#xff0c;缺一不可&#xff1a; 必须在继承体系下子类必须对父类中方…

训练 Vision Transformer 模型并运行推理

目录 CV Architecture ViT and U-Net Training ViT Florence-2 Load Model Load images CV Scenarios test Genarate CAPTION from the images DENSE REGION CAPTION and REGION_PROPOSA Caption to Phrase Grounding Bounding boxes OCR test Fine Tuning Floren…

2024年转行做网络安全工程师还来得及吗?薪资怎么样呢

&#x1f91f; 基于入门网络安全/黑客打造的&#xff1a;&#x1f449;黑客&网络安全入门&进阶学习资源包 2022年以来&#xff0c;我国网络安全行业的市场规模持续增长&#xff0c;根据市场调研在线网发布的2023-2029年中国网络安全集成行业市场运行态势及发展趋向分析…

Pycharm配置ssh远程服务器解析器

算法学习、4对1辅导、论文辅导或核心期刊可以通过公众号滴滴我 文章目录 需求配置流程 需求 之前在开发中&#xff0c;Pycharm都是通过本机Python环境来解析。但有时候&#xff0c;可能受限于本机电脑配置原因&#xff0c;导致运行速度并不快。因此推荐大家尝试下&#xff0c…

一文带你彻底掌握二分查找

1. 认识二分查找 二分查找也被称为折半查找&#xff0c;他是一种查询效率较高的查找方式&#xff0c;普通查找的方式通常是从头到尾遍历一遍数组&#xff0c;二分查找的方式是找到数组中间的那个元素mid与目标值target进行比较&#xff0c;比target小就去前半段找&#xff0c;…

Java中List集合去重

反问问题&#xff1a;为什么不直接使用 Set 或者 LinkedHashSet 呢 实际场景&#xff1a;实际的业务开发中遇到的情况会更复杂。比如&#xff0c;List 集合可能是历史遗留问题&#xff0c;也有可能是调用接口返回的类型限制&#xff0c;只能使用 List 接收&#xff0c;又或者是…

Qualcomm Linux 交叉编译应用程序

1. 前提条件 Ubuntu 20.04 系统 Qualcomm RB3 Gen2开发板 2.下载并安装 eSDK 平台 1.从 Qualcomm 发布存档平台下载 eSDK。 wget https://artifacts.codelinaro.org/artifactory/qli-ci/flashable-binaries/qimpsdk/qcm6490/x86/qcom-6.6.28-QLI.1.1-Ver.1.1_qim-product-s…

消除数字球-第15届蓝桥省赛Scratch初级组真题第5题

[导读]&#xff1a;超平老师的《Scratch蓝桥杯真题解析100讲》已经全部完成&#xff0c;后续会不定期解读蓝桥杯真题&#xff0c;这是Scratch蓝桥杯真题解析第184讲。 如果想持续关注Scratch蓝桥真题解读&#xff0c;可以点击《Scratch蓝桥杯历年真题》并订阅合集&#xff0c;…

python程序使用nohup后台执行不能实时输出到定向文件的解决方法

问题描述&#xff1a;使用nohup命令后台执行python&#xff0c;但python中print方法打印结果不能实时输出到nohup后台定向文件&#xff0c;只能在程序结束时一次性输出。典型问题样例&#xff1a;在python中使用了os.system(command)方法&#xff0c;command命令打印的结果可以…

免费爬虫软件“HyperlinkCollector超链采集器v0.1”

HyperlinkCollector超链采集器单机版v0.1 软件采用python的pyside2和selenium开发,暂时只支持window环境&#xff0c;抓取方式支持普通程序抓取和selenium模拟浏览器抓取。软件遵守robots协议。 首先下载后解压缩&#xff0c;然后运行app目录下的HyperlinkCollector.exe 运行…

网页与App无缝衔接,揭秘拉起应用的黑科技!

随着移动互联网的飞速发展&#xff0c;App已经成为了我们日常生活中不可或缺的一部分。然而&#xff0c;在推广和运营App的过程中&#xff0c;如何让用户更便捷地从网页跳转到App&#xff0c;一直是困扰推广者的难题。今天&#xff0c;我们就来聊聊网页拉起应用这一黑科技&…

开源 AI 智能名片 S2B2C 商城小程序中的全渠道供应策略

摘要&#xff1a;本文深入探讨在开源 AI 智能名片 S2B2C 商城小程序的情境下&#xff0c;全渠道供应的运行机制。阐述各环节企业相互配合的重要性&#xff0c;重点分析零售企业在其中的关键作用&#xff0c;包括协调工作、信息传递、需求把握等方面&#xff0c;旨在实现高效的全…

Python中的上下文管理器:提升代码的优雅与安全

在编写Python程序时&#xff0c;处理资源&#xff08;如文件、网络连接、数据库会话等&#xff09;的正确打开和关闭至关重要。不当的资源管理可能导致内存泄漏、数据损坏等问题。幸运的是&#xff0c;Python提供了一种优雅的方式来解决这个问题——上下文管理器。本文将探讨上…

象过河轮胎进销存,轻松管理进出库以及废旧轮胎回收

在轮胎行业&#xff0c;高效的进销存管理与废旧轮胎的回收是两大核心挑战&#xff0c;象过河轮胎进销存应运而生。软件专为轮胎行业量身定制&#xff0c;从进货&#xff0c;销售&#xff0c;到库存盘点&#xff0c;财务&#xff0c;轮胎废旧回收等一体化管理&#xff0c;以科技…

【每日刷题】Day118

【每日刷题】Day118 &#x1f955;个人主页&#xff1a;开敲&#x1f349; &#x1f525;所属专栏&#xff1a;每日刷题&#x1f34d; &#x1f33c;文章目录&#x1f33c; 1. 123. 买卖股票的最佳时机 III - 力扣&#xff08;LeetCode&#xff09; 2. 188. 买卖股票的最佳时…

如何用python打开csv文件路径

python读取CSV文件方法&#xff1a; 方法1&#xff1a;可先用以下代码查看当前工作路径&#xff0c;然后将CSV文件放在该路径下。 import os os.getcwd() 方法2&#xff1a;&#xff08;绝对路径&#xff09; import pandas as pd iris_trainpd.read_csv(E:\Study\DataSets\ir…