如何卷曲Pod k8S

时间:2019-09-04 17:52:32

标签: curl kubernetes

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

[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的新手

1 个答案:

答案 0 :(得分:0)

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