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 only
 safe 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 working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).

     3. Run the command with the repository temporarily disabled
            yum --disablerepo=kubernetes ...

     4. Disable the repository permanently, so yum won't use it by default. Yum
        will then just ignore the repository until you permanently enable it
        again or use --enablerepo for temporary usage:

            yum-config-manager --disable kubernetes
        or
            subscription-manager repos --disable=kubernetes

     5. 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 much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=kubernetes.skip_if_unavailable=true

failure: 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 condition
	This 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.mfbz.cn/a/316940.html

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

相关文章

ssm基于Javaweb的网上奶茶店系统的设计与实现论文

摘 要 计算机网络发展到现在已经好几十年了&#xff0c;在理论上面已经有了很丰富的基础&#xff0c;并且在现实生活中也到处都在使用&#xff0c;可以说&#xff0c;经过几十年的发展&#xff0c;互联网技术已经把地域信息的隔阂给消除了&#xff0c;让整个世界都可以即时通话…

助力工业园区作业违规行为检测预警,基于YOLOv8【n/s/m/l/x】全系列参数模型开发构建工业园区场景下作业人员违规行为检测识别系统

在很多工业园区生产作业场景下保障合规合法进行作业生产操作&#xff0c;对于保护工人生命安全降低安全隐患有着非常重要的作用&#xff0c;但是往往在实际的作业生产中&#xff0c;因为一个安全观念的淡薄或者是粗心大意&#xff0c;对于纪律约束等意思薄弱&#xff0c;导致在…

宝塔安装redis并且远程连接redis教程

第一步&#xff1a;搜索redis并安装 第二步&#xff1a;在防火墙添加端口6379 第三步&#xff1a;查看宝塔防火墙是否开启了6379端口 firewall-cmd --zonepublic --list-ports 很显然并没有开启 第四步&#xff1a;开启防火墙的6379端口 firewall-cmd --zonepublic --add-po…

Linux学习记录——사십이 高级IO(3)--- Poll型服务器

文章目录 1、认识poll接口2、实现3、特点 1、认识poll接口 #include <poll.h> int poll(struct pollfd *fds, nfds_t nfds, int timeout);// pollfd结构 struct pollfd {int fd; /* file descriptor */short events; /* requested events */short revents; /* returned…

Linux系统SSH远程管理服务

目录 一、SSH协议是什么&#xff1f; 1、SSH协议的定义&#xff1a; 2、SSH协议的优点 3、SSH的客户端与服务端 4、SSH的原理 4.1公钥首次连接原理 4.2ssh远程登录 4.3使用简单的SSH远程登录 二、OpenSSH服务器 1、OpenSSH简介 2、配置Openssh服务端 3、SSH服务的最…

Unity中URP中的光照简介

文章目录 前言URP下的光照在Unity中的设置1、主灯设置2、额外灯设置3、反射光设置 前言 我们在这篇文章开始了解URP下的光照。 URP下的光照在Unity中的设置 1、主灯设置 主灯可以选择 禁用 或 逐像素 光照 当选择逐像素光照的主灯后 Cast Shadows&#xff1a;可以选择开启 或…

CSS 流光发光按钮

<template><view class="content"><view class="a"><text></text><text></text><text></text><text></text>发光按钮</view></view></template><script></…

HTML标签(一)

目录 HTML语法规范 基本语法概述 标签关系 HTML基本结构标签 第一个HTML网页 开发工具 VSCode的使用&#xff1a; VScode工具生成骨架标签新增代码 文档类型声明标签 lang语言种类 字符集 总结 HTML常用标签 标签语义 标题标签 段落标签 换行标签 文本格式化…

如何公网远程访问Linux AMH服务器管理面板【内网穿透】

⛳️ 推荐 前些天发现了一个巨牛的人工智能学习网站&#xff0c;通俗易懂&#xff0c;风趣幽默&#xff0c;忍不住分享一下给大家。点击跳转到网站。 文章目录 ⛳️ 推荐1. Linux 安装AMH 面板2. 本地访问AMH 面板3. Linux安装Cpolar4. 配置AMH面板公网地址5. 远程访问AMH面板6…

【UEFI基础】EDK网络框架(ARP)

ARP ARP协议说明 从这里开始涉及到的网络协议都是比较通用的了&#xff0c;在一般的TCP/IP四层模型中都能够看到这些内容&#xff0c;不过这里主要介绍的还是其在BIOS下的实现&#xff0c;但是在此之前还是需要先说明ARP的作用。 ARP的全称是Address Resolution Protocol&am…

AI-数学-高中-4.函数表达式特性-要变一起变

求f(x):换元法&#xff1a;左边代换时&#xff0c;右边也要同时替换&#xff0c;原作者视频&#xff1a;函数】1引导课&#xff1a;高中为什么用f(x)_哔哩哔哩_bilibili 1.什么是函数&#xff1a;给定任意一个x&#xff0c;都有唯一确定的y与之对应&#xff0c;这种x与y的关系就…

如何提高匹配的精确度(多次学习)

我们工业自动化中&#xff0c;视觉软件匹配&#xff0c;都是学习一次&#xff0c;比如找到轮廓&#xff0c;旋转360度&#xff0c;也就是有360个轮廓&#xff0c;然后到图像中去找任意角度的目标。 这样的学习并不能一而概括全。 所以&#xff0c;我借鉴ai的方法&#xff0c;…

【计算机组成原理】指令流水线的三种冒险情况(Hazards)

冒险 在计算机架构中&#xff0c;流水线冒险是指在指令流水线的执行过程中由于数据相关性或控制相关性而导致的一种性能问题。指令流水线是将指令执行过程划分为多个阶段&#xff0c;这样可以同时处理多条指令&#xff0c;从而提高指令执行的效率。然而&#xff0c;流水线执行…

阳光保险选择OceanBase稳定运行超700天

阳光保险集团成立于 2005 年 7 月&#xff0c;旗下拥有财产保险、人寿保险、信用保证保险、资产管理等多家专业子公司&#xff0c;是全球市场化企业中成长最快的集团公司之一&#xff0c;目前位列中国保险行业前八。随着数字化升级趋势的不断加速&#xff0c;很多企业产生将软硬…

Kali Linux——aircrack-ng无线教程

目录 一、准备 二、案例 1、连接usb无线网卡 2、查看网卡信息 3、开启网卡监听 4、扫描wifi信号 5、抓取握手包 6、强制断开连接 7、破解握手包 三、预防 一、准备 1、usb无线网卡&#xff08;笔记本也是需要用到&#xff09; 2、密码字典&#xff08;Kali 系统自带…

微信小程序 全局配置||微信小程序 页面配置||微信小程序 sitemap配置

全局配置 小程序根目录下的 app.json 文件用来对微信小程序进行全局配置&#xff0c;决定页面文件的路径、窗口表现、设置网络超时时间、设置多 tab 等。 以下是一个包含了部分常用配置选项的 app.json &#xff1a; {"pages": ["pages/index/index",&q…

软件设计考试相关信息

简单介绍 软考是国家人力资源和社会保障部、工业和信息化部联合组织实施的国家级考试&#xff0c;参加计算机软件资格考试并取得相应级别的资格证书&#xff0c;是各用人单位聘用计算机技术与软件专业工程师系列职务的前提。计算机软件资格考试&#xff0c;与会计、经济师、税…

2024年广东省安全员C证第四批(专职安全生产管理人员)证模拟考试题库及广东省安全员C证第四批(专职安全生产管理人员)理论考试试题

题库来源&#xff1a;安全生产模拟考试一点通公众号小程序 2024年广东省安全员C证第四批&#xff08;专职安全生产管理人员&#xff09;证模拟考试题库及广东省安全员C证第四批&#xff08;专职安全生产管理人员&#xff09;理论考试试题是由安全生产模拟考试一点通提供&#…

科大讯飞星火大模型接入API js 部分 接口 安装注意事项

下载以下链接例子运行程序 https://xfyun-doc.xfyun.cn/static%2F16968175055332330%2Fspark_js_demo.zip 官网给的说明 准备 1.在demo中填写APPID、APISecret、APIKey&#xff0c;可到控制台-我的应用-大模型页面获取 2.安装nodejs 本地运行 1.打开cmd&#xff0c;进入dem…

CSS 下载进度条

<template><view class=btn>下载中</view></template><script></script><style>/* 设置整个页面的样式 */body {width: 100vw; /* 页面宽度为视口宽度 */background: #000000; /* 背景颜色为白色 */display: flex; /* 使用 flex…
最新文章