当前位置:网站首页>Introduction to kubernetes resource object and common commands
Introduction to kubernetes resource object and common commands
2022-06-28 03:28:00 【Jiangxiaonan】
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 .
边栏推荐
- Why is the service implementation class always red
- 您的物联网安全性是否足够强大?
- 数据库的迁移
- R1 Quick Open Pressure Vessel Operation Special Operation Certificate Examination Library and Answers in 2022
- Apache——阿帕奇簡介
- 国泰君安证券靠谱吗?开证券账户安全吗?
- Tencent games released more than 40 products and projects, including 12 new games
- TypeScript 联合类型
- 新手开哪家的证券账户是比较好?炒股开户安全吗
- 2022 safety officer-c certificate examination question bank simulated examination platform operation
猜你喜欢

A16z: metauniverse unlocks new opportunities in game infrastructure

可扩展存储系统(上)

service实现类里面为何一直报红

将PCAP转换为Json文件的神器:joy(安装篇)

Import an excel file, solve the problem of skipping blank cells without reading and moving the subscript forward, and return_ BLANK_ AS_ Null red

17 `bs对象.节点名h3.parent` parents 获取父节点 祖先节点

【小程序】使用font-awesome字体图标的解决文案(图文)

无代码软件发展简史及未来趋势

可扩展数据库(上)

Necessary software tools in embedded software development
随机推荐
The same is MB. Why is the gap so large?
基于 LNMP 搭建个人网站的填坑之旅
What is the best and safest software to download when buying stocks?
Win 10出现bitlocke恢复,蓝屏错误代码0x1600007e
国泰君安证券靠谱吗?开证券账户安全吗?
电子地图坐标系统研究整理
Inference optimization implementation of tensorrt model
Solution to not displaying logcat logs during debugging of glory V8 real machine
INFO:&nbsp;HHH000397:&nbsp;Using…
数据库乱码问题
如何获取GC(垃圾回收器)的STW(暂停)时间?
物体上下漂浮工具
In the digital era, enterprises must do well in user information security
s32ds跳转到DefaultISR
Importer un fichier Excel, résoudre le problème de sauter les cellules vides et de ne pas lire, et avancer l'indice, et retourner Blank As NULL Red
Agileplm exception resolution session
Thesis reading: General advantageous transformers
ARM Development Studio build编译报错
kubernetes资源对象介绍及常用命令
Is online stock investment exchange group safe? Is it reliable to open an account for free?