k8s环境部署配置

这篇具有很好参考价值的文章主要介绍了k8s环境部署配置。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

目录

一.虚拟机准备

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

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-689991.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

到了这里,关于k8s环境部署配置的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

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

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

相关文章

  • 【云原生、k8s】管理Kubernetes应用搭建与部署

    官方提供Kubernetes部署3种方式 (一)minikube Minikube是一个工具,可以在本地快速运行一个单点的Kubernetes,尝试Kubernetes或日常开发的用户使用。不能用于生产环境。 官方文档:https://kubernetes.io/docs/setup/minikube/ (二)二进制包 从官方下载发行版的二进制包,手动部署每个组件,

    2024年01月21日
    浏览(77)
  • 云原生Kubernetes:简化K8S应用部署工具Helm

    目录 一、理论 1.HELM ​编辑 2.部署HELM2 3.部署HELM3(2to3方式) 4.部署HELM3(单独安装) 二、实验 1.部署 HELM2 2.部署HELM3(2to3方式) 3.部署HELM3(单独安装) 三、问题 1.api版本过期 2.helm初始化报错 3.pod状态为ImagePullBackOff 4.helm 命令显示 no repositories to show 的错误 5.Helm安装报错

    2024年02月07日
    浏览(65)
  • 【云原生】k8s 前置环境 网络配置 VMware Linux共享上网(iptables forward)

    本文介绍了如何使用 Linux iptalbes 来使其他内网主机进行上网。 解释说明:一般情况下,VMware安装好后会出现两张网卡,vmnet1 与 vmnet8 。其中vmnet1 为仅主机模式(虚拟机之间可通信,虚拟机与宿主机可通信,不能上网);vmnet8 为 NAT 模式(虚拟机之间可通信,虚拟机与宿主机

    2024年02月21日
    浏览(55)
  • 【云原生】【k8s】Kubernetes+EFK构建日志分析安装部署

    目录 EFK安装部署 一、环境准备(所有主机) 1、主机初始化配置 2、配置主机名并绑定hosts,不同主机名称不同 3、主机配置初始化 4、部署docker环境 二、部署kubernetes集群 1、组件介绍 2、配置阿里云yum源 3、安装kubelet kubeadm kubectl 4、配置init-config.yaml init-config.yaml配置 5、安装

    2024年02月12日
    浏览(39)
  • 云原生Kubernetes: K8S 1.29版本 部署Jenkins

    目录  一、实验 1.环境 2.K8S 1.29版本 部署Jenkins 服务 3.jenkins安装Kubernetes插件 二、问题 1.创建pod失败 2.journalctl如何查看日志信息 2.容器内如何查询jenkins初始密码 3.jenkins离线安装中文包报错 4.jenkins插件报错 (1)主机 表1 主机 主机 架构 版本 IP 备注 master K8S master节点 1.29.0 1

    2024年04月25日
    浏览(54)
  • 云原生Kubernetes:Kubeadm部署K8S单Master架构

    目录 一、理论 1.kubeadm 2.Kubeadm部署K8S单Master架构 3.环境部署 4.所有节点安装docker 5.所有节点安装kubeadm,kubelet和kubectl 6.部署K8S集群 7.安装dashboard 8.安装Harbor私有仓库 9.内核参数优化方案 二、实验 1.Kubeadm部署K8S单Master架构 2. 部署流程  3.环境部署 4.所有节点安装docker 5.所有节

    2024年02月10日
    浏览(60)
  • 云原生Kubernetes:K8S配置资源管理

    目录 一、理论 1.Secret 2.Secret创建 3.Secret使用 4.Configmap 5.Configmap创建 6.Configmap使用 二、实验 1.Secret创建 2.Secret使用 3.Configmap创建 4.Configmap使用 三、问题 1.变量引用生成资源报错 2.查看pod日志失败 3.创建configmap报错 4.YAML创建configmap报错 5. 生成资源报错 6.文件挂载pod报错Error 四

    2024年02月07日
    浏览(67)
  • 云上攻防-云原生篇&Kubernetes&K8s安全&API&Kubelet未授权访问&容器执行

    Kubernetes是一个开源的, 用于编排云平台中多个主机上的容器化的应用,目标是让部署容器化的应用能简单并且高效的使用, 提供了应用部署,规划,更新,维护的一种机制 。其核心的特点就是能够自主的管理容器来保证云平台中的容器按照用户的期望状态运行着,管理员可

    2024年02月08日
    浏览(87)
  • Kubernetes(K8s)基本环境部署

    此处只做学习使用,配置单master环境。 1、ip+主机规划(准备五台新机)==修改各个节点的主机名 注意:关闭防火墙与selinux 节点 主机名 ip 身份 joshua1 kubernetes-master.openlab.cn 192.168.134.151 master joshua2 kubernetes-work1.openlab.cn 192.168.134.152 work1 joshua3 kubernetes-work2.openlab.cn 192.168.134.153

    2024年02月10日
    浏览(59)
  • 云原生Kubernetes:二进制部署K8S单Master架构(一)

    目录 一、理论 1.K8S单Master架构 2.  etcd 集群 3.CNI 4.Flannel网络 5.K8S单Master架构环境部署 6.部署 etcd 集群 7.部署 docker 引擎 8.flannel网络配置 二、实验 1.二进制部署K8S单Master架构 2. 环境部署 3.部署 etcd 集群 4.部署 docker 引擎 5.flannel网络配置 三、问题 1.etcd 报错 2.安装etcd问题 3.系

    2024年02月10日
    浏览(55)

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

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

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

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

二维码1

领取红包

二维码2

领红包