当前位置:网站首页>[cloud native] 2.3 kubernetes core practice (Part 1)
[cloud native] 2.3 kubernetes core practice (Part 1)
2022-06-27 08:26:00 【Procedural ape chase】
hello ~ Hello, everyone , In the previous article, we deployed the cluster and set up the visual interface , Let's move on to the core practical part .
Personal home page : Personal home page
Series column :【 Cloud native series 】
Articles related to this article :
1.5【 Cloud native 】 Docker The advanced combat 【 Cloud native 】1.5 Docker The advanced combat _ Program ape chase blog -CSDN Blog _idea link docker 2.1【 Cloud native 】 Kubernetes Basic concepts 【 Cloud native 】2.1 Kubernetes Basic concepts _ Program ape chase blog -CSDN Blog 2.2【 Cloud native 】 kubeadm Create clusters 【 Cloud native 】2.2 kubeadm Create clusters _ Program ape chase blog -CSDN Blog
Catalog
Four 、 Multiple containers Pod details
5、 ... and 、 Use Deployment Deploy the application
One 、 operation Namespace
Our resource creation methods include command line and YAML.Namespace( The name space ) It is used to isolate resources . notes : The name space , It is used to isolate and partition cluster resources . By default, only resources are isolated , Do not isolate the network . The general system comes with :kube-node-lease、kube-public、kube-system etc. , The default is default. Of course, we can also see from the command line (kubectl get ns And kubectl get pods -A). Before operation, we usually need to build a .yaml file .
Create space
kubectl create ns hello
Delete space
kubectl delete ns hello
Two 、 understand Pod
Pod Is a set of containers in operation , yes kubernetes The smallest unit applied in .
Pod What does it have to do with the container ?
We have three nodes , Also install Docker( Provide a containerized operating environment , We call it CRI【Container Runtime Interface】), Add three applications ( In a containerized way ),k8s It is to manage these containers , Then add... To the application Pod, It can be understood as encapsulating them , That's why I have a sentence —— yes kubernetes The smallest unit applied in .(Pod It can run multiple containers )
3、 ... and 、 establish Pod
With the above concept , This is what we are going to create Pod, So it's the same as before , We use commands .
kubectl run mynginx --image=nginx
We have seen so much in detail , Everyone is familiar with this format ?kubectl run + name + Mirror name
Once created, you can use kubectl get pod Check it out. (-A Is to view all )
Check the running container ( Use in batch input )
docker ps|grep mynginx
describe Pod
kubectl describe pod Your own Pod name
Delete Pod
kubectl delete pod Pod name
see Pod Operation log of
kubectl logs Pod name
How to create a configuration file Pod Well ?
Input vi pod. yaml, Then enter the following code ( Remember to exit and save )
apiVersion: v1
kind: Pod
metadata:
labels:
run: mynginx
name: mynginx
# namespace: default
spec:
containers:
- image: nginx
name: mynginx
kubectl apply -f pod. yaml Let's apply
Every Pod - k8s Will be assigned a ip
kubectl get pod -owide
Use Pod Of ip + pod The port in which the container runs
curl 192.168.169.136
Four 、 Multiple containers Pod details
In our last article, we talked about using visual interfaces , Here, let's take a look at the use of the command line and interface .
Again, we create a yaml file ——vi mul ticontainer-pod.yaml, Then paste directly .
apiVersion: v1
kind: Pod
metadata:
labels:
run: mynginx
name: mynginx
# namespace: default
spec:
containers:
- image: nginx
name: mynginx
The visual interface is very friendly to operate , For example, it is very convenient to view resource information 、 state 、 Events, etc. . After downloading , Use curl + ip You can print some htnl Code .
We enter nginx Container come , visit tomcat——curl + Native address :8080, In the same way tomcat Inside visit nginx It only needs tomcat——curl + Native address :80, That's all right.
( Very gingko like ).
5、 ... and 、 Use Deployment Deploy the application
Deployment effect : control Pod, send Pod Have multiple copies , self-healing , Ability to expand, shrink, etc ( Not afraid of machine crash 、 Swing machine , With self recovery function ).
In a word , It's used to control Pod Of .
Create deployment
kubectl create deployment mytomcat --image=tomcat:8.5.68
establish 3 Copies
kubectl create deployment my-dep --image=nginx --replicas=3
The next preview continues 2.4 Kubernetes Core combat
( Please pay attention to ) Ongoing update ……
边栏推荐
- 2022.06.26 (LC Luo 6101 Luo determines whether the matrix is an X matrix)
- 【12. 最大连续不重复子序列】
- 【c ++ primer 笔记】第3章 字符串、向量和数组
- Lvgl usage demo and instructions 2
- Game asset reuse: a new way to find required game assets faster
- 【每日一练】产品卡片动画效果的实现
- 關聯GIS:條條道路通UE5城
- AQS underlying source code of concurrent programming JUC
- 八大误区,逐个击破(终篇):云难以扩展、定制性差,还会让管理员失去控制权?
- 100%弄明白5种IO模型
猜你喜欢
(原创)自定义Drawable
【批处理DOS-CMD命令-汇总和小结】-将文件夹映射成虚拟磁盘——subst
JVM层次上的对象的创建过程和内存布局
oracle用一条sql查出哪些数据不在某个表里
L'introduction en bourse de Wild Wind Pharmaceutical a pris fin: Yu pinzeng, qui avait l'intention de lever 540 millions de RMB, a effectué un investissement P2P.
Zabbix部署说明(Server+Win客户端+交换机(H3C))
JVM常见的垃圾收集器
DataV轮播表组件dv-scroll-board宽度问题
正确的理解MySQL的MVCC
0号进程,1号进程,2号进程
随机推荐
webrtc入门:12.Kurento下的RtpEndpoint和WebrtcEndpoint
关联GIS:条条道路通UE5城
Order by injection of SQL injection
March into machine learning -- Preface
[batch dos-cmd command - summary and summary] - environment variables, path variables, search file location related instructions - set, path, where, what if there are spaces in the path parameters of
[batch dos-cmd command - summary and summary] - parameters%0,%1,%2,%[0-9],%0-9 in the batch command and batch command parameter position switching command shift, operator% usage in the DOS command
SPARQL基础入门练习
JVM common garbage collector
即构「畅直播」,全链路升级的一站式直播服务
100%弄明白5种IO模型
【每日一练】产品卡片动画效果的实现
[notes on c++ primer] Chapter 3 string, vector and array
RockerMQ消息发送模式
【批处理DOS-CMD命令-汇总和小结】-cmd的内部命令和外部命令怎么区分,CMD命令和运行(win+r)命令的区别,
野風藥業IPO被終止:曾擬募資5.4億 實控人俞蘠曾進行P2P投資
05 observer mode
Futures reverse Documentary - training for traders
PayPal账户遭大规模冻结!跨境卖家如何自救?
lvgl使用demo及说明2
参考 | Win11 开启热点之后电脑不能上网