繁体   English   中英

如何 curl Pod k8S

[英]How curl Pod k8S

我已经安装了 1 个主节点和两个节点。 我为 POD 创建了命名空间。 我已经在教程中启动了由 linux academy 提供的 Yaml 文件,请参见下面的教程但是当我执行命令 curl 时,它不起作用。

[rbo@K8SMaster ~]$ curl 10.244.1.2:80

yaml文件

apiVersion: v1
kind: Pod
metadata:
  name: examplepod
  namespace: pod-example
spec:
  volumes:
  - name: html
    emptyDir: {}
  containers:
  - name: webcontainer
    image: nginx
    volumeMounts:
    - name: html
      mountPath: /usr/share/nginx/html
  - name: filecontainer
    image: debian
    volumeMounts:
    - name: html
      mountPath: /html
    command: ["/bin/sh", "-c"]
    args:
      - while true; do
         date >> /html/index.html;
         sleep 1;
        done

命令:

    [rbo@K8SMaster ~]$ kubectl get nodes
NAME        STATUS   ROLES    AGE     VERSION
k8smaster   Ready    master   4d17h   v1.15.3
k8snode1    Ready    <none>   3d23h   v1.15.3
k8snode2    Ready    <none>   3d16h   v1.15.3


kubectl create namespace podexample
kubectl create -f pod-example.yml
pod/examplepod created

kubectl get pods --all-namespaces
NAMESPACE     NAME                                READY   STATUS    RESTARTS   AGE
kube-system   coredns-5c98db65d4-9929x            1/1     Running   216        4d17h
kube-system   coredns-5c98db65d4-mb9t2            1/1     Running   216        4d17h
kube-system   etcd-k8smaster                      1/1     Running   1          4d17h
kube-system   kube-apiserver-k8smaster            1/1     Running   1          4d17h
kube-system   kube-controller-manager-k8smaster   1/1     Running   1          4d17h
kube-system   kube-flannel-ds-amd64-2d28b         1/1     Running   1          3d23h
kube-system   kube-flannel-ds-amd64-kpnqs         1/1     Running   1          3d16h
kube-system   kube-flannel-ds-amd64-zbh7z         1/1     Running   1          4d17h
kube-system   kube-proxy-24msd                    1/1     Running   1          4d17h
kube-system   kube-proxy-ghngr                    1/1     Running   0          3d16h
kube-system   kube-proxy-mg25z                    1/1     Running   1          3d23h
kube-system   kube-scheduler-k8smaster            1/1     Running   1          4d17h
podexample    examplepod                          2/2     Running   0          5m33s

感谢您的帮助,对不起,我是 K8S 的新手

我认为 curl 命令是正确的,但 nginx 容器在端口 80 上没有任何返回。 确保 pvc 已创建并手动检查此目录 -> /usr/share/nginx/html 是否有 index.html 并检查 index.html 文件是否具有读取权限。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM