日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學無先后,達者為師

網站首頁 編程語言 正文

k8s創(chuàng)建一個簡單的Pod

作者:LG_985938339 更新時間: 2022-05-11 編程語言

k8s創(chuàng)建一個簡單的Pod


nginx-pod.yaml 文件內容:

apiVersion: v1
kind: Pod    # 類型為Pod
metadata:
  name: nginx-pod       # Pod的名稱
  labels:
    app: nginxlabel
spec:
    containers:           # Pod內容器的定義部分
    - name: nginx         # 容器對應的名稱
      image: nginx        # 容器對應的Docker鏡像
      ports:
      - containerPort: 80      # 容器應用監(jiān)聽的端口號

創(chuàng)建Pod

[root@k8s-node1 mytestyaml]# kubectl apply -f nginx-pod.yaml
pod/nginx-pod created

查看Pod創(chuàng)建情況

[root@k8s-node1 mytestyaml]# kubectl get pod -o wide
NAME        READY   STATUS              RESTARTS   AGE   IP       NODE        NOMINATED NODE   READINESS GATES
nginx-pod   0/1     ContainerCreating   0          26s   <none>   k8s-node3   <none>           <none>
[root@k8s-node1 mytestyaml]# kubectl get pod -o wide
NAME        READY   STATUS    RESTARTS   AGE   IP            NODE        NOMINATED NODE   READINESS GATES
nginx-pod   1/1     Running   0          79m   10.244.2.58   k8s-node3   <none>           <none>

訪問nginx

[root@k8s-node1 mytestyaml]# curl 10.244.2.58
<!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>

出現這樣的,就是訪問成功了。

原文鏈接:https://blog.csdn.net/weixin_44228698/article/details/122025548

欄目分類
最近更新