【k8s初始化过程解析】

k8s初始化过程解析

[root@k8s-master ~]# kubeadm init
–apiserver-advertise-address=10.10.10.100
–image-repository registry.aliyuncs.com/google_containers
–kubernetes-version v1.25.0
–service-cidr=10.1.0.0/16
–pod-network-cidr=10.2.0.0/16
–cri-socket /var/run/cri-dockerd.sock
–service-dns-domain=cluster.local
–ignore-preflight-errors=all

W0219 22:03:38.471584 10600 initconfiguration.go:119] Usage of CRI endpoints without URL scheme is deprecated and can cause kubelet errors in the future. Automatically prepending scheme “unix” to the “criSocket” with value “/var/run/cri-dockerd.sock”. Please update your configuration!
[init] Using Kubernetes version: v1.25.0

1、[preflight] 环境检查和拉取镜像 kubeadm config images pull

[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’

2、[cert] 生成k8s证书和etcd证书。

[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 [k8s-master kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.1.0.1 10.10.10.100]
[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 [k8s-master localhost] and IPs [10.10.10.100 127.0.0.1 ::1]
[certs] Generating “etcd/peer” certificate and key
[certs] etcd/peer serving cert is signed for DNS names [k8s-master localhost] and IPs [10.10.10.100 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

3、[kubeconfig] 生成kubeconfig文件,可以理解为认证文件。链接apiserver认证

[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”

4、[kubelet-start] 生成kubelet配置文件,启动kubelet

[kubelet-start] Writing kubelet configuration to file “/var/lib/kubelet/config.yaml”
[kubelet-start] Starting the kubelet

5、[control-plane] 部署管理节点组件,用镜像启动容器,可以使用命令查看: kubectl get pods -n kube-system

[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”

6、[etcd] 部署etcd数据库,用镜像启动容器

[etcd] Creating static Pod manifest for local etcd in “/etc/kubernetes/manifests”

7、[wait-control-plane] 等待管理面板

[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

8、[apiclient] 检测所有控制面板状态

[apiclient] All control plane components are healthy after 13.004448 seconds

9、[upload-config] 上传配置文件到k8s集群中

[upload-config] Storing the configuration used in ConfigMap “kubeadm-config” in the “kube-system” Namespace

10、[kubelet] 配置文件存储到master节点中

[kubelet] Creating a ConfigMap “kubelet-config” in namespace kube-system with the configuration for the kubelets in the cluster

11、[upload-certs] 上传证书存储到k8s集群中

[upload-certs] Skipping phase. Please see --upload-certs

12、[mark-control-plane] 给管理节点添加一个标签:[node-role.kubernetes.io/master(deprecated) node-role.kubernetes.io/control-plane node.kubernetes.io/exclude-from-external-load-balancers],并且添加一个污点:[node-role.kubernetes.io/master:NoSchedule]

[mark-control-plane] Marking the node k8s-master as control-plane by adding the labels: [node-role.kubernetes.io/control-plane node.kubernetes.io/exclude-from-external-load-balancers]
[mark-control-plane] Marking the node k8s-master as control-plane by adding the taints [node-role.kubernetes.io/control-plane:NoSchedule]

13、[bootstrap-token] 自动为每个节点颁发证书

[bootstrap-token] Using token: hjdyqz.byzmutnkmn448i5z
[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

14、[kubelet-finalize] 更新“/etc/kubernetes/kubelet.conf”以指向可旋转的kubelet客户端证书和密钥

[kubelet-finalize] Updating “/etc/kubernetes/kubelet.conf” to point to a rotatable kubelet client certificate and key

15、[addons] 部署相关插件,coreDNS、kube-proxy

[addons] Applied essential addon: CoreDNS
[addons] Applied essential addon: kube-proxy

16、代表K8S-master已经成功安装

Your Kubernetes control-plane has initialized successfully!

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

17、创建k8s集群配置文件,制订了,默认的ssl证书在哪,api-server的地址,等信息

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

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

export KUBECONFIG=/etc/kubernetes/admin.conf

18、pod分布再多个机器上,pod互相之间链接,得部署,集群网络,选用网络插件

You 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/

19、使用如下命令,将k8s-node加入集群即可

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

kubeadm join 10.10.10.100:6443 --token hjdyqz.byzmutnkmn448i5z
–discovery-token-ca-cert-hash sha256:18ce7af434e99a8edd527be3ea83603e68c50fb676b7cf9eeeb169f5ded88b7f

k8s 初始化后,查看master节点都启动了那些端口

在这里插入图片描述

k8s初始化node节点加入到master节点后都启动了那些端口

在这里插入图片描述

pod是如何被创建到目标机器上的(原理流程)?

  1. 在master节点上,写yaml描述你对容器的运行要求,创建pod的要求,eg:install-mysql.yml
  2. (kubectl create -f install-mysql.yml)使用kubectl命令去创建,应用这个资源描述文件,才会涉及k8s组件交互发出请求,我需要创建一个pod去运行mysql了,请求发给谁?(api-server)
  3. 验证kubectl命令发来的请求是否被允许,利用本地的https证书,直接写入kubectl配置文件的该请求被允许后才会被执行
  4. api-server将mysql-pod创建的信息记录到etcd数据库中(数据库记录了一些信息, mysql镜像版本,容器名,是否需要暴露端口)
  5. api-server会通知下一个组件,调度器组件,schedule准备pod调度
  6. schedule调度,回去etcd里面查询,部署的pod信息是什么,schedule调度判断出一个合适的node节点去部署pod(选择好了具体的机器,还未执行)
  7. scheduler调度器,回告诉api-server自己决定pod要部署到哪个node节点上
  8. api-server 会将这个部署信息存储到etcd里,数据库更新(mysql本身的容器信息+绑定关系,部署到那台机器上)
  9. api-server会通知node节点机器,node节点机器上的kubelet去读取etcd数据库里面的信息,根据这些信息创建mysql镜像并且创建pod。

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

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

相关文章

PDF文件格式(二):交叉引用类型“O“

PDF交叉引用类型有三种:“n”,"f","o";前两种比较常见,本文介绍第三种“o”类型。 type为"o"类型的引用在PDF文件中不能够直接找到对应的obj,它被以压缩的形式内嵌在其他的obj内,因此此类型的引用…

GitCode配置ssh

下载SSH windows设置里选“应用” 选“可选功能” 添加功能 安装这个 坐等安装,安装好后可以关闭设置。 运行 打开cmd 执行如下指令,启动SSH服务。 net start sshd设置开机自启动 把OpenSSH服务添加到Windows自启动服务中,可避免每…

Sora会“杀死”剪映吗?

图片来源:pexels ▎留给张一鸣和张楠的时间不多了。 Sora的横空出世,对张一鸣来说,亦喜亦忧。 被OpenAI的ChatGPT震撼过一轮的AI大模型行业,又一次被这家公司推出的首个视频生成模型Sora震撼了一把。 不同于Runway、Pika等仅能生成不足10秒&…

Linux——信号(3)

经过前两部分的介绍,我们现在已经认识了信号是如何产生的,并且知道无 论信号是如何产生的,最终只能由操作系统来对特定进程发送信号,而发送 信号其实也就是写信号,往内核数据结构(pending表)中写…

第3.1章:StarRocks数据导入——Insert into 同步模式

一、概述 在StarRocks中,insert的语法和mysql等数据库的语法类似,并且每次insert into操作都是一次完整的导入事务。 主要的 insertInto 命令包含以下两种: insert into tbl select ...insert into tbl (col1, col2, ...) values (1, 2, ...…

Oracle 如何提高空间使用率?

一,行迁移和行链接。 oracle尽量保证一行的数据能够放在同一个数据块当中,有的时候行会发生行迁移和行链接。 行链接 :有一个列的字段是大对象(long,longlong)一行占的数据一整个块都放不下,则…

OpenCV统计函数之minMaxLoc和meanStdDev

在OpenCV中,minMaxLoc和meanStdDev是两个用于统计图像或数组中元素的基本特性的函数。这些统计函数对于图像处理、特征提取和数据分析非常有用。 minMaxLoc minMaxLoc函数用于查找数组或图像中的最小值和最大值,并可选地返回这些值的位置。这在处理图像…

【漏洞复现】大华DSS视频管理系统信息泄露漏洞

Nx01 产品简介 大华DSS数字监控系统是一个在通用安防视频监控系统基础上设计开发的系统,除了具有普通安防视频监控系统的实时监视、云台操作、录像回放、报警处理、设备治理等功能外,更注重用户使用的便利性。 Nx02 漏洞描述 大华DSS视频管理系统存在信…

.NET 9 首个预览版发布:瞄准云原生和智能应用开发

前言 前不久.NET团队发布了.NET 9 的首个预览版,并且分享.NET团队对 .NET 9 的初步愿景,该愿景将于今年年底在 .NET Conf 2024 上发布。其中最重要的关注领域是:云原生和智能应用开发。 云原生开发人员平台 过去几年,.NET团队一直…

探索 LRU 算法的缺陷与解决方案

LRU算法 Linux 的 Page Cache 和 MySQL 的 Buffer Pool 的大小是有限的,并不能无限的缓存数据,对于一些频繁访问的数据我们希望可以一直留在内存中,而一些很少访问的数据希望可以在某些时机可以淘汰掉,从而保证内存不会因为满了而…

conda 进入python环境里pip install安装不到该环境或不生效

参考:https://blog.csdn.net/weixin_47834823/article/details/128951963 https://blog.51cto.com/u_15060549/4662570?loginfrom_csdn 1、直接进入python Scripts目录下安装 cmd打开运行窗口,cd切换路径至指定虚拟环境下的Scripts路径后再pip安装 擦…

08-静态pod(了解即可,不重要)

我们都知道,pod是kubelet创建的,那么创建的流程是什么呐? 此时我们需要了解我们k8s中config.yaml配置文件了; 他的存放路径:【/var/lib/kubelet/config.yaml】 一、查看静态pod的路径 [rootk8s231 ~]# vim /var/lib…

SQL笔记-多表查询(合并记录新增字段)

比如要统计2张表的所有数据,这两张表无关联关系,统计的数据需要在同一行: SELECT (SELECT COUNT(*) FROM reptile_csdn_article) AS table1_count, (SELECT COUNT(*) FROM reptile_tag_type) AS table2_count 运行截图如下: 大于…

构造函数,原型,实例,类的关系整理

视频来源js原型链、构造函数和类_哔哩哔哩_bilibili 如视频所说,构造函数的prototype指向原型,实例化的对象的__proto__指向原型,原型通过constructor指向构造函数,正如class里面的constructor方法就相当于Person构造函数一样&am…

Vue3实现带动画效果的tab栏切换

效果图如下所示&#xff1a; 实现思路&#xff1a; 其实很简单 1、首先切换tab栏时tab标签激活下标与对应显示内容下标要一致。 2、其次点击tab栏切换时更新下标 3、最后就是css添加动画效果 这样就了&#xff01;&#xff01;&#xff01; 上全部代码 <template><…

C++入门 上(命名空间 缺省参数 函数重载)

C入门 上 命名空间命名空间定义命名空间使用 C输入输出缺省参数缺省参数概念缺省参数分类 函数重载函数重载概念C支持函数重载的原理--名字修饰 命名空间 在C/C中&#xff0c;变量、函数和后面要学到的类都是大量存在的&#xff0c;这些变量、函数和类的名称将都存在于全局作用…

前缀和 K倍区间

思路&#xff1a;统计相加后余数数组对应的数&#xff0c;就是k倍区间对应的个数 import java.util.*; public class Main{public static void main(String[] args){Scanner scnew Scanner(System.in);int nsc.nextInt();int msc.nextInt();int f[]new int[m];f[0]1;long sum0;…

C# OpenCvSharp DNN Image Retouching

目录 介绍 模型 项目 效果 代码 下载 C# OpenCvSharp DNN Image Retouching 介绍 github地址&#xff1a;https://github.com/hejingwenhejingwen/CSRNet (ECCV 2020) Conditional Sequential Modulation for Efficient Global Image Retouching 模型 Model Properti…

小型洗衣机什么牌子好?四大超强实力内衣洗衣机整理

如果你对于内衣物的卫生追求比较高&#xff0c;又不想手洗内衣&#xff0c;觉得太耽误时间&#xff0c;那就选购一台小型洗衣机吧&#xff01;其特色的高温洗护程序高效杀灭细菌&#xff0c;呵护健康&#xff0c;同时又能带来如手洗般的洁净&#xff0c;还能很好的保护衣物不被…

RuntimeError: CUDA out of memory.【多种场景下的解决方案】

RuntimeError: CUDA out of memory.【多种场景下的解决方案】 &#x1f308; 个人主页&#xff1a;高斯小哥 &#x1f525; 高质量专栏&#xff1a;【Matplotlib之旅&#xff1a;零基础精通数据可视化】 &#x1f3c6;&#x1f3c6;关注博主&#xff0c;随时获取更多关于深度学…
最新文章