Read k8S-source-code notes, help quickly understand the K8S-code organization rules

K8S源码阅读笔记

以下笔记针对 kubernetes V1.23.1(截至2022年01月01日最新版本),并不保证对其它版本的有效性

一、架构图

架构图

二、阅读前准备

由于kubernetes项目巧妙的设计和代码高度的封装性,建议在阅读代码前,尽可能的进行以下内容的准备:

1. 编程知识配备

  • 编程语准备: 学习golang语法,并额外对cobrapflagflag等包有一定了解,了解go module机制
  • 环境准备:配置并熟悉golang程序的调试,额外掌握在带有命令行参数的情境下如何调试

2. 系统、网络及安全知识

  • 学习HTTPS通信与TLS加密
  • 掌握X.509证书基本要素
  • 了解Bootstrap机制(kubeletkube-ApiServer注册时使用)
  • 基本了解网络代理、容器技术
  • 掌握YAMLJSON编码格式

3. kubernetes组件运行

  • 掌握kubernetes基础概念,例如poddeployment等。了解各组件的作用以及之间的关系、通信方式和大体流程
  • 手动从kubernetes源码编译获得二进制文件,掌握kubernetes源码构建二进制的具体过程
  • 手动从二进制文件配置一个多节点集群,从中加深了解kubernetes组件的运行关系,以及深入了解kubernetes单个组件启动参数含义,同时可以借此形成单个组件的良好调试运行环境。
    • 基于二进制构建kubernetes是较为复杂的,且随着版本更新旧的方式逐渐失效,直到V1.23.1已没有完美教程,为此通过博客的方式详细记录此次集群搭建过程,可供参考:从二进制搭建kubernetes v1.23.1集群(由于教程是在实验做完后补上,可能有小部分缺失,如果您发现了问题请尽快取得联系!)

三、源码剖析

1. API-Server

提供了资源操作的唯一入口,并提供认证、授权、访问控制、API注册和发现等机制

2. Controller-manager

负责维护集群的状态,比如故障检测、自动扩展、滚动更新等

3. Kube-Scheduler

负责资源的调度,按照预定的调度策略将Pod调度到相应的机器上

4. Kubelet

负责维护容器的生命周期,同时也负责Volume(CVI)和网络(CNI)的管理

5. Kube-proxy

负责为Service提供cluster内部的服务发现和负载均衡

6. Kube-ctl

7. 技术补充

8. 示例代码参考

Owner
kubernetes-based edge-cloud solution
kubernetes-based edge-cloud solution
Similar Resources

Quickly find all IPv6 and IPv4 hosts in a LAN.

invaentory Quickly find all IPv6 and IPv4 hosts in a LAN. Overview 🚧 This project is a work-in-progress! Instructions will be added as soon as it is

May 17, 2022

Go-grpc-template - A small template for quickly bootstrapping a, developer platform independent gRPC golang application

Go-grpc-template - A small template for quickly bootstrapping a, developer platform independent gRPC golang application

go-grpc-template A small template for quickly bootstrapping a developer platform

Jan 20, 2022

Dhrate - Quickly check Dockerhub rate (limit) as an unauthenticated user

Dhrate - Quickly check Dockerhub rate (limit) as an unauthenticated user

Dockerhub Rate A small Go program that returns the Dockerhub rate of an unauthen

Feb 7, 2022

Nuke-Net is a VERY VERY over powered and ridiculous web crawler that is well- very very noisy XD read more here

Nuke-Net is a VERY VERY over powered and ridiculous web crawler that is well- very very noisy XD read more here

Nuke-Net is a VERY VERY over powered and ridiculous web crawler that is well- very very noisy XD read more here

Dec 20, 2021

Provides the function Parallel to create a synchronous in memory pipe and lets you write to and read from the pipe parallelly

iopipe provides the function Parallel to create a synchronous in memory pipe and lets you write to and read from the pipe parallely

Jan 25, 2022

A fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet.

A fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet.

frp README | 中文文档 What is frp? frp is a fast reverse proxy to help you expose a local server behind a NAT or firewall to the Internet. As of now, it s

Jan 5, 2023

A repository for the X-Team community to collaborate and learn solutions to most coding challenges to help prepare for their interviews.

A repository for the X-Team community to collaborate and learn solutions to most coding challenges to help prepare for their interviews.

Community Coding Challenge Handbook This repository focuses on helping X-Teamers and community members to thrive through coding challenges offering so

Sep 6, 2022

4chain is a simple、fast reverse proxy to help you expose a local server behind a NAT or firewall to the Internet.

4Chain What is 4chain? 4chain is a simple、fast reverse proxy to help you expose a local server behind a NAT or firewall to the Internet. Using the ssh

Nov 1, 2022

Fake server, Consumer Driven Contracts and help with testing performance from one configuration file with zero system dependencies and no coding whatsoever

Fake server, Consumer Driven Contracts and help with testing performance from one configuration file with zero system dependencies and no coding whatsoever

mockingjay server Mockingjay lets you define the contract between a consumer and producer and with just a configuration file you get: A fast to launch

Jan 6, 2023
x-crafter is used to quickly create templates from your prototype, also come with a builder to quickly regenerate your code

XCrafter ?? x-crafter is used to quickly create templates from your prototype, also come with a builder to quickly regenerate your code. Install Using

Nov 29, 2021
red-tldr is a lightweight text search tool, which is used to help red team staff quickly find the commands and key points they want to execute, so it is more suitable for use by red team personnel with certain experience.
red-tldr is a lightweight text search tool, which is used to help red team staff quickly find the commands and key points they want to execute, so it is more suitable for use by red team personnel with certain experience.

Red Team TL;DR English | 中文简体 What is Red Team TL;DR ? red-tldr is a lightweight text search tool, which is used to help red team staff quickly find t

Jan 5, 2023
Generate types and service clients from protobuf definitions annotated with http rules.

protoc-gen-typescript-http Generates Typescript types and service clients from protobuf definitions annotated with http rules. The generated types fol

Nov 22, 2022
The rest api that can manage the iptables rules of the remote host

fiewall-api firewall api是基于firewalld来远程管理iptables规则的rest-api,无需部署agent Features 指定一个主机ip,让这个主机上的iptables增加一个规则 处理单个IP或CIDR范围(xx.xx.xx.xx/mask,mac,inte

Mar 24, 2022
Go rules for Bazel

Go rules for Bazel Mailing list: bazel-go-discuss Slack: #go on Bazel Slack, #bazel on Go Slack Announcements 2021-10-06 Release v0.29.0 is now availa

Dec 29, 2022
KeeneticRouteToVpn is simple app updating Keenetic Router rules for some hosts to go through VPN interface.

KeeneticRouteToVpn KeeneticRouteToVpn is simple app updating Keenetic Router rules for some hosts to go through VPN interface. It has defaults values

Oct 8, 2022
🚀Gev is a lightweight, fast non-blocking TCP network library based on Reactor mode. Support custom protocols to quickly and easily build high-performance servers.
🚀Gev is a lightweight, fast non-blocking TCP network library based on Reactor mode. Support custom protocols to quickly and easily build high-performance servers.

gev 中文 | English gev is a lightweight, fast non-blocking TCP network library based on Reactor mode. Support custom protocols to quickly and easily bui

Jan 6, 2023
Take an IP address and quickly get the reverse PTR

FlipIP Just a little quick app to take an IP (or set of IPs), and convert them to reverse IP pointers Example: $ flipip 1.2.3.4 4.3.2.1.in-addr.arpa.

Feb 27, 2022
A little tool to test IP addresses quickly against a geolocation and a reputation API

iptester A little tool to test IP addresses quickly against a geolocation and a

May 19, 2022
Forms814 - A website builder, useful for writing data collection webapps quickly.
Forms814 - A website builder, useful for writing data collection webapps quickly.

forms814 A website builder, useful for writing data collection webapps quickly. Project Design The method in use here is to mix it with complicated fo

Oct 25, 2022