当前位置: 首页 > java >正文

centos7.5安装kubernetes1.25.0

centos7.5安装kubernetes

  • centos7.5+kubernetes
      • 1)准备阶段
        • 准备2台虚拟机
        • 配置静态IP
        • 修改主机名
        • 桥接设置
        • 配置阿里云的repo源
        • 配置k8s切国际源
        • 配置时间同步
        • 安装基础软件包
      • 2)安装containerd服务
        • 安装
        • 配置开启启动
      • 3)安装k8s
      • 4)安装kubersphere
        • 下载helm安装包
        • 解压
        • 将helm配置成系统命令
        • 通过helm安装KubeSphere的核心组件KubeSphere Core
        • 安装成功之后显示地址和账号密码
      • ps 命令

centos7.5+kubernetes

kubelet-1.25.0 kubeadm-1.25.0 kubectl-1.25.0

1)准备阶段

  1. 准备2台虚拟机
iphostname
192.168.8.201k8smaster
192.168.8.202k8snode1
  1. 配置静态IP

vim /etc/sysconfig/network-scripts/ifcfg-ens33

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=990edb7d-58b0-486f-ad5a-41045ac8ee58
DEVICE=ens33
ONBOOT=yesIPADDR=192.168.8.201
NETMASK=255.255.255.0
GATEWAY=192.168.8.1
DNS1=192.168.8.1
ZONE=public

service network restart

  1. 修改主机名

#k8smaster
[root@localhost ~] hostname
localhost.localdomain
[root@localhost ~] hostname k8smaster ##临时生效
[root@localhost ~] hostnamectl set-hostname k8smaster ##重启后永久生效#k8snode1  
[root@localhost ~] hostname
localhost.localdomain
[root@localhost ~] hostname k8snode1  ##临时生效
[root@localhost ~] hostnamectl set-hostname k8snode1  ##重启后永久生效
  1. 桥接设置
$ modprobe br_netfilter
echo "modprobe br_netfilter" >> /etc/profile
cat > /etc/sysctl.d/k8s.conf << EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
EOF

$ sysctl --system

  1. 配置阿里云的repo源
修改 /etc/yum.repos.d/CentOS-Base.repo#mirrorlist=http://baseurl=http://vault.centos.org/centos/$releaseveryum install -y yum-utils
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
  1. 配置k8s切国际源
cat > /etc/yum.repos.d/kubernetes.repo << EOF
[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
  1. 配置时间同步
#yum install ntpdate -y
#ntpdate cn.pool.ntp.org
  1. 安装基础软件包
#yum install -y device-mapper-persistent-data lvm2 wget net-tools nfs-utils lrzsz gcc gcc-c++ make cmake libxml2-devel openssl-devel curl curl-devel unzip sudo ntp libaio-devel wget vim ncurses-devel autoconf automake zlib-devel  python-devel epel-release openssh-server socat  ipvsadm conntrack telnet ipvsadm

2)安装containerd服务

  1. 安装

yum install containerd.io-1.6.6 -y

1. 生成配置mkdir -p /etc/containerdcontainerd config default > /etc/containerd/config.toml#修改config.toml[plugins."io.containerd.grpc.v1.cri"]sandbox_image = "registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.7"[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]SystemdCgroup = true2配置文件---暂时不用配置cat > /etc/crictl.yaml << EOF 
runtime-endpoint: unix:///run/containerd/containerd.sock
image-endpoint: unix:///run/containerd/containerd.sock
timeout: 10
debug: false
EOF
  1. 配置开启启动

systemctl enable containerd --now

3)安装k8s

1.安装

yum install -y kubelet-1.25.0 kubeadm-1.25.0 kubectl-1.25.0
systemctl enable kubelet

2.初始化集群 —master节点执行

kubeadm init --apiserver-advertise-address 192.168.8.201 --image-repository registry.cn-hangzhou.aliyuncs.com/google_containers --cri-socket “unix:///var/run/containerd/containerd.sock” --kubernetes-version 1.25.0

3.打标签

kubectl label nodes k8snode1 node-role.kubernetes.io/work=work

4.安装pod网络插件flannel

kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

5.查看依赖的镜像/拉取镜像

kubeadm config images list
kubeadm config images pull

6.初始化master节点(成功之后生成token,node节点加入需要)

kubeadm init
–apiserver-advertise-address=192.168.8.201
–image-repository registry.aliyuncs.com/google_containers
–kubernetes-version=v1.25.0
–service-cidr=10.96.0.0/12
–pod-network-cidr=10.244.0.0/16
–v=5

7.安装calico

curl https://projectcalico.docs.tigera.io/archive/v3.23/manifests/calico.yaml -O
修改CALICO_IPV4POOL_CIDR


value: “10.244.0.0/16”


kubectl apply -f calico.yaml #应用

8.node节点

将kubelet 的配置复制到用户目录
sudo mkdir -p $HOME/.kube
sudo cp /etc/kubernetes/kubelet.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
node节点加入master
kubeadm join 192.168.8.201:6443 --token jstf23.au132wb83awk4zk6 \--discovery-token-ca-cert-hash sha256:9324351934967a1d59ea97525d92172a46ec1311a192236ee5294b6f5ae0dfe4

4)安装kubersphere

  1. 下载helm安装包

wget https://get.helm.sh/helm-v3.10.0-linux-amd64.tar.gz

  1. 解压

tar -zxvf helm-v3.10.0-linux-amd64.tar.gz

  1. 将helm配置成系统命令

mv linux-amd64/helm /usr/local/bin/helm

  1. 通过helm安装KubeSphere的核心组件KubeSphere Core

helm upgrade --install -n kubesphere-system --create-namespace ks-core https://charts.kubesphere.com.cn/main/ks-core-1.1.3.tgz --debug --wait
–set global.imageRegistry=swr.cn-southwest-2.myhuaweicloud.com/ks
–set extension.imageRegistry=swr.cn-southwest-2.myhuaweicloud.com/ks
–set hostClusterName=k8s-paco

  1. 安装成功之后显示地址和账号密码
1. Wait for Deployment CompletionConfirm that all KubeSphere components are running by executing the following command:kubectl get pods -n kubesphere-system
2. Access the KubeSphere ConsoleOnce the deployment is complete, you can access the KubeSphere console using the following URL:http://192.168.8.201:30880
3. Login to KubeSphere ConsoleUse the following credentials to log in:Account: adminPassword: xxxxxx

ps 命令


journalctl -u kubelet 查看错误日志kubectl get pods -Akubectl delete pod <podname> -n <namespace>kubectl get deployment --all-namespaceskubectl delete deployment <deploymentname> -n <namespace>kubectl describe node <node-name>
http://www.xdnf.cn/news/9284.html

相关文章:

  • 随叫随到的电力补给:移动充电服务如何重塑用户体验?
  • cursor-stats 实时监控 Cursor IDE 的使用情况和订阅状态
  • 线代第四章线性方程组第三节:齐次线性方程组
  • JDK21深度解密 Day 7:FFM与VarHandle底层剖析
  • langchain 0.3.x 版本如何初始化本地模型
  • js-day3
  • Tailwind css实战,基于Kooboo构建AI对话框页面(二)
  • 鸿蒙OSUniApp 开发支持图片和视频的多媒体展示组件#三方框架 #Uniapp
  • AI学习搭档:开启终身学习新时代
  • 强大的免费工具,集合了30+功能
  • 科技赋能建筑行业,智能楼宇自控系统崭露头角成发展新势力
  • 一起学数据结构和算法(二)| 数组(线性结构)
  • Rust编程环境安装
  • PostgreSQL的扩展 amcheck
  • day 38
  • flyway问题合集
  • word批量导出visio图
  • 图标变白,开始菜单栏无法打开程序(以jupyter为例)
  • ARM内核一览
  • Mac安装MongoDB数据库以及MongoDB Compass可视化连接工具
  • 【数据结构】单链表练习
  • 改进系列(12):基于SAM交互式点提示的UNet腹部多脏器分割方法研究
  • 【北京盈达科技】GEO优化:引领AI时代内容霸权,重塑行业生态
  • 思澈科技助力Keep Watch Pilot 1:重新定义智能运动手表体验
  • React 虚拟dom
  • ROS2 robot控制学习(一)
  • 自然语言×数据集成新范式:SeaTunnel MCP深度解读 | 附视频讲解
  • 重新安装解决mac vscode点击不能跳转问题
  • 树莓派(Raspberry Pi)安装Docker教程
  • LabVIEW软件开发过程中如何保证软件的质量?