linux 使用kubeadm安装部署K8S

上一节,安装了docker-20.10.14版本

安装kubeadm,kubelet和kubectl

由于版本更新频繁,这里指定版本号部署

 yum  install kubelet-1.23.4-0 kubeadm-1.23.4-0 kubectl-1.23.4-0 -y
Loaded plugins: fastestmirror
Repository epel is listed more than once in the configuration
Repository epel-debuginfo is listed more than once in the configuration
Repository epel-source is listed more than once in the configuration
Loading mirror speeds from cached hostfile* base: mirrors.aliyun.com* extras: mirrors.aliyun.com* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package kubeadm.x86_64 0:1.23.4-0 will be installed
--> Processing Dependency: kubernetes-cni >= 0.8.6 for package: kubeadm-1.23.4-0.x86_64
---> Package kubectl.x86_64 0:1.23.4-0 will be installed
---> Package kubelet.x86_64 0:1.23.4-0 will be installed
--> Running transaction check
---> Package kubernetes-cni.x86_64 0:1.2.0-0 will be installed
--> Finished Dependency ResolutionDependencies Resolved===================================================================================================================Package                        Arch                   Version                    Repository                  Size
===================================================================================================================
Installing:kubeadm                        x86_64                 1.23.4-0                   kubernetes                 9.0 Mkubectl                        x86_64                 1.23.4-0                   kubernetes                 9.5 Mkubelet                        x86_64                 1.23.4-0                   kubernetes                  21 M
Installing for dependencies:kubernetes-cni                 x86_64                 1.2.0-0                    kubernetes                  17 MTransaction Summary
===================================================================================================================
Install  3 Packages (+1 Dependent package)Total download size: 56 M
Installed size: 255 M
Downloading packages:
(1/4): c8a17896ac2f24c43770d837f9f751acf161d6c33694b5dad42f5f638c6dd626-kubeadm-1.23.4-0.x8 | 9.0 MB  00:00:20     
(2/4): ae22dad233f0617861909955e30f527067e6f5535c1d1a9cda7b3a288fe62cd2-kubectl-1.23.4-0.x8 | 9.5 MB  00:00:20     
(3/4): 7a0d50ba594f62deddd266db3400d40a3b7 92% [==============================   ] 892 kB/s |  52 MB  00:00:05 ETA 
(3/4): 0f2a2afd740d476ad77c508847bad1f559afc2425816c1f2ce4432a62dfe0b9d-kubernetes-cni-1.2. |  17 MB  00:00:38     
(4/4): 7a0d50ba594f62deddd266db3400d40a3b745be71f10684faa9c1632aca50d6b-kubelet-1.23.4-0.x8 |  21 MB  00:00:47     
-------------------------------------------------------------------------------------------------------------------
Total                                                                              845 kB/s |  56 MB  00:01:07     
Running transaction check
Running transaction test
Transaction test succeeded
Running transactionInstalling : kubelet-1.23.4-0.x86_64                                                                         1/4 Installing : kubernetes-cni-1.2.0-0.x86_64                                                                   2/4 Installing : kubectl-1.23.4-0.x86_64                                                                         3/4 Installing : kubeadm-1.23.4-0.x86_64                                                                         4/4 Verifying  : kubeadm-1.23.4-0.x86_64                                                                         1/4 Verifying  : kubernetes-cni-1.2.0-0.x86_64                                                                   2/4 Verifying  : kubelet-1.23.4-0.x86_64                                                                         3/4 Verifying  : kubectl-1.23.4-0.x86_64                                                                         4/4 Installed:kubeadm.x86_64 0:1.23.4-0             kubectl.x86_64 0:1.23.4-0             kubelet.x86_64 0:1.23.4-0            Dependency Installed:kubernetes-cni.x86_64 0:1.2.0-0                                                                                  Complete!

启动kubelet

# systemctl start kubelet
[root@host-10-19-83-151 docker]# systemctl status  kubelet.service 
● kubelet.service - kubelet: The Kubernetes Node AgentLoaded: loaded (/usr/lib/systemd/system/kubelet.service; enabled; vendor preset: disabled)Drop-In: /usr/lib/systemd/system/kubelet.service.d└─10-kubeadm.confActive: activating (auto-restart) (Result: exit-code) since Tue 2024-03-26 16:37:12 CST; 8s agoDocs: https://kubernetes.io/docs/Process: 8613 ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS (code=exited, status=1/FAILURE)Main PID: 8613 (code=exited, status=1/FAILURE)Mar 26 16:37:12 host-10-19-83-151 systemd[1]: Unit kubelet.service entered failed state.
Mar 26 16:37:12 host-10-19-83-151 systemd[1]: kubelet.service failed.

查看日志journalctl -xe

Failed to load kubelet config file" err="failed to load Kubelet config file /var/lib/kubelet/config.yaml, error failed to read kubelet config file \"/var/lib/kubelet/config.yaml\"

原因是这台机器,原来有过kubernutes环境,需要环境初始化

#  kubeadm init \
>  --apiserver-advertise-address=10.18.18.18 \
>  --image-repository registry.aliyuncs.com/google_containers \
>  --kubernetes-version v1.23.4 \
>  --service-cidr=10.96.0.0/12 \
>  --pod-network-cidr=10.244.0.0/16 \
>  --ignore-preflight-errors=all
[init] Using Kubernetes version: v1.23.4
[preflight] Running pre-flight checks
[preflight] Pulling images required for setting up a Kubernetes cluster
[preflight] This might take a minute or two, depending on the speed of your internet connection
[preflight] You can also perform this action in beforehand using 'kubeadm config images pull'
[certs] Using certificateDir folder "/etc/kubernetes/pki"
[certs] Generating "ca" certificate and key
[certs] Generating "apiserver" certificate and key
[certs] apiserver serving cert is signed for DNS names [host-10-19-83-151 kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 10.19.83.151]
[certs] Generating "apiserver-kubelet-client" certificate and key
[certs] Generating "front-proxy-ca" certificate and key
[certs] Generating "front-proxy-client" certificate and key
[certs] Generating "etcd/ca" certificate and key
[certs] Generating "etcd/server" certificate and key
[certs] etcd/server serving cert is signed for DNS names [host-10-19-83-151 localhost] and IPs [10.19.83.151 127.0.0.1 ::1]
[certs] Generating "etcd/peer" certificate and key
[certs] etcd/peer serving cert is signed for DNS names [host-10-19-83-151 localhost] and IPs [10.19.83.151 127.0.0.1 ::1]
[certs] Generating "etcd/healthcheck-client" certificate and key
[certs] Generating "apiserver-etcd-client" certificate and key
[certs] Generating "sa" key and public key
[kubeconfig] Using kubeconfig folder "/etc/kubernetes"
[kubeconfig] Writing "admin.conf" kubeconfig file
[kubeconfig] Writing "kubelet.conf" kubeconfig file
[kubeconfig] Writing "controller-manager.conf" kubeconfig file
[kubeconfig] Writing "scheduler.conf" kubeconfig file
[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
[kubelet-start] Starting the kubelet
[control-plane] Using manifest folder "/etc/kubernetes/manifests"
[control-plane] Creating static Pod manifest for "kube-apiserver"
[control-plane] Creating static Pod manifest for "kube-controller-manager"
[control-plane] Creating static Pod manifest for "kube-scheduler"
[etcd] Creating static Pod manifest for local etcd in "/etc/kubernetes/manifests"
[wait-control-plane] Waiting for the kubelet to boot up the control plane as static Pods from directory "/etc/kubernetes/manifests". This can take up to 4m0s
[apiclient] All control plane components are healthy after 34.003860 seconds
[upload-config] Storing the configuration used in ConfigMap "kubeadm-config" in the "kube-system" Namespace
[kubelet] Creating a ConfigMap "kubelet-config-1.23" in namespace kube-system with the configuration for the kubelets in the cluster
NOTE: The "kubelet-config-1.23" naming of the kubelet ConfigMap is deprecated. Once the UnversionedKubeletConfigMap feature gate graduates to Beta the default name will become just "kubelet-config". Kubeadm upgrade will handle this transition transparently.
[upload-certs] Skipping phase. Please see --upload-certs
[mark-control-plane] Marking the node host-10-19-83-151 as control-plane by adding the labels: [node-role.kubernetes.io/master(deprecated) node-role.kubernetes.io/control-plane node.kubernetes.io/exclude-from-external-load-balancers]
[mark-control-plane] Marking the node host-10-19-83-151 as control-plane by adding the taints [node-role.kubernetes.io/master:NoSchedule]
[bootstrap-token] Using token: q4r3j6.w1ilfk5gal5z6e9n
[bootstrap-token] Configuring bootstrap tokens, cluster-info ConfigMap, RBAC Roles
[bootstrap-token] configured RBAC rules to allow Node Bootstrap tokens to get nodes
[bootstrap-token] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials
[bootstrap-token] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token
[bootstrap-token] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster
[bootstrap-token] Creating the "cluster-info" ConfigMap in the "kube-public" namespace
[kubelet-finalize] Updating "/etc/kubernetes/kubelet.conf" to point to a rotatable kubelet client certificate and key
[addons] Applied essential addon: CoreDNS
[addons] Applied essential addon: kube-proxyYour Kubernetes control-plane has initialized successfully!To start using your cluster, you need to run the following as a regular user:mkdir -p $HOME/.kubesudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/configsudo chown $(id -u):$(id -g) $HOME/.kube/configAlternatively, if you are the root user, you can run:export KUBECONFIG=/etc/kubernetes/admin.confYou should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:https://kubernetes.io/docs/concepts/cluster-administration/addons/Then you can join any number of worker nodes by running the following on each as root:kubeadm join 10.18.18.18:6443 --token q4r3j6.w133333333z6e9n \--discovery-token-ca-cert-hash sha256:c3580c9a2903e42222222222222222222289a469ef60b85de260015f180690a129

初始化就是成功的。

查看node状态,是notReady

# kubectl get nodes
NAME                STATUS     ROLES                  AGE     VERSION
host-10-19-83-151   NotReady   control-plane,master   6m42s   v1.23.4

安装网络插件

# kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
namespace/kube-flannel created
clusterrole.rbac.authorization.k8s.io/flannel created
clusterrolebinding.rbac.authorization.k8s.io/flannel created
serviceaccount/flannel created
configmap/kube-flannel-cfg created
daemonset.apps/kube-flannel-ds created

kubelet运行正常

# systemctl status kubelet.service 
● kubelet.service - kubelet: The Kubernetes Node AgentLoaded: loaded (/usr/lib/systemd/system/kubelet.service; enabled; vendor preset: disabled)Drop-In: /usr/lib/systemd/system/kubelet.service.d└─10-kubeadm.confActive: active (running) since Tue 2024-03-26 16:52:52 CST; 1min 50s agoDocs: https://kubernetes.io/docs/Main PID: 11727 (kubelet)Tasks: 19Memory: 34.0MCGroup: /system.slice/kubelet.service└─11727 /usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/...Mar 26 16:54:18 host-10-19-83-151 kubelet[11727]: E0326 16:54:18.695760   11727 kubelet.go:2347] "Container ...zed"
Mar 26 16:54:22 host-10-19-83-151 kubelet[11727]: I0326 16:54:22.926785   11727 cni.go:240] "Unable to updat...t.d"
Mar 26 16:54:23 host-10-19-83-151 kubelet[11727]: E0326 16:54:23.718069   11727 kubelet.go:2347] "Container ...zed"
Mar 26 16:54:27 host-10-19-83-151 kubelet[11727]: I0326 16:54:27.927646   11727 cni.go:240] "Unable to updat...t.d"
Mar 26 16:54:28 host-10-19-83-151 kubelet[11727]: E0326 16:54:28.739272   11727 kubelet.go:2347] "Container ...zed"
Mar 26 16:54:32 host-10-19-83-151 kubelet[11727]: I0326 16:54:32.928423   11727 cni.go:240] "Unable to updat...t.d"
Mar 26 16:54:33 host-10-19-83-151 kubelet[11727]: E0326 16:54:33.765686   11727 kubelet.go:2347] "Container ...zed"
Mar 26 16:54:37 host-10-19-83-151 kubelet[11727]: I0326 16:54:37.928958   11727 cni.go:240] "Unable to updat...t.d"
Mar 26 16:54:38 host-10-19-83-151 kubelet[11727]: E0326 16:54:38.784954   11727 kubelet.go:2347] "Container ...zed"
Mar 26 16:54:42 host-10-19-83-151 kubelet[11727]: I0326 16:54:42.929909   11727 cni.go:240] "Unable to updat...t.d"
Hint: Some lines were ellipsized, use -l to show in full.

查看k8s环境

kubectl get nodes
NAME                STATUS   ROLES                  AGE   VERSION
host-10-10-10-10    Ready    control-plane,master   22m   v1.23.4[root@host-10-10-10-10 yum.repos.d]# kubectl get po -A 
NAMESPACE      NAME                                        READY   STATUS    RESTARTS   AGE
kube-flannel   kube-flannel-ds-lpm9c                       1/1     Running   0          16m
kube-system    coredns-6d8c4cb4d-sml87                     1/1     Running   0          22m
kube-system    coredns-6d8c4cb4d-w4hgz                     1/1     Running   0          22m
kube-system    etcd-host-10-10-10-10                       1/1     Running   160        22m
kube-system    kube-apiserver-host-10-10-10-10             1/1     Running   0          22m
kube-system    kube-controller-manager-host-10-10-10-10    1/1     Running   0          22m
kube-system    kube-proxy-6ct9f                            1/1     Running   0          22m
kube-system    kube-scheduler-host-10-19-83-151            1/1     Running   3024       22m

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

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

相关文章

提升自己最快的方式是什么?

提升自己最快的方式通常涉及到个人成长的各个方面,包括心理、情感、技能和知识等。根据查阅到的资料,以下是一些具体的方法和步骤,帮助你快速提升自己: 1. 培养屏蔽力 荷兰畅销书作家罗伊马丁纳提到,屏蔽力是个人成长…

实现恒功率控制丨极海APM32F035高压灌溉水泵参考方案

直流无刷电机用途广泛,具有高效节能、使用寿命长、运行可靠无电火花、结构简单易维护等性能优势,在办公设备、智能家居、消费家电、工业设备、医疗设备等领域已规模化落地。随着智能化技术与成本的持续优化,BLDC应用将进一步提升在各行业的渗…

OpenAI官宣,ChatGPT免登录使用

昨天,就在愚人节当天,OpenAI突然宣布ChatGPT3.5向所有人开放,意思是即使没有注册OpenAI的账号,也能体验ChatGPT,就像浏览器一样,联接即可使用。 消息一出,OpenAI的官网直接被大量的用户挤挂了。…

axios 封装 http 请求详解

前言 Axios 是一个基于 Promise 的 HTTP 库,它的概念及使用方法本文不过多赘述,请参考:axios传送门 本文重点讲述下在项目中是如何利用 axios 封装 http 请求。 一、预设全局变量 在 /const/preset.js 中配置预先设置一些全局变量 window.…

adobe stock会员开通付费付款订阅充值教程/adobe stock免费白嫖一个月

登录adobe stock的官网,点击你想要下载的视频,然后点击免费下载,我们点击免费试用按钮,可以看到非常贵,需要80美金一个月,用fomepay可以免费白嫖一个月 点击获取一张虚拟信用卡,就可以白嫖一个…

配mmdetection

1. 安装conda 链接后面补上 2. 装pytorch,版本别装错了 Start Locally | PyTorch用这里面的命令 nvcc --version看cuda版本(实验室服务器是11.0,可以用这个11.8的 ) 检查torch和cuda版本的命令: import torch # …

C语言:二叉树的构建

目录 一、二叉树的存储 1.1 顺序存储 1.2 链式存储 二、二叉树的顺序结构及实现 2.1堆的概念及结构 2.2堆的构建 2.3堆的插入 2.4堆顶的删除 2.5堆的完整代码 三、二叉树的链式结构及实现 3.1链式二叉树的构建 3.2链式二叉树的遍历 3.2.1前序遍历 …

鸿蒙原OS开发实例:【ArkTS类库单次I/O任务开发】

Promise和async/await提供异步并发能力,适用于单次I/O任务的场景开发,本文以使用异步进行单次文件写入为例来提供指导。 实现单次I/O任务逻辑。 import fs from ohos.file.fs; import common from ohos.app.ability.common;async function write(data:…

计算机学生求职简历的一些想法

面试真的是一件非常难的事情,因为在短短的半小时到一个小时,来判断一个同学行不行,其实是很不全面的。作为一个求职的同学应该怎么办呢?求职的同学可以提前做一些准备,其中比较重要的要数简历的编写。 简历的作用 简…

深入解析大数据体系中的ETL工作原理及常见组件

** 引言 关联阅读博客文章:探讨在大数据体系中API的通信机制与工作原理 关联阅读博客文章:深入理解HDFS工作原理:大数据存储和容错性机制解析 ** 在当今数字化时代,大数据处理已经成为了企业成功的重要组成部分。而在大数据处…

OpenHarmony实战:小型系统 STM32MP1 芯片移植案例

本文章基于意法半导体 STM32MP157 芯片的小熊派 BearPi-HM Micro 开发板,进行小型带屏开发板的移植,实现了 ace_engine_lite、arkui_ui_lite、aafwk_lite、appexecfwk_lite、HDF 等部件基于 OpenHarmony LiteOS-A 内核的适配。移植架构上采用 Board 与 S…

shopee虾皮怎么分析竞品?这些技巧能帮你提升出单量90%+

“竞品分析”长久以来都是运营所纠结的核心问题,没有分析出对标竞品怎么增长销量,却被其他竞品给町上了,导致自身销量不增反减。这种情况我们是无法直观从自身的店铺及商品本身去找到原因的,本质的问题在竞品身上。我们无法控制有…

基于RDMA的云服务能力实践与探索

01 背景 随着基于大数据大模型构建的数据系统越来越有商业价值,机器学习的玩家也越来越多,数据量越来越大。为解决海量数据在服务器之间的同步效率问题,RDMA(Remote Direct Memory Access) 技术逐渐走进了网络技术人员的视野。RDMA为什么…

鸿鹄工程项目管理系统源码:Spring Boot带来的快速开发与部署体验

随着企业规模的不断扩大和业务的快速发展,传统的工程项目管理方式已经无法满足现代企业的需求。为了提高工程管理效率、减轻劳动强度、提高信息处理速度和准确性,企业需要借助先进的数字化技术进行转型。本文将介绍一款采用Spring CloudSpring BootMybat…

处理关于 React lazy 白屏的两种方案

这篇文章是今天在阅读 React 官方文档的时候看到的一个关于 处理 lazy 体验问题的小技巧,在这里记录一下 当我们使用 React.lazy 去懒加载一个路由组件,在不做任何其他处理的情况下从其他页面首次进入到这个懒加载的路由页面时,肯定会出现白屏…

蓝桥杯单片机速成6-DS1302

目录 一、电路图 二、底层驱动 三、实际应用 四、时序 一、电路图 上图是寄存器地址定义,时分秒,年月日等等 DS1302有自己的时钟线SCLK,不会跟单总线一样因为没有自己的时钟线而导致温度读不出来 CH:时钟静止,置1时…

2024最新软件测试【测试理论+ 抓包与网络协议】面试题(内附答案)

一、测试理论 3.1 你们原来项目的测试流程是怎么样的? 我们的测试流程主要有三个阶段:需求了解分析、测试准备、测试执行。 1、需求了解分析阶段 我们的 SE 会把需求文档给我们自己先去了解一到两天这样,之后我们会有一个需求澄清会议, …

【Linux】防火墙iptables详解

目录 一、防护墙概述 二、防火墙 2.1名词 2.2使用规则 2.3表与链 2.3.1简介 2.3.2每个表说明 1)filter表 2)nat表 2.4环境的配置 2.5iptables的命令参数 2.6 配置filter表规则 2.6.1备份与恢复 2.6.2案例1:禁止访问22端口 2.6.3案例2&…

算法——逆波兰式

http://t.csdnimg.cn/Wg8vu 逆波兰式思路: 对于每个元素,它检查是否是一个操作符(“”、“-”、“*” 或 “/”)。如果是,它就从栈中弹出两个元素,执行相应的操作,然后将结果推回到栈中。如果…

c++不同数据类型的大小

C++提供了各种基本数据类型,以及一些复合数据类型,如数组、结构体、枚举和类等。以下是C++中常见的数据类型: ChatGPT ChatGPT C++是一种静态类型的编程语言,意味着在编写代码时必须显式地声明每个变量的数据类型。C++提供了各种基本数据类型,以及一些复合数据类型,如数…