K8S集群部署--亲测好用

最近在自学K8S,花了三天最后终于成功部署一套K8S Cluster集群(master+node1+node2)

在这里先分享一下具体的步骤,后续再更新其他的内容:例如部署期间遇到的问题及其解决办法。

部署步骤是英文写的,最近想练练英文,所以就这样了,但是都比较基础的英文,都能看懂:

1.Preparing 3 servers like below: My lab is Centos 7

Master Node:

  • Disabled the Firewall and SE Linux:
    systemctl disable firewalld
    sed -i '/selinux/enforcing/disabled/' /etc/selinux/config
  • Disable swap(Remember to restart the VM):
    • swapoff -a  ##This is the temporary way
      #swap options under the path of /etc/fstab  ##permernent way
  • Change hostname:
    • hostnamectl set-hostname k8s-master
  • Add the hostname to the /etc/hosts
cat >> /etc/hosts << EOF

192.168.206.130 k8s-node2
192.168.206.131 k8s-node1
192.168.206.132 k8s-master
EOF
  • Modify machine kernel parameters
    • 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 -p /etc/sysctl.d/k8s.conf
  • Config the yum:
[root@k8s-master1 yum.repos.d]# cat kubernetes.repo

[kubernetes]

name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0


[root@k8s-master1 yum.repos.d]# cat 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
  • Install the docker and enable it:
    • yum install -y docker-ce docker-ce-cli containerd.io
      systemctl enable docker && systemctl start docker
      docker --version
  • Configure the docker speeder and driver:
vi /etc/docker/daemon.json
{
        "exec-opts": ["native.cgroupdriver=systemd"],         
"registry-mirrors": [

                   "https://tl522tpb.mirror.aliyuncs.com",
                   "https://docker.m.daocloud.io/",
                   "https://huecker.io/",
                   "https://dockerhub.timeweb.cloud",
                   "https://noohub.ru/",
                   "https://dockerproxy.com",
                   "https://docker.mirrors.ustc.edu.cn",
                   "https://docker.nju.edu.cn",
                   "https://xx4bwyg2.mirror.aliyuncs.com",
                   "http://f1361db2.m.daocloud.io",
                   "https://registry.docker-cn.com",
                   "http://hub-mirror.c.163.com"
  ]

}
  • Reload the json file and restart the docker service :
    • systemctl daemon-reload && systemctl restart docker
      systemctl status docker
  • Install the NTP and update the time:
    • yum install ntpdate -y
      ntpdate time.windows.com
  • Install the K8S
    • yum install -y kubelet-1.23.6 kubeadm-1.23.6 kubectl-1.23.6
      systemctl enable kubelet
  • Init the Master : ##You need to edit IP information on your system
kubeadm init \
 --kubernetes-version=v1.23.6 \
 --apiserver-advertise-address=192.168.206.132 \
 --image-repository=registry.aliyuncs.com/google_containers \
 --service-cidr=192.168.204.0/24 \
 --pod-network-cidr=192.168.159.0/24

If the init option can be ran successfully, you will see the below words:

​Your Kubernetes control-plane has initialized successfully!

To start using your cluster, you need to run the following as a regular user:

  mkdir -p $HOME/.kube

  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

  sudo chown $(id -u):$(id -g) $HOME/.kube/config

Alternatively, if you are the root user, you can run:

  export KUBECONFIG=/etc/kubernetes/admin.conf

You should now deploy a pod network to the cluster.

Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:

  Installing Addons | Kubernetes

Then you can join any number of worker nodes by running the following on each as root:

kubeadm join 192.168.206.132:6443 --token 8he0uh.8ftagcf7yk0ccy0j \

        --discovery-token-ca-cert-hash sha256:5a97b36bed5a4e31d2ae08f7efd0a4a62b6d08ae63f9341f889b92601716b827
​
  • Check the Kubelet service status:
​
[root@k8s-master1 ~]# systemctl status kubelet.service

● kubelet.service - kubelet: The Kubernetes Node Agent

   Loaded: loaded (/usr/lib/systemd/system/kubelet.service; enabled; vendor preset: disabled)

  Drop-In: /usr/lib/systemd/system/kubelet.service.d

           └─10-kubeadm.conf

   Active: active (running) since Fri 2025-01-31 15:39:18 CST; 3min 41s ago

     Docs: Kubernetes Documentation | Kubernetes

 Main PID: 15836 (kubelet)

    Tasks: 15

   Memory: 36.9M

   CGroup: /system.slice/kubelet.service

           └─15836 /usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --conf...

Jan 31 15:42:39 k8s-master1 kubelet[15836]: I0131 15:42:39.171118   15836 cni.go:240] "Unable to update cni config" err="no networks found...i/net.d"
​

Configure the enviroment:

  mkdir -p $HOME/.kube
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  sudo chown $(id -u):$(id -g) $HOME/.kube/config

The master node has completed.

For the Node deploy please flow the steps :

  • Disabled the Firewall and SE Linux:
  • Disable swap(Remember to restart the VM):
  • Change hostname: k8s-node1,etc
  • Add the hostname to the /etc/hosts
  • Modify machine kernel parameters
  • Config the yum
  • Install the docker and enable it
  • Configure the docker speeder and driver
  • Reload the json file
  • Install the NTP and update the time
  • Install the K8S

Add nodes to the master:

kubeadm join 192.168.206.132:6443 --token 8he0uh.8ftagcf7yk0ccy0j --discovery-token-ca-cert-hash sha256:5a97b36bed5a4e31d2ae08f7efd0a4a62b6d08ae63f9341f889b92601716b827

Check the nodes:

[root@k8s-master1 yum.repos.d]# kubectl get nodes

NAME          STATUS   ROLES                  AGE    VERSION
k8s-master1   NotReady    control-plane,master   2d2h   v1.23.6
k8s-node1     NotReady    <none>                 46h    v1.23.6
k8s-node2     NotReady    <none>                 45h    v1.23.6

Add the CNI network add-in:

Create folder :mkdir ~./k8s

Download the yaml file

  • curl https://calico-v3-25.netlify.app/archive/v3.25/manifests/calico.yaml -O
    ​kubectl apply -f yaml
  • You also can download the yaml file from this command and apply it:
kubectl apply -f https://calico-v3-25.netlify.app/archive/v3.25/manifests/calico.yaml
​

Short the containers:

  • sed -i 's#docker.io/##g' calico.yaml

Check the Pod status:

 kubectl get po -n kube-system -o wide

If display like below will be good for the containers: Pod Status all Running and Ready

Check the node status:

 kubectl get nodes

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

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

【Unity2D 2022:UI】创建滚动视图

一、创建Scroll View游戏对象 在Canvas画布下新建Scroll View游戏对象 二、为Content游戏对象添加Grid Layout Group&#xff08;网格布局组&#xff09;组件 选中Content游戏物体&#xff0c;点击Add Competent添加组件&#xff0c;搜索Grid Layout Group组件 三、调整Grid La…

c++:list

1.list的使用 1.1构造 1.2迭代器遍历 &#xff08;1&#xff09;迭代器是算法和容器链接起来的桥梁 容器就是链表&#xff0c;顺序表等数据结构&#xff0c;他们有各自的特点&#xff0c;所以底层结构是不同的。在不用迭代器的前提下&#xff0c;如果我们的算法要作用在容器上…

一文速览DeepSeek-R1的本地部署——可联网、可实现本地知识库问答:包括671B满血版和各个蒸馏版的部署

前言 自从deepseek R1发布之后「详见《一文速览DeepSeek R1&#xff1a;如何通过纯RL训练大模型的推理能力以比肩甚至超越OpenAI o1(含Kimi K1.5的解读)》」&#xff0c;deepseek便爆火 爆火以后便应了“人红是非多”那句话&#xff0c;不但遭受各种大规模攻击&#xff0c;即便…

游戏引擎 Unity - Unity 打开项目、Unity Editor 添加简体中文语言包模块、Unity 项目设置为简体中文

Unity Unity 首次发布于 2005 年&#xff0c;属于 Unity Technologies Unity 使用的开发技术有&#xff1a;C# Unity 的适用平台&#xff1a;PC、主机、移动设备、VR / AR、Web 等 Unity 的适用领域&#xff1a;开发中等画质中小型项目 Unity 适合初学者或需要快速上手的开…

[权限提升] Windows 提权 维持 — 系统错误配置提权 - 注册表权限配置错误提权

关注这个专栏的其他相关笔记&#xff1a;[内网安全] 内网渗透 - 学习手册-CSDN博客 0x01&#xff1a;注册表权限配置错误提权原理 通常 Windows 中的服务都是以 System 权限运行的&#xff0c;而 Windows 的服务程序的启动路径又是存放在注册表中的&#xff0c;若注册表配置不…

牛客周赛 Round 79

题目目录 A 小红的合数寻找解题思路参考代码 B 小红的小球染色解题思路参考代码 C 小红的二叉树解题思路参考代码 D 小红的“质数”寻找解题思路参考代码 E 小红的好排列解题思路参考代码 F 小红的小球染色期望解题思路参考代码 A 小红的合数寻找 \hspace{15pt} 小红拿到了一个…

Zookeeper入门部署(单点与集群)

本篇文章基于docker方式部署zookeeper集群&#xff0c;请先安装docker 目录 1. docker初期准备 2.启动zookeeper 2.1 单点部署 2.2 集群部署 3. Linux脚本实现快速切换启动关闭 1. docker初期准备 拉取zookeeper镜像 docker pull zookeeper:3.5.6 如果拉取时间过长&#xf…

【MySQL】MySQL经典面试题深度解析

文章目录 一、MySQL与C的深度结合1.1 为什么C项目需要MySQL&#xff1f;1.2 典型应用场景 二、基础概念面试题精讲2.1 存储引擎对比2.2 索引原理 三、C专项面试题解析3.1 连接池实现3.2 预处理语句3.3 批量操作优化 四、高级应用面试题剖析4.1 事务隔离级别4.2 锁机制详解4.3 查…

w190工作流程管理系统设计与实现

&#x1f64a;作者简介&#xff1a;多年一线开发工作经验&#xff0c;原创团队&#xff0c;分享技术代码帮助学生学习&#xff0c;独立完成自己的网站项目。 代码可以查看文章末尾⬇️联系方式获取&#xff0c;记得注明来意哦~&#x1f339;赠送计算机毕业设计600个选题excel文…

网络安全学习 day5

状态检测和会话技术 状态检测以 “ 数据流量 ” 为单位来对报文进行检测和转发。即对一条流量的第一个报文进行包过滤规 则检查&#xff0c;并将判断结果作为这条流量的 “ 状态 ” 记录下来 。对于该条流量的后续报文&#xff0c;直接根据这个 “ 状态 ”来判断是否转发还是…

4 前端前置技术(上):AJAX技术、Axios技术(前端发送请求)

文章目录 前言一、Ajax技术&#xff08;从服务端获取数据&#xff0c;发送各种请求&#xff09;0 接口文档管理&#xff1a;使用apipost等接口测试软件创建接口便于前端后端分离测试1 基本概念2 原生Ajax使用示例&#xff08;几年前的早期用法&#xff09; 二、 Axios技术(对原…

Node.js与嵌入式开发:打破界限的创新结合

文章目录 一、Node.js的本质与核心优势1.1 什么是Node.js?1.2 嵌入式开发的范式转变二、Node.js与嵌入式结合的四大技术路径2.1 硬件交互层2.2 物联网协议栈2.3 边缘计算架构2.4 轻量化运行时方案三、实战案例:智能农业监测系统3.1 硬件配置3.2 软件架构3.3 核心代码片段四、…

51c视觉~CV~合集10

我自己的原文哦~ https://blog.51cto.com/whaosoft/13241694 一、CV创建自定义图像滤镜 热图滤镜 这组滤镜提供了各种不同的艺术和风格化光学图像捕捉方法。例如&#xff0c;热滤镜会将图像转换为“热图”&#xff0c;而卡通滤镜则提供生动的图像&#xff0c;这些图像看起来…

OPENPPP2 —— VMUX_NET 多路复用原理剖析

在阅读本文之前&#xff0c;必先了解以下几个概念&#xff1a; 1、MUX&#xff08;Multiplexer&#xff09;&#xff1a;合并多个信号到单一通道。 2、DEMUX&#xff08;Demultiplexer&#xff09;&#xff1a;从单一通道分离出多个信号。 3、单一通道&#xff0c;可汇聚多个…

核心集:DeepCore: A Comprehensive Library for CoresetSelection in Deep Learning

目录 一、TL&#xff1b;DR 二、为什么研究核心集&#xff1f; 三、问题定义和如何做 3.1 问题定义 3.2 业界方法 3.2.1 基于几何的方法 3.2.2 基于不确定性的方法 3.2.3 基于误差/损失的方法 3.2.5 GraNd 和 EL2N 分数 3.2.6 重要性采样 3.2.7 基于决策边界的办法 …

MyBatis-Plus笔记-快速入门

大家在日常开发中应该能发现&#xff0c;单表的CRUD功能代码重复度很高&#xff0c;也没有什么难度。而这部分代码量往往比较大&#xff0c;开发起来比较费时。 因此&#xff0c;目前企业中都会使用一些组件来简化或省略单表的CRUD开发工作。目前在国内使用较多的一个组件就是…

Redis - String相关命令

目录 setgetmsetmgetsetnx、setex、psetexincr、incrby、decr、decrby、incrbyfloatappendgetrangesetrangestrlen字符串类型编码方式总结 Redis - String Redis存储的字符串&#xff0c;是直接按二进制方式存储&#xff0c;不会做任何编码转换&#xff0c;存的是什么&#xff…

优选算法合集————双指针(专题二)

好久都没给大家带来算法专题啦&#xff0c;今天给大家带来滑动窗口专题的训练 题目一&#xff1a;长度最小的子数组 题目描述&#xff1a; 给定一个含有 n 个正整数的数组和一个正整数 target 。 找出该数组中满足其和 ≥ target 的长度最小的 连续子数组 [numsl, numsl1, …

本地Ollama部署DeepSeek R1模型接入Word

目录 1.本地部署DeepSeek-R1模型 2.接入Word 3.效果演示 4.问题反馈 上一篇文章办公新利器&#xff1a;DeepSeekWord&#xff0c;让你的工作更高效-CSDN博客https://blog.csdn.net/qq_63708623/article/details/145418457?spm1001.2014.3001.5501https://blog.csdn.net/qq…