查看default命名空间中的Pod
kubectl get pod
或
kubectl get pods
或
kubectl get pods --namespace default
或
kubectl get pod --namespace default
查看其他命名空间中的Pod
kubectl get pod -n kube-system # kube-system 命名空间名称
由于网络原因,建议提前准备好容器镜像。本次使用nginx:latest容器镜像
root@k8s1:/home# cat 02-create-pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: pod1
#namespace: default
spec:
containers:
- name: ngninx-pod
image: nginx:latest
ports:
- name: nginxport
containerPort: 88
resources:
limits:
cpu: '1'
memory: 1Gi
requests:
cpu: 200m
memory: 512Mi
命令
kubectl apply -f 02-create-pod.yaml
输出结果
pod/pod1 created
查看控制面板
查看已创建pod
root@k8s1:/home# kubectl get pod
NAME READY STATUS RESTARTS AGE
pod1 1/1 Running 0 6m
通过指定默认命名空间查看已创建pod
root@k8s1:/home# kubectl get pods -n default
NAME READY STATUS RESTARTS AGE
pod1 1/1 Running 0 7m47s
查看pod更加详细信息
root@k8s1:/home# kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
pod1 1/1 Running 0 8m59s 10.233.88.56 k8s3 <none> <none>
root@k8s1:/home# curl http://10.233.88.56
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
root@k8s1:/home# kubectl delete pods pod1
pod "pod1" deleted
root@k8s1:/home# kubectl delete -f 02-create-pod.yaml
pod "pod1" deleted
版权说明 : 本文为转载文章, 版权归原作者所有 版权申明
原文链接 : https://blog.csdn.net/weixin_43296313/article/details/121334485
内容来源于网络,如有侵权,请联系作者删除!