# 进入pod容器中 [root@kubernetes-masterstudy]# kubectl exec -it my-nginx sh kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
# 查看nginx默认发布目录下文件 # ls /usr/share/nginx/html/ 50x.html index.html
删除pod
1 2
[root@kubernetes-masterstudy]# kubectl delete -f pod-nginx.yaml pod "my-nginx" deleted
使用命令方式生成yaml
# 生成yaml
kubectl run my-nginx-2 --image=daocloud.io/library/nginx --restart=Never --dry-run=client -o yaml > my-nginx-2.yaml
# 创建pod
[root@kubernetes-master study]# kubectl apply -f pod-nginx-2.yaml
pod/my-nginx-2 created
# 查看pod
[root@kubernetes-master study]# kubectl get pod
NAME READY STATUS RESTARTS AGE
my-nginx-2 1/1 Running 0 9s
# 查看详细信息
[root@kubernetes-master study]# kubectl get pod -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
my-nginx-2 1/1 Running 0 17s 10.10.20.232 kubernetes-node1 <none> <none>
# 测试访问podip
[root@kubernetes-master study]# curl 10.10.20.232
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
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>
# 删除pod
[root@kubernetes-master study]# kubectl delete -f pod-nginx-2.yaml
pod "my-nginx-2" deleted