当前位置:网站首页>One article introduces you to the world of kubernetes
One article introduces you to the world of kubernetes
2022-06-24 01:06:00 【Luga Lee】
Based on these tools , I believe it can help you from 0 Get started Kubernetes colony , Start the journey of cloud origin ~
Kubernetes, Usually we abbreviate it to “K8s”, Is an open source container orchestration platform , Initially in Shipyard Widely used in the platform . Many of the tasks involved in maintaining containerized applications based on automation patterns , For example, deployment 、 Expand 、 Load balancing 、 Grayscale and resource elasticity, etc . Its aerial view is as follows :
Kubernetes Inferiority
Kubernetes It is the main orchestration platform for cloud native ecological asset management , Thousands of companies have optimized their deployment , Authors efficiency . However , It is notorious for its steep learning curve and cumbersome underlying principles . in short , Kubernetes It's really a little innocent , It is not only welcomed by the majority of open source enthusiasts, but also deterred everyone , Makes it difficult to achieve a bowl level .
That means , If everyone is trying to learn and master Kubernetes Iceberg technicians , So you're lucky , Because there are a lot of open source resources that can help you start right Kubernetes Cloud native journey .
Kubernetes advantage
Although the use of Kubernetes You may encounter all kinds of difficulties 、 Danger , But fortunately , be based on h reasonable Kubernetes The platform will bring us the following benefits :
1、 Reduce cloud costs by efficiently expanding clusters
2、 Simplify the different engineering processes of the team ( For example, development 、 Test and release )
3、 Minimize safety issues , Such as cross container communication
4、 Determine how traffic passes through infrastructure
5、 Prevent resource poor services from interrupting each other
Yours Kubernetes The journey
indeed , Study Kubernetes It's a long and complicated 、 The process of excitement and decadence , But everyone has to start somewhere . Actually , just 2-3 God , We can use it locally or in the cloud Kubernetes Deploy and manage containers . This article will be a high-level guide , Lead everyone step by step , From macro to micro , From tools to principles , With 0 Basic introduction Kubernetes The world .
Before we start ...
We need to download and install the base environment , for example ,Docker、Kubectl And other basic tools , So that it can provide commands for normal interaction with the cluster .
The first 1 God : Local clusters
Set up local Kubernetes Clustering is one of the best practice routes for getting familiar with basic operations and concepts . In this paper , I will focus on the more classic 2 Tools ,Minikube and K3d, Following pair 2 A brief analysis of .
If you are a Yunyuan Xiaobai , It means that everything will start from scratch ,Minikube Maybe it's a good choice . Use Minikube, We can quickly and easily set up local... From the command line Kubernetes colony . There are many cases on the Internet , How to use Kubernetes In document Minikube Create clusters . About Minikube Related content , Not to be repeated in this article , You can refer to the previous article :Kubernetes Build tools .
Minikube There is no doubt about the power of , Its role is played incisively and vividly in the local environment of the majority of technicians . In addition to this , As a rising star ,K3d Run as local K3s( K8s Lightweight version of ) Another way of is accelerating .K3d One of the most attractive features is , It allows us to Docker Create and manage clusters in ( Instead of running in a virtual machine Minikube ). Check out this starter repo : https://github.com/iwilltry42/k3d-demo Get an example of K3d Applications .
[[email protected] ~ ] % curl -s https://raw.githubusercontent.com/rancher/k3d/main/install.sh | bash ... ... [[email protected] ~ ] % k3d cluster create mycluster -p 9080:[email protected] ... ...
The first 2 God : Deploy
In container Ecology ,Kubernetes The basic building blocks of are called checklists YAML file . These documents are submitted to Kubernetes Explain what we want to create , And how you want to create .
Here are Nginx Example listing of service deployment , With the latest version v1.19 For example , The details are as follows :
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.19.10
ports:
- containerPort: 80For single copy , We can easily create and maintain , However , Once we want to deploy multiple copies of the application , Maintaining copies of several slightly different lists can be a bit stretched .
This is it. Helm The use of template making . Template based tools , We can easily create and manage variations of the application , Maintain the generality of a specific value , And make adaptive adjustment as needed .Helm As a comprehensive tool for cluster creation and release management, it came into being .
besides ,Helm It has also become a tool for packaging the entire application Kubernetes System , We refer to these packages collectively as diagrams . for example , We can use charts based on helm install kube prometheus stack prometheus community/kube prometheus stack Install the monitoring service from the command line ( Measurement collector 、 Time series databases and dashboards ).
About Helm Related content , Refer to the previous article :Helm Management tools resolve .
The first 3 God : management
Past the front 2 Days of practice , We have now deployed a complete cluster , But at the same time , We need to know what happened , Need to be based on our actual business or Demo Effective management . Inside this , We usually recommend the following tools , Of course , There are better , Maybe it depends on everyone's usage habits and style .
First , Let's take a look at the most classic command line tool -Kubectl, Based on this tool ,Kubectl For monitoring Kubernetes Clustering is very useful . We can get Kubernetes Know the state of any object , View real time logs , And in Pod Get the command line . Some useful 、 The little-known meaning of fun is as follows :
kubectl watch: see Kubernetes Real time events for objects . kubectl port forward: A self-organizing port tunnel from the local host to services in the cluster . kubectl proxy: establish kubernetes API Our local agent .
And Kubectl Command line tools are similar , such as Ktunnel . It is also a CLI Tools , Used in Kubernetes Establish a reverse tunnel between the cluster and the local machine . It allows us to expose our deployed machines to the external environment as services in the cluster , Its working principle can be referred to as follows :
If we want to record one group at a time Pod,Kubectl We have not really given us relevant and effective help in this regard . So , We can try it Stern Tools .
be based on Stern, We can span any given ( adopt regex )Pod Set view log . It even displays logs of services started and stopped during execution .
for example , function stern-n kube System DNS Will be displayed Kube String contained in system namespace “DNS” Any of the Pod All the logs of .
[[email protected] ~ ] % go get -u github.com/stern/stern ... ... [[email protected] ~ ] % asdf plugin-add stern ... ... [[email protected] ~ ] % asdf install stern latest ... ...
[[email protected] ~ ] % stern envvars --context staging --container gateway ... ...
Next , Let's introduce 2 Classic GUI Management tools :K9s And Lens . In terms of overview tools ,K9 and Lens It's actually different sides of the same coin . Whatever the choice , It all comes down to personal preferences , But in essence , Both have complete functions and good maintainability , It's worth trying .
If you like the terminal based console , Give priority to K9s , After all, it can monitor existing K8s The basic dashboard of the cluster . besides ,K9s It has a series of useful functions , for example , Benchmarking and resource allocation information, etc .
[[email protected] ~ ] % wget https://github.com/derailed/k9s/releases/download/v0.24.2/k9s_Linux_x86_64.tar.gz [[email protected] ~ ] % tar -xzf k9s_*.tar.gz -C ~/luga-cloud/tools/k9s ... ... [[email protected] ~ ] % ~/luga-cloud/tools/k9s/k9s
If you like GUI Provide availability and clarity , Please check out Lens. It provides a series of tools for general cluster overview , And other related tools , So that we can learn more about the detailed configuration with just a few clicks .
# Download the 3.4.0 AppImage for Lens, mark it executable and copy it to your $PATH # (output omitted for brevity) [[email protected] ~ ] % wget https://github.com/lensapp/lens/releases/download/v3.4.0/Lens-3.4.0.AppImage [[email protected] ~ ] % chmod +x Lens-3.4.0.AppImage [[email protected] ~ ] % sudo mv Lens-3.4.0.AppImage /usr/sbin/lens
Brief analysis based on the above tools , I believe you can set foot on the road to Kubernetes The journey of enlightenment . Next , We need to spend a lot of energy combing 、 master Kubernetes Every specific component of Ecology , Only based on this , We can be right Kubernetes The ecological architecture system is familiar 、 Achieve mastery through a comprehensive .
边栏推荐
- 数字化工厂可以分为哪两类
- CODING CD
- Niu Xuechang's anniversary celebration: software promotion, limited time and free registration code!
- CVPR2022 | 可精简域适应
- [technical grass planting] use webhook to automatically deploy my blogs on multiple sites in Tencent cloud
- Installation and use of winscp and putty
- An accident caused by a MySQL misoperation, and the "high availability" cannot withstand it!
- Zhongshanshan: engineers after being blasted will take off | ONEFLOW u
- js输入输出语句,变量
- WinSCP和PuTTY的安装和使用
猜你喜欢

阿里巴巴面试题:多线程相关

Apple iphone14 is equipped with Beidou navigation system. What are the advantages of Beidou vs GPS?

What are the two types of digital factories

分别用SVM、贝叶斯分类、二叉树、CNN实现手写数字识别
![Graduation project - thesis writing notes [design topic type, thesis writing details, design materials]](/img/66/c0c400609b56dd012d87c620ca66e4.png)
Graduation project - thesis writing notes [design topic type, thesis writing details, design materials]

Application configuration management, basic principle analysis
![[applet] realize the effect of double column commodities](/img/e3/b72955c1ae67ec124520ca46c22773.png)
[applet] realize the effect of double column commodities

Icml'22 | progcl: rethinking difficult sample mining in graph contrast learning

牛学长周年庆活动:软件大促限时抢,注册码免费送!

Shardingsphere-proxy-5.0.0 implementation of capacity range partition (V)
随机推荐
paddle使用指南
WinSCP和PuTTY的安装和使用
飞桨产业级开源模型库:加速企业AI任务开发与应用
所见之处都是我精准定位的范畴!显著图可视化新方法开源
[Hongke case] how can 3D data become operable information Object detection and tracking
MIP nerf: anti aliasing multiscale neural radiation field iccv2021
C language: structure array implementation to find the lowest student record
用一个软件纪念自己故去的母亲,这或许才是程序员最大的浪漫吧
version `ZLIB_ 1.2.9‘ not found (required by /lib64/libpng16.so.16)
C language: on the right shift of matrix
CVPR2022 | 可精简域适应
SQL数据库:知识点汇总,期末不挂科
苹果Iphone14搭载北斗导航系统,北斗VS GPS有哪些优势?
Delegation attack of Intranet penetration and lateral mobility
Experience summary of 9 Android interviews, bytes received, Ali, advanced Android interview answer
这不会又是一个Go的BUG吧?
实时计算框架:Flink集群搭建与运行机制
What should I pay attention to in the interview of artificial intelligence technology?
SQL database: summary of knowledge points, no suspension at the end of the period
【osg】OSG开发(04)—创建多个场景视图