Fast-Kubernetes

Fast-Kubernetes

掌握Kubernetes核心概念与实践技能

Fast-Kubernetes项目详细介绍了Kubernetes的核心对象和组件,包括Kubectl、Pod、Deployment和Service等。通过实践场景和动手实验,该项目帮助学习者从创建简单Pod到实现复杂集群监控,全面掌握Kubernetes技能。项目内容丰富全面,是深入学习Kubernetes的优质参考资源。

Kubernetes容器编排Pod集群KubectlGithub开源项目

Fast-Kubernetes

This repo covers Kubernetes objects' and components' details (Kubectl, Pod, Deployment, Service, ConfigMap, Volume, PV, PVC, Daemonset, Secret, Affinity, Taint-Toleration, Helm, etc.) fastly, and possible example usage scenarios (HowTo: Hands-on LAB) in a nutshell. Possible usage scenarios are aimed to update over time.

Prerequisite

  • Have a knowledge of Container Technology (Docker). You can learn it from here => Fast-Docker

Keywords: Containerization, Kubernetes, Kubectl, Pod, Deployment, Service, ConfigMap, ReplicaSet, Volume, Cheatsheet.

Note: K8s objects and objects feature can be updated/changed in time. While creating this repo, the version of K8s was v1.22.3. Some sections are trying to be kept up to date. Especially Creating K8s Cluster with Kubeadm and Containerd.

Quick Look (HowTo): Scenarios - Hands-on LAB

Table of Contents

Motivation <a name="motivation"></a>

Why should we use Kubernetes? "Kubernetes is a portable, extensible, open-source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation. It has a large, rapidly growing ecosystem. Kubernetes services, support, and tools are widely available." (Ref: Kubernetes.io)

What is Containerization? What is Container Orchestration? <a name="containerization"></a>

  • "Containerization is an operating system-level virtualization or application-level virtualization over multiple network resources so that software applications can run in isolated user spaces called containers in any cloud or non-cloud environment" (wikipedia)
  • With Docker Environment, we can create containers.
  • Kubernetes and Docker Swarm are the container orchestration and management tools that automate and schedule the deployment, management, scaling, and networking of containers.

image

Features <a name="features"></a>

  • Service discovery and load balancing: Kubernetes can expose a container using the DNS name or using their own IP address. If traffic to a container is high, Kubernetes is able to load balance and distribute the network traffic so that the deployment is stable.
  • Storage orchestration: Kubernetes allows you to automatically mount a storage system of your choice, such as local storages, public cloud providers, and more.
  • Automated rollouts and rollbacks:  You can describe the desired state for your deployed containers using Kubernetes, and it can change the actual state to the desired state at a controlled rate.
  • Automatic bin packing: You tell Kubernetes how much CPU and memory (RAM) each container needs. Kubernetes can fit containers onto your nodes to make the best use of your resources.
  • Self-monitoring: Kubernetes checks constantly the health of nodes and containers
  • Self-healing: Kubernetes restarts containers that fail, replaces containers, kills containers that don't respond to your user-defined health check
  • Automates various manual processes: for instance, Kubernetes will control for you which server will host the container, how it will be launched etc.
  • Interacts with several groups of containers: Kubernetes is able to manage more cluster at the same time
  • Provides additional services: as well as the management of containers, Kubernetes offers security, networking and storage services
  • Horizontal scaling: Kubernetes allows you scaling resources not only vertically but also horizontally, easily and quickly
  • Container balancing: Kubernetes always knows where to place containers, by calculating the “best location” for them
  • Run everywhere: Kubernetes is an open source tool and gives you the freedom to take advantage of on-premises, hybrid, or public cloud infrastructure, letting you move workloads to anywhere you want
  • Secret and configuration management: Kubernetes lets you store and manage sensitive information

What is Kubernetes? <a name="whatIsKubernetes"></a>

  • "Kubernetes is a portable, extensible, open-source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation. It has a large, rapidly growing ecosystem. Kubernetes services, support, and tools are widely available." (Ref: Kubernetes.io)

image (Ref: Kubernetes.io)

Kubernetes Architecture <a name="architecture"></a>

image

Kubernetes Components <a name="components"></a> (Ref: Kubernetes.io)

  • Control Plane: User enters commands and configuration files from control plane. It controls all cluster.
    • API Server: "It exposes the Kubernetes API. The API server is the front end for the Kubernetes control plane."
    • Etcd: "Consistent and highly-available key value store used as Kubernetes' backing store for all cluster data (meta data, objects, etc.)."
    • Scheduler: "It watches for newly created Pods with no assigned node, and selects a node for them to run on.
      • Factors taken into account for scheduling decisions include:
        • individual and collective resource requirements,
        • hardware/software/policy constraints,
        • affinity and anti-affinity specifications,
        • data locality,
        • inter-workload interference,
        • deadlines."
    • Controller Manager: "It runs controller processes.
      • Logically, each controller is a separate process, but to reduce complexity, they are all compiled into a single binary and run in a single process.
      • Some types of these controllers are:
        • Node controller: Responsible for noticing and responding when nodes go down.
        • Job controller: Watches for Job objects that represent one-off tasks, then creates Pods to run those tasks to completion.
        • Endpoints controller: Populates the Endpoints object (that is, joins Services & Pods).
        • Service Account & Token controllers: Create default accounts and API access tokens for new namespaces"
    • Cloud Controller Manager: "It embeds cloud-specific control logic. The cloud controller manager lets you link your cluster into your cloud provider's API, and separates out the components that interact with that cloud platform from components that only interact with your cluster. The cloud-controller-manager only runs controllers that are specific to your cloud provider
      • The following controllers can have cloud provider dependencies:
        • Node controller: For checking the cloud provider to determine if a node has been deleted in the cloud after it stops responding
        • Route controller: For setting up routes in the underlying cloud infrastructure
        • Service controller: For creating, updating and deleting cloud provider load balancers."
  • Node: "Node components run on every node, maintaining running pods and providing the Kubernetes runtime environment."
    • Kubelet: "An agent that runs on each node in the cluster. It makes sure that containers are running in a Pod. The kubelet takes a set of PodSpecs that are provided through various mechanisms and ensures that the containers described in those PodSpecs are running and healthy."
    • Kube-proxy: "It is a network proxy that runs on each node in your cluster, implementing part of the Kubernetes Service concept.
      • It maintains network rules on nodes. These network rules allow network communication to your Pods from network sessions inside or outside of your cluster.
      • It uses the operating system packet filtering layer if there is one and it's available. Otherwise, kube-proxy forwards the traffic itself."
    • Container Runtime: "The container runtime is the software that is responsible for running containers.
      • Kubernetes supports several container runtimes: Docker, containerd, CRI-O, and any implementation of the Kubernetes CRI (Container Runtime Interface)"

image

Installation <a name="installation"></a>

Download:

  • Kubectl: The Kubernetes command-line tool, kubectl, allows you to run commands against Kubernetes clusters.
  • Minikube: It is a tool that lets you run Kubernetes locally. It runs a single-node Kubernetes cluster on your personal computer (https://minikube.sigs.k8s.io/docs/start/)
  • KubeAdm: You can use the kubeadm tool to create and manage Kubernetes clusters. This is for creating cluster with computers (Goto: LAB: K8s Kubeadm Cluster Setup).

from here=> https://kubernetes.io/docs/tasks/tools/

For learning K8s and running on a computer, Kubectl and Minikube are enough to install.

PS: Cloud providers (Azure, Google Cloud, AWS) offer managed K8s (control plane is managed by cloud provides). You can easily create your cluster (number of computer and details) and make connection with Kubectl (using CLI get-credentials of cluster on the cloud)

Kubectl Config – Usage <a name="kubectl"></a>

Config File

  • You can communicate with K8s cluster in different ways: REST API, Command Line Tool (CLI-Kubectl), GUI (kube-dashboard, etc.)
  • After installation, you can find the kubernetes config file (C:\Users\User.kube\config) that is YAML file.
  • Config file contains 3 main parts: Clusters (cluster certificate data, server, name), Context (cluster and user, namespace), Users (name, config features, certificates, etc.)

Usage

  • Kubectl is our main command line tool that connects minikube. There are many combination of commands. So it is not possible to list all commands.
  • When run "kubectl" on the terminal, it can be seen some simple commands. Also "kubectl <command> --help" gives more information.
  • Pattern: kubectl [get|delete|edit|apply] [pods|deployment|services] [podName|serviceName|deploymentName]
  • Example: "kubectl get pods podName", "kubectl delete pods test_pod", "kubectl describe pods firstpod", etc.
  • All necessary/most usable commands are listed in the "Kubernetes Commands Cheatsheet". Please have a look to get more information and usage.

Pod: Creating, Yaml, LifeCycle <a name="pod"></a>

  • Pod is the smallest unit that is created and managed in K8s.
  • Pods may contain more than 1 container, but mostly pods contain only 1 container.
  • Each pod has unique id (uid).
  • Each pod has unique IP address.
  • Containers in the same Pod run on the same Node (computer), and these containers can communicate with each other on the localhost.
  • Creation of the first pod, IMPERATIVE WAY (with command):
  • Please have a look Scenario (Creating Pod - Imperative way, below link) to learn more information about the pod's kubectl commands.
    • how to create basic K8s pod using imperative commands,
    • how to get more information about pod (to solve troubleshooting),
    • how to run commands in pod,
    • how to delete pod.

Goto the Scenario: [LAB: K8s Creating Pod - Imperative

编辑推荐精选

蛙蛙写作

蛙蛙写作

AI小说写作助手,一站式润色、改写、扩写

蛙蛙写作—国内先进的AI写作平台,涵盖小说、学术、社交媒体等多场景。提供续写、改写、润色等功能,助力创作者高效优化写作流程。界面简洁,功能全面,适合各类写作者提升内容品质和工作效率。

AI辅助写作AI工具蛙蛙写作AI写作工具学术助手办公助手营销助手AI助手
Trae

Trae

字节跳动发布的AI编程神器IDE

Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。

AI工具TraeAI IDE协作生产力转型热门
问小白

问小白

全能AI智能助手,随时解答生活与工作的多样问题

问小白,由元石科技研发的AI智能助手,快速准确地解答各种生活和工作问题,包括但不限于搜索、规划和社交互动,帮助用户在日常生活中提高效率,轻松管理个人事务。

热门AI助手AI对话AI工具聊天机器人
Transly

Transly

实时语音翻译/同声传译工具

Transly是一个多场景的AI大语言模型驱动的同声传译、专业翻译助手,它拥有超精准的音频识别翻译能力,几乎零延迟的使用体验和支持多国语言可以让你带它走遍全球,无论你是留学生、商务人士、韩剧美剧爱好者,还是出国游玩、多国会议、跨国追星等等,都可以满足你所有需要同传的场景需求,线上线下通用,扫除语言障碍,让全世界的语言交流不再有国界。

讯飞智文

讯飞智文

一键生成PPT和Word,让学习生活更轻松

讯飞智文是一个利用 AI 技术的项目,能够帮助用户生成 PPT 以及各类文档。无论是商业领域的市场分析报告、年度目标制定,还是学生群体的职业生涯规划、实习避坑指南,亦或是活动策划、旅游攻略等内容,它都能提供支持,帮助用户精准表达,轻松呈现各种信息。

AI办公办公工具AI工具讯飞智文AI在线生成PPTAI撰写助手多语种文档生成AI自动配图热门
讯飞星火

讯飞星火

深度推理能力全新升级,全面对标OpenAI o1

科大讯飞的星火大模型,支持语言理解、知识问答和文本创作等多功能,适用于多种文件和业务场景,提升办公和日常生活的效率。讯飞星火是一个提供丰富智能服务的平台,涵盖科技资讯、图像创作、写作辅助、编程解答、科研文献解读等功能,能为不同需求的用户提供便捷高效的帮助,助力用户轻松获取信息、解决问题,满足多样化使用场景。

热门AI开发模型训练AI工具讯飞星火大模型智能问答内容创作多语种支持智慧生活
Spark-TTS

Spark-TTS

一种基于大语言模型的高效单流解耦语音令牌文本到语音合成模型

Spark-TTS 是一个基于 PyTorch 的开源文本到语音合成项目,由多个知名机构联合参与。该项目提供了高效的 LLM(大语言模型)驱动的语音合成方案,支持语音克隆和语音创建功能,可通过命令行界面(CLI)和 Web UI 两种方式使用。用户可以根据需求调整语音的性别、音高、速度等参数,生成高质量的语音。该项目适用于多种场景,如有声读物制作、智能语音助手开发等。

咔片PPT

咔片PPT

AI助力,做PPT更简单!

咔片是一款轻量化在线演示设计工具,借助 AI 技术,实现从内容生成到智能设计的一站式 PPT 制作服务。支持多种文档格式导入生成 PPT,提供海量模板、智能美化、素材替换等功能,适用于销售、教师、学生等各类人群,能高效制作出高品质 PPT,满足不同场景演示需求。

讯飞绘文

讯飞绘文

选题、配图、成文,一站式创作,让内容运营更高效

讯飞绘文,一个AI集成平台,支持写作、选题、配图、排版和发布。高效生成适用于各类媒体的定制内容,加速品牌传播,提升内容营销效果。

热门AI辅助写作AI工具讯飞绘文内容运营AI创作个性化文章多平台分发AI助手
材料星

材料星

专业的AI公文写作平台,公文写作神器

AI 材料星,专业的 AI 公文写作辅助平台,为体制内工作人员提供高效的公文写作解决方案。拥有海量公文文库、9 大核心 AI 功能,支持 30 + 文稿类型生成,助力快速完成领导讲话、工作总结、述职报告等材料,提升办公效率,是体制打工人的得力写作神器。

下拉加载更多