当前位置:网站首页>Introduction to kubernetes resource object and common commands
Introduction to kubernetes resource object and common commands
2022-06-28 17:52:00 【Silly [email protected]】
Namespace
stay kubernetes in , Namespaces are used to isolate resources . For example, configure the dictionary , Internal routing, etc , Each namespace can only use the... Under it .
View namespace
kubectl get ns
ns yes namespace Abbreviation .
Create a namespace
Create a hello The namespace of .
Command line mode
kubectl create ns hello
yaml The way ,hello.yaml
apiVersion: v1
kind: Namespace
metadata:
name: hello
kubectl apply -f hello.yaml
Delete namespace
Command line mode
kubectl delete ns hello
yaml The way
kubectl delete -f hello.yaml
It should be noted that the system default namespace cannot be deleted . Include default. And deleting a namespace will delete all resources deployed in the space , Prudent operation .
Pod
pod Is a set of containers in operation , yes kubernetes The smallest unit applied in .
see pod
kubectl get pod -A
By default, this command is to view all pod. If we want to see... Under the specified namespace pod, have access to kubectl get pod -n Space name , Without parameters , View the default namespace .
establish pod
Create a name mynginx Of pod, The image used is nginx.
Command line mode
kubectl run mynginx --image=nginx
[[email protected] ~]# kubectl get pod [mynginx]
NAME READY STATUS RESTARTS AGE
mynginx 1/1 Running 0 80s
[[email protected] ~]#
explain :NAME Express pod name .READY Indicates the number of containers ready and the total number of containers .STATUS According to state .RESTARTS Indicates the number of restarts .AGE Indicates the creation duration .
yaml The way ,nginx.yaml
apiVersion: v1
kind: Pod
metadata:
name: mynginx
namespace: default
spec:
containers:
- image: nginx
name: mynginx
Print detailed description
[[email protected] ~]# kubectl describe pod [mynginx]
......
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 4m54s default-scheduler Successfully assigned default/mynginx to k8s-worker2
Normal Pulling 4m53s kubelet Pulling image "nginx"
Normal Pulled 3m49s kubelet Successfully pulled image "nginx" in 1m4.144467081s
Normal Created 3m48s kubelet Created container mynginx
Normal Started 3m48s kubelet Started container mynginx
[[email protected] ~]#
Mainly look at the event part . Including the information of the assigned node, etc . We found out k8s-worker2 Node created pod, So pass docker ps | grep mynginx The only time to check is worker2 Nodes can be seen .
Print detailed log information
[[email protected] ~]# kubectl logs [mynginx]
...
2022/06/27 15:18:45 [notice] 1#1: start worker process 32
2022/06/27 15:18:45 [notice] 1#1: start worker process 33
[[email protected] ~]#
see pod Assigned ip
[[email protected] ~]# kubectl get pod -owide [mynginx]
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
mynginx 1/1 Running 0 4m6s 192.168.126.8 k8s-worker2 <none> <none>
[[email protected] ~]#
Any machine and any application in the cluster can pass Pod The distribution of ip To visit this Pod,curl 192.168.126.8:[80].
Get into pod Inside of container
[[email protected] ~]# kubectl exec -it [mynginx] -c [mynginx] -- /bin/bash
[email protected]:/# ls
bin dev docker-entrypoint.sh home lib64 mnt proc run srv tmp var
boot docker-entrypoint.d etc lib media opt root sbin sys usr
[email protected]:/#
Be careful , If it is multi container pod, We can add parameters -c Container name You can enter the designated container .
Delete pod
kubectl delete pod [mynginx]
kubectl delete -f nginx.yml
Key points :pod yes kubernetes The smallest unit applied in . In the same pod The inner container can be used directly 127.0.0.1: port Mode of access , But be careful , Ports cannot be duplicated .
This paper is written by mdnice Multi platform Publishing
版权声明
本文为[Silly [email protected][email protected]]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/179/202206281723180998.html
边栏推荐
- IDC: Alibaba cloud ranks first in the market share of China's data governance platform in 2021
- Redis主从复制、哨兵、cluster集群原理+实验(好好等,会晚些,但会更好)
- How to configure the Oracle CDC service name without Sid?
- 2022 review questions and answers for safety production management personnel of hazardous chemical production units
- Visubit "ai+3d vision" product series | loading assembly workstation
- Anesthesia is not as simple as "one injection". Painless, safe and comfortable anesthesia is the first choice for patients
- 11 effective ways to enhance WordPress
- Log management in MySQL log backup and recovery
- In rhel6.4, cacti+spine monitoring host is used to send email alarm
- From getting started to mastering the application of | yalmip+cplex in power system (excellent, I will lose if I can't understand it, and I will lose if I don't gain)
猜你喜欢

58技术沙龙第三十一期|Flutter动态化专题沙龙

Redis持久化(少年一貫快馬揚帆,道阻且長不轉彎)

Redis 原理 - Hash

NoSQL之Redis配置与优化(你不在南京的日子我替你吹了秦淮河的晚风)

MySQL中的日志管理 日志備份與恢複

2022 recurrent training question bank and online simulation examination for main principals of hazardous chemicals business units

节点基础~节点层级

Google推出Advanced API Security 保护API免受安全威胁
![[World Ocean Day] tcapulusdb calls on you to protect marine biodiversity together](/img/82/2357f9d195cfbb38c4052790804a6f.png)
[World Ocean Day] tcapulusdb calls on you to protect marine biodiversity together

WPF video hard decoding, rendering and playing (no airspace) (support 4K, 8K and high frame rate video)
随机推荐
Redis persistence (young people always set sail with a fast horse, with obstacles and long turns)
Apache setting timeout parameter
2022年6月27日-2022年7月3日(ue4视频教程)
听说转行软件测试只能自学,培训机构是个坑?
Gestion des journaux sauvegarde et récupération des journaux dans MySQL
2022 review questions and answers for safety production management personnel of hazardous chemical production units
58技术沙龙第三十一期|Flutter动态化专题沙龙
你们采集oracle数据,数据延迟大约有多少啊?我这边就维持在3秒了,降不下去了。有没有个业内参考啊
Q: how bad can a programmer be?
2022年化工自动化控制仪表考试模拟100题模拟考试平台操作
rsync 远程同步(日落尤其温柔的人间皆是浪漫)
MySQL high availability MHA (accidentally passed my youth)
单片机修改网络硬件驱动(phy芯片更换)
2022 chemical automation control instrument test simulation 100 questions simulation test platform operation
Does rapid software delivery really need to be at the cost of security?
全力冲unreal了
节点基础~节点层级
How to do a good job of gateway high availability protection in the big promotion scenario
WPF video hard decoding, rendering and playing (no airspace) (support 4K, 8K and high frame rate video)
Krack based network attack "suggestions collection"