Centos7安装K8S

Centos7安装K8S


安装过程中没有出现的错误可以往下

根据以前一些博主写的博客,在小阳翻了不下几十篇博客之后,我果断是放弃了,于是找到了官网地址,然后也有

1. 关闭防火墙

systemctl stop firewalld
systemctl disable firewalld

2. 关闭 selinux(2,3根据自己情况选择哈)

sed -i 's/enforcing/disabled/' /etc/selinux/config 这个是永久关闭
setenforce 0 临时关闭是这个哟

3、关闭 swap

swapoff -a # 临时关闭
vim /etc/fstab # 永久关闭
#注释掉 /dev/mapper/centos-swap swap swap defaults 0 0 这行
然后呢
systemctl reboot #重启生效
free ‐m #查看下swap交换区是否都为0,如果都为0则swap关闭成功

4.给三台机器分别设置主机名

hostnamectl set‐hostname 主机名称
第一台:k8s-master 第二台:k8s-node1 第三台:k8s-node2

5.在 k8s-master机器添加hosts,注意ip地址哟
cat >> /etc/hosts << EOF
192.168.2.64 k8s-master
192.168.2.59 k8s-node1
192.168.2.51 k8s-node2
EOF
6.将桥接的IPv4流量传递到iptables
cat > /etc/sysctl.d/k8s.conf << EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF

需要让它生效哈
sysctl --system

7.设置时间
yum install ntpdate -y
ntpdate -u ntp.api.bz
出现
21 Mar 17:07:17 ntpdate[3124]: adjust time server 114.118.7.161 offset 0.013776 sec
即为成功注意我的日期为2022321日,日期和你自己对上即可
8. yum源切换与yum k8s

此处有bug切记别着急复制粘贴,请往下看

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=1
repo_gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF
setenforce 0
yum install -y kubelet kubeadm kubectl ------ 坑在这呢
systemctl enable kubelet && systemctl start kubelet #开机启动kubelet

ps: 由于官网未开放同步方式, 可能会有索引gpg检查失败的情况, 这时请用 yum install -y --nogpgcheck kubelet kubeadm kubectl 安装<<<<<<<<<这是官网写的字体老小了
这是报的错

https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/repodata/repomd.xml: [Errno -1] repomd.xml signature could not be verified for kubernetes
Trying other mirror.One of the configured repositories failed (Kubernetes),and yum doesn't have enough cached data to continue. At this point the onlysafe thing yum can do is fail. There are a few ways to work "fix" this:1. Contact the upstream for the repository and get them to fix the problem.2. Reconfigure the baseurl/etc. for the repository, to point to a workingupstream. This is most often useful if you are using a newerdistribution release than is supported by the repository (and thepackages for the previous distribution release still work).3. Run the command with the repository temporarily disabledyum --disablerepo=kubernetes ...4. Disable the repository permanently, so yum won't use it by default. Yumwill then just ignore the repository until you permanently enable itagain or use --enablerepo for temporary usage:yum-config-manager --disable kubernetesorsubscription-manager repos --disable=kubernetes5. Configure the failing repository to be skipped, if it is unavailable.Note that yum will try to contact the repo. when it runs most commands,so will have to try and fail each time (and thus. yum will be be muchslower). If it is a very temporary problem though, this is often a nicecompromise:yum-config-manager --save --setopt=kubernetes.skip_if_unavailable=truefailure: repodata/repomd.xml from kubernetes: [Errno 256] No more mirrors to try.

这是正确的配置

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=1
repo_gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF
setenforce 0
yum install -y --nogpgcheck kubelet kubeadm kubectl
systemctl enable kubelet && systemctl start kubelet

此处需要注意(9、10)均在k8s-master机器上执行指令

9.初始化

ip为master的ip地址,其次注意版本,剩下的无需改动

kubeadm init --apiserver-advertise-address=192.168.2.64 --image-repository registry.aliyuncs.com/google_containers --kubernetes-version v1.23.0 --service-cidr=10.96.0.0/12 --pod-network-cidr=10.244.0.0/16

这行执行的话需要注意至少两个cpu,就是红色框框里面的数字是个2就行
在这里插入图片描述
改完之后呢,有报错了/(ㄒoㄒ)/~~

[kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Get "http://localhost:10248/healthz": dial tcp [::1]:10248: connect: connection refused.Unfortunately, an error has occurred:timed out waiting for the conditionThis error is likely caused by:- The kubelet is not running- The kubelet is unhealthy due to a misconfiguration of the node in some way (required cgroups disabled)If you are on a systemd-powered system, you can try to troubleshoot the error with the following commands:- 'systemctl status kubelet'- 'journalctl -xeu kubelet'Additionally, a control plane component may have crashed or exited when started by the container runtime.To troubleshoot, list all containers using your preferred container runtimes CLI.Here is one example how you may list all Kubernetes containers running in docker:- 'docker ps -a | grep kube | grep -v pause'Once you have found the failing container, you can inspect its logs with:- 'docker logs CONTAINERID'
error execution phase wait-control-plane: couldn't initialize a Kubernetes cluster
To see the stack trace of this error execute with --v=5 or higher

处理办法详见<<<此处有个超链接

当初始化完成之后出现红色框框即为初始化成功,下面的绿色框框为下来所需要执行的指令
在这里插入图片描述

10.配置 kubectl 命令工具
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

然后验证一下
kubectl get nodes

安装 Pod 网络插件
kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml
不成功的话
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kubeflannel.yml

那么此处需要在node节点的两台机器上执行这一行指令,这个指令就是上图初始化完成蓝色框框中的

kubeadm join 192.168.2.64:6443 --token bxtr03.7ekvjxxyx57dh2nz --discovery-token-ca-cert-hash sha256:5f41464af9fab2003b357d445a9927445e3ad540872b01e07bb3e85995a30e65

本小阳此处是报错了的
unexpected kernel config: CONFIG_CGROUP_PIDS

解决第一个error为以下指令
echo "1" >/proc/sys/net/bridge/bridge-nf-call-iptables
地址: https://blog.csdn.net/m0_47219942/article/details/110873272

剩下两个问题主要是内核版本过低导致的,详细可见CentOS7升级内核并启用BBR
此时已是开始搭建的一周后了,因为总是忘记,此时报的错误

error execution phase preflight: couldn't validate the identity of the API Server: could not find a JWS signature in the cluster-info ConfigMap for token ID "bxtr03"

Token过期,那么此时需要重新生成
https://blog.csdn.net/YouMing_Li/article/details/117553658
此时再次执行

kubeadm reset

之后重新加入主节点之后
在这里插入图片描述
此时的报错含义为

kubelet没有运行  
kubelet是不健康的,因为节点在某种程度上配置错误(需要禁用cgroups)  

此处结局方案,原文链接
在这里插入图片描述

然后呢

kubectl get nodes

在这里插入图片描述
上面红色框中的NotReady状态解决,链接

下面开始测试
kubectl create deployment nginx --image=nginx
kubectl expose deployment nginx --port=80 --type=NodePort
kubectl get pod,svc -o wide

执行完需要注意端口号
在这里插入图片描述
完了之后三台机器都可以通过此端口访问到
在这里插入图片描述
此时已经完了哈
在这里插入图片描述

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

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

相关文章

MySQL的各种日志

目录 一、错误日志 二、二进制日志 1、介绍 2、作用 3、相关信息 4、日志格式 5、查看二进制文件 6、二进制日志文件删除 三、查询日志 四、慢日志 一、错误日志 记录MySQL在启动和停止时&#xff0c;以及服务器运行过程中发生的严重错误的相关信息&#xff0c;当数据库…

Hive使用shell调用命令行特殊字符处理

1.场景分析 数据处理常用hive -e的方式&#xff0c;通过脚本操作数仓&#xff0c;过程中常常遇到特殊字符的处理&#xff0c;如单双引号、反斜杠、换行符等&#xff0c;现将特殊字符用法总结使用如下&#xff0c;可直接引用&#xff0c;避免自行测试的繁琐。 2.特殊字符处理 …

16.桥接模式

桥接模式 介绍 桥接模式是一种结构型设计模式&#xff0c;它通过将抽象部分与实现部分分离&#xff0c;使它们可以独立变化。这种模式通过组合的方式来实现&#xff0c;而不是继承。桥接模式通过将抽象和实现解耦&#xff0c;从而实现抽象和实现的分离&#xff0c;使得系统更加…

Java零基础——Vue基础篇

1.【熟悉】Vue简介 1.1 简介 它是一个构建用户界面单页面的框架 Vue是一个前端框架 https://www.pmdaniu.com/#file UI网站 UI 一般开发者使用蓝湖 工具 看着UI图 写接口 https://lanhuapp.com/web/#/item 是一个轻量级的MVVM&#xff08;Model-View-ViewModel&#xff…

Spring Boot - Application Events 的发布顺序_ApplicationStartingEvent

文章目录 概述Code源码分析 概述 Spring Boot 的广播机制是基于观察者模式实现的&#xff0c;它允许在 Spring 应用程序中发布和监听事件。这种机制的主要目的是为了实现解耦&#xff0c;使得应用程序中的不同组件可以独立地改变和复用逻辑&#xff0c;而无需直接进行通信。 …

VMware虚拟机忘记密码操作方法

下面已openEuler虚拟机为例&#xff1a; 1、点击重启时&#xff0c;一直按esc&#xff08;鼠标点击一下&#xff0c;确保鼠标在你的虚拟机里面&#xff09; 2、一直到进入到如下页面按e键&#xff08;可能会略有不同&#xff09; 3、按e键后跳转到如下页面 4、在该页面输入 in…

高级定时器

本节主要介绍以下内容&#xff1a; 定时器简介 高级定时器功能框图讲解 一、定时器简介 定时器功能 &#xff1a;定时、输出比较、输入捕获、断路输入 定时器分类 &#xff1a;基本定时器、通用定时器、高级定时器 定时器资源 &#xff1a;F103有2个高级定时器、4个通…

c语言-数据类型(下)

目录 4.实型变量 5.字符常量 直接常量&#xff1a; 转义字符&#xff1a; 6.字符变量 7.字符串常量 五、输出格式总结 整型&#xff1a; 浮点型&#xff1a; 字符及字符串&#xff1a; 指针&#xff08;地址&#xff09;&#xff1a; 六、typedef 七、sizeof一个问…

Matlab并行编程之GPU

Matlab并行编程之GPU Matlab提供GPU上计算支持: 基础数据类型(gpuArray和对应API),支持GPU计算的内置函数和多个工具包,支持PTX内核对象加载,支持MEX函数使用CUDA C/C开发等。对大规模数据处理&#xff0c;复杂计算&#xff0c;利用GPU计算能提供显著的性能加速效果. Matlab同…

Docker之网络配置的使用

&#x1f389;&#x1f389;欢迎来到我的CSDN主页&#xff01;&#x1f389;&#x1f389; &#x1f3c5;我是君易--鑨&#xff0c;一个在CSDN分享笔记的博主。&#x1f4da;&#x1f4da; &#x1f31f;推荐给大家我的博客专栏《Docker之网络配置的使用》。&#x1f3af;&…

OpenHarmony——Linux之IR驱动

Linux之IR驱动 背景 在光谱中波长自760nm至400um的电磁波称为红外线&#xff0c;它是一种不可见光。红外遥控成本很低&#xff0c;以前广泛应用在电视&#xff0c;空调等电器的控制上面&#xff0c;现在随着蓝牙遥控器慢慢普及&#xff0c;红外遥控越来越少&#xff0c;但在某…

图像处理:孤立点的检测

图像处理-孤立点的检测 孤立点的检测在图像处理中通常涉及到检测图像中的突变或者边缘&#xff0c;而使用二阶导数是一种常见的方法。一阶导数可以帮助找到图像中的边缘&#xff0c;而二阶导数则有助于检测边缘上的峰值&#xff0c;这些峰值可能对应于孤立点或者特殊的图像结构…

AI大模型预先学习笔记二:prompt提问大模型、langchain使用大模型框架、fine tune微调大模型

文章目录 一、Prompt Engineering&#xff08;怎么去提问大模型&#xff09;1&#xff09;环境准备2&#xff09;交互代码的参数备注3&#xff09;交互代码 二、LangChain&#xff08;一个框架去使用大模型&#xff09;1&#xff09;LangChain核心介绍&#xff1a;I/O模块、数据…

TypeError: (0 , _ahooks.createUpdateEffect) is not a function

版本 "next": "14.0.4", "antd-mobile": "^5.34.0", next中使用antd-mobile可困难了.主要是因为antd-mobile不支持ssr 1.下载antd-mobile包,在next.config.js中加入 transpilePackages: [antd-mobile,], 2.在页面中引入antd-mobi…

蓝桥杯备赛day02 -- 算法训练题 拿金币Java

目录 题目&#xff1a; 问题描述 输入格式 输出格式 解题过程 第一步 定义dp数组 第二步 确定 dp 数组递推公式 第三步 dp数组的初始化 第四步 dp数组的遍历顺序 第五步 举例说明 报错&#xff1a;内存超限 用dp数组去存储位置上的金币 dp数组从二维降为一维 收获&a…

【MCAL】MCU模块详解

目录 前言 正文 1. MCU模块介绍 2. MCU依赖的模块 3. MCU模块提供服务 3.1 时钟的初始化 3.2 MCU模式的配置 3.3 MCU软件复位功能 3.4 RAM的初始化 4.MCU重要数据类型 4.1 Mcu_ResetType 4.2 Mcu_ModeType 5. MCU重要API 5.1 Mcu_Init 5.2 Mcu_InitClock 5.3 M…

信息系统安全——Linux 访问控制机制分析

实验 4 Linux 访问控制机制分析 4.1 实验名称 《Linux 访问控制机制分析》 4.2 实验目的 1 、熟悉 Linux基本访问控制机制使用和原理 2 、熟悉 Linux S 位的作用和使用 3 、熟悉强制访问控制 Selinux 原理及其使用 4.3 实验步骤及内容 1 、Linux 基本访问控制机制 &#xff08…

vue el-table 多选框回填

主要代码: //选中列&#xff0c;所有列&#xff0c;表名toggleSelection(selectRows, totalRows, tablename) {this.$refs.table.clearSelection();if (selectRows.length > 0) {this.$nextTick(() > {selectRows.forEach(item > {totalRows.forEach(item1 > {if (…

C语言天花板——指针(经典题目)

指针我们已经学习的差不多了&#xff0c;今天我来给大家分享几个经典的题目&#xff0c;来让我们相互学习&#x1f3ce;️&#x1f3ce;️&#x1f3ce;️ int main() {int a[4] { 1, 2, 3, 4 };int* ptr1 (int*)(&a 1);int* ptr2 (int*)((int)a 1);printf("%x,%…

连锁品牌如何引流获客?小魔推短视频矩阵助你流量爆棚

近几年因为大环境的影响&#xff0c;大多数实体行业的生意都不太好做&#xff0c;为了帮助更多实体行业提升品牌知名度&#xff0c;带来更多的流量与转化&#xff0c;餐赞小魔推也在不断的更新迭代&#xff0c;同时考虑到了单门店与连锁品牌使用的便捷性。 目前针对连锁品牌方&…