Project Icon

Fast-Kubernetes

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

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

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

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?

  • "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

  • 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?

  • "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

image

Kubernetes Components (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

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

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

  • 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

项目侧边栏1项目侧边栏2
推荐项目
Project Cover

豆包MarsCode

豆包 MarsCode 是一款革命性的编程助手,通过AI技术提供代码补全、单测生成、代码解释和智能问答等功能,支持100+编程语言,与主流编辑器无缝集成,显著提升开发效率和代码质量。

Project Cover

AI写歌

Suno AI是一个革命性的AI音乐创作平台,能在短短30秒内帮助用户创作出一首完整的歌曲。无论是寻找创作灵感还是需要快速制作音乐,Suno AI都是音乐爱好者和专业人士的理想选择。

Project Cover

有言AI

有言平台提供一站式AIGC视频创作解决方案,通过智能技术简化视频制作流程。无论是企业宣传还是个人分享,有言都能帮助用户快速、轻松地制作出专业级别的视频内容。

Project Cover

Kimi

Kimi AI助手提供多语言对话支持,能够阅读和理解用户上传的文件内容,解析网页信息,并结合搜索结果为用户提供详尽的答案。无论是日常咨询还是专业问题,Kimi都能以友好、专业的方式提供帮助。

Project Cover

阿里绘蛙

绘蛙是阿里巴巴集团推出的革命性AI电商营销平台。利用尖端人工智能技术,为商家提供一键生成商品图和营销文案的服务,显著提升内容创作效率和营销效果。适用于淘宝、天猫等电商平台,让商品第一时间被种草。

Project Cover

吐司

探索Tensor.Art平台的独特AI模型,免费访问各种图像生成与AI训练工具,从Stable Diffusion等基础模型开始,轻松实现创新图像生成。体验前沿的AI技术,推动个人和企业的创新发展。

Project Cover

SubCat字幕猫

SubCat字幕猫APP是一款创新的视频播放器,它将改变您观看视频的方式!SubCat结合了先进的人工智能技术,为您提供即时视频字幕翻译,无论是本地视频还是网络流媒体,让您轻松享受各种语言的内容。

Project Cover

美间AI

美间AI创意设计平台,利用前沿AI技术,为设计师和营销人员提供一站式设计解决方案。从智能海报到3D效果图,再到文案生成,美间让创意设计更简单、更高效。

Project Cover

稿定AI

稿定设计 是一个多功能的在线设计和创意平台,提供广泛的设计工具和资源,以满足不同用户的需求。从专业的图形设计师到普通用户,无论是进行图片处理、智能抠图、H5页面制作还是视频剪辑,稿定设计都能提供简单、高效的解决方案。该平台以其用户友好的界面和强大的功能集合,帮助用户轻松实现创意设计。

投诉举报邮箱: service@vectorlightyear.com
@2024 懂AI·鲁ICP备2024100362号-6·鲁公网安备37021002001498号