kubernetes 复制命令没有响应
kubernetes copy command does not respond
我想复制一个文件夹到pod,我正在使用下面的命令
kubectl cp keys $POD:/home/oracle/
问题是当我按下回车键时,我没有看到任何响应(复制文件夹后它没有退出),好像命令花费了很长时间,尽管当我检查 POD 时我可以看到文件夹已被复制。
我需要用ctrl+c关闭它才能执行下一个命令。
下面是调试日志
```
kubectl cp test $POD:/home/oracle/ -v=8
loader.go:357] Config loaded from file /root/.kube/config
round_trippers.go:414] GET https://192.168.3.236:6443/api/v1/namespaces/default/pods/xnode-2-56cb894476-w9thk
round_trippers.go:421] Request Headers:
round_trippers.go:424] Accept: application/json, */*
round_trippers.go:424] User-Agent: kubectl/v1.9.5 (linux/amd64) kubernetes/f01a2bf
round_trippers.go:439] Response Status: 200 OK in 25 milliseconds
round_trippers.go:442] Response Headers:
round_trippers.go:445] Content-Type: application/json
round_trippers.go:445] Content-Length: 2594
round_trippers.go:445] Date: Fri, 23 Mar 2018 03:34:50 GMT
request.go:873] Response Body: {"kind":"Pod","apiVersion":"v1","metadata":{"name":"xnode-2-56cb894476-w9thk","generateName":"xnode-2-56cb894476-","namespace":"default","selfLink":"/api/v1/namespaces/default/pods/xnode-2-56cb894476-w9thk","uid":"bd88c607-2db6-11e8-aa6f-525400ddd5c6","resourceVersion":"1213768","creationTimestamp":"2018-03-22T09:52:32Z","labels":{"pod-template-hash":"1276450032","run":"xnode-2"},"ownerReferences":[{"apiVersion":"extensions/v1beta1","kind":"ReplicaSet","name":"xnode-2-56cb894476","uid":"bd78a06e-2db6-11e8-aa6f-525400ddd5c6","controller":true,"blockOwnerDeletion":true}]},"spec":{"volumes":[{"name":"default-token-mf6z4","secret":{"secretName":"default-token-mf6z4","defaultMode":420}}],"containers":[{"name":"xnode-2","image":"engg-nexus.com:8511/ms-linux","args":["/bin/bash"],"env":[{"name":"JAVA_HOME","value":"/usr/orps/java/jdk1.8.0_144"},{"name":"DISPLAY","value":":1"}],"resources":{},"volumeMounts":[{"name":"default-token-mf6z4","readOnly":true,"mountPath":"/var/run/secrets/kubernetes.io/s [truncated 1570 chars]
round_trippers.go:414] POST https://192.168.3.236:6443/api/v1/namespaces/default/pods/xnode-2-56cb894476-w9thk/exec?command=test&command=-d&command=%2Fhome%2Foracle%2F%2Fconfig&container=xnode-2&container=xnode-2&stderr=true&stdout=true
round_trippers.go:421] Request Headers:
round_trippers.go:424] X-Stream-Protocol-Version: v4.channel.k8s.io
round_trippers.go:424] X-Stream-Protocol-Version: v3.channel.k8s.io
round_trippers.go:424] X-Stream-Protocol-Version: v2.channel.k8s.io
round_trippers.go:424] X-Stream-Protocol-Version: channel.k8s.io
round_trippers.go:424] User-Agent: kubectl/v1.9.5 (linux/amd64) kubernetes/f01a2bf
round_trippers.go:439] Response Status: 101 Switching Protocols in 75 milliseconds
round_trippers.go:442] Response Headers:
round_trippers.go:445] Connection: Upgrade
round_trippers.go:445] Upgrade: SPDY/3.1
round_trippers.go:445] X-Stream-Protocol-Version: v4.channel.k8s.io
round_trippers.go:445] Date: Fri, 23 Mar 2018 03:34:50 GMT
round_trippers.go:414] GET https://192.168.3.236:6443/api/v1/namespaces/default/pods/xnode-2-56cb894476-w9thk
round_trippers.go:421] Request Headers:
round_trippers.go:424] Accept: application/json, */*
round_trippers.go:424] User-Agent: kubectl/v1.9.5 (linux/amd64) kubernetes/f01a2bf
round_trippers.go:439] Response Status: 200 OK in 4 milliseconds
round_trippers.go:442] Response Headers:
round_trippers.go:445] Content-Length: 2594
round_trippers.go:445] Date: Fri, 23 Mar 2018 03:34:50 GMT
round_trippers.go:445] Content-Type: application/json
request.go:873] Response Body: {"kind":"Pod","apiVersion":"v1","metadata":{"name":"xnode-2-56cb894476-w9thk","generateName":"xnode-2-56cb894476-","namespace":"default","selfLink":"/api/v1/namespaces/default/pods/xnode-2-56cb894476-w9thk","uid":"bd88c607-2db6-11e8-aa6f-525400ddd5c6","resourceVersion":"1213768","creationTimestamp":"2018-03-22T09:52:32Z","labels":{"pod-template-hash":"1276450032","run":"xnode-2"},"ownerReferences":[{"apiVersion":"extensions/v1beta1","kind":"ReplicaSet","name":"xnode-2-56cb894476","uid":"bd78a06e-2db6-11e8-aa6f-525400ddd5c6","controller":true,"blockOwnerDeletion":true}]},"spec":{"volumes":[{"name":"default-token-mf6z4","secret":{"secretName":"default-token-mf6z4","defaultMode":420}}],"containers":[{"name":"xnode-2","image":"engg-nexus.com:8511/ms-linux","args":["/bin/bash"],"env":[{"name":"JAVA_HOME","value":"/usr/orps/java/jdk1.8.0_144"},{"name":"DISPLAY","value":":1"}],"resources":{},"volumeMounts":[{"name":"default-token-mf6z4","readOnly":true,"mountPath":"/var/run/secrets/kubernetes.io/s [truncated 1570 chars]
round_trippers.go:414] POST https://192.168.3.236:6443/api/v1/namespaces/default/pods/xnode-2-56cb894476-w9thk/exec?command=tar&command=xf&command=-&command=-C&command=%2Fhome%2Foracle%2F%2Fconfig&container=xnode-2&container=xnode-2&stderr=true&stdin=true&stdout=true
round_trippers.go:421] Request Headers:
round_trippers.go:424] X-Stream-Protocol-Version: v4.channel.k8s.io
round_trippers.go:424] X-Stream-Protocol-Version: v3.channel.k8s.io
round_trippers.go:424] X-Stream-Protocol-Version: v2.channel.k8s.io
round_trippers.go:424] X-Stream-Protocol-Version: channel.k8s.io
round_trippers.go:424] User-Agent: kubectl/v1.9.5 (linux/amd64) kubernetes/f01a2bf
round_trippers.go:439] Response Status: 101 Switching Protocols in 69 milliseconds
round_trippers.go:442] Response Headers:
round_trippers.go:445] Connection: Upgrade
round_trippers.go:445] Upgrade: SPDY/3.1
round_trippers.go:445] X-Stream-Protocol-Version: v4.channel.k8s.io
round_trippers.go:445] Date: Fri, 23 Mar 2018 03:34:50 GMT
```
这可能是由于 docker 客户端中的错误导致客户端未关闭输入流。
请参阅 https://github.com/moby/moby/issues/36516 for the docker issue and https://github.com/kubernetes/kubernetes/issues/61557 了解对 kubectl 的影响
我想复制一个文件夹到pod,我正在使用下面的命令
kubectl cp keys $POD:/home/oracle/
问题是当我按下回车键时,我没有看到任何响应(复制文件夹后它没有退出),好像命令花费了很长时间,尽管当我检查 POD 时我可以看到文件夹已被复制。
我需要用ctrl+c关闭它才能执行下一个命令。
下面是调试日志
```
kubectl cp test $POD:/home/oracle/ -v=8
loader.go:357] Config loaded from file /root/.kube/config
round_trippers.go:414] GET https://192.168.3.236:6443/api/v1/namespaces/default/pods/xnode-2-56cb894476-w9thk
round_trippers.go:421] Request Headers:
round_trippers.go:424] Accept: application/json, */*
round_trippers.go:424] User-Agent: kubectl/v1.9.5 (linux/amd64) kubernetes/f01a2bf
round_trippers.go:439] Response Status: 200 OK in 25 milliseconds
round_trippers.go:442] Response Headers:
round_trippers.go:445] Content-Type: application/json
round_trippers.go:445] Content-Length: 2594
round_trippers.go:445] Date: Fri, 23 Mar 2018 03:34:50 GMT
request.go:873] Response Body: {"kind":"Pod","apiVersion":"v1","metadata":{"name":"xnode-2-56cb894476-w9thk","generateName":"xnode-2-56cb894476-","namespace":"default","selfLink":"/api/v1/namespaces/default/pods/xnode-2-56cb894476-w9thk","uid":"bd88c607-2db6-11e8-aa6f-525400ddd5c6","resourceVersion":"1213768","creationTimestamp":"2018-03-22T09:52:32Z","labels":{"pod-template-hash":"1276450032","run":"xnode-2"},"ownerReferences":[{"apiVersion":"extensions/v1beta1","kind":"ReplicaSet","name":"xnode-2-56cb894476","uid":"bd78a06e-2db6-11e8-aa6f-525400ddd5c6","controller":true,"blockOwnerDeletion":true}]},"spec":{"volumes":[{"name":"default-token-mf6z4","secret":{"secretName":"default-token-mf6z4","defaultMode":420}}],"containers":[{"name":"xnode-2","image":"engg-nexus.com:8511/ms-linux","args":["/bin/bash"],"env":[{"name":"JAVA_HOME","value":"/usr/orps/java/jdk1.8.0_144"},{"name":"DISPLAY","value":":1"}],"resources":{},"volumeMounts":[{"name":"default-token-mf6z4","readOnly":true,"mountPath":"/var/run/secrets/kubernetes.io/s [truncated 1570 chars]
round_trippers.go:414] POST https://192.168.3.236:6443/api/v1/namespaces/default/pods/xnode-2-56cb894476-w9thk/exec?command=test&command=-d&command=%2Fhome%2Foracle%2F%2Fconfig&container=xnode-2&container=xnode-2&stderr=true&stdout=true
round_trippers.go:421] Request Headers:
round_trippers.go:424] X-Stream-Protocol-Version: v4.channel.k8s.io
round_trippers.go:424] X-Stream-Protocol-Version: v3.channel.k8s.io
round_trippers.go:424] X-Stream-Protocol-Version: v2.channel.k8s.io
round_trippers.go:424] X-Stream-Protocol-Version: channel.k8s.io
round_trippers.go:424] User-Agent: kubectl/v1.9.5 (linux/amd64) kubernetes/f01a2bf
round_trippers.go:439] Response Status: 101 Switching Protocols in 75 milliseconds
round_trippers.go:442] Response Headers:
round_trippers.go:445] Connection: Upgrade
round_trippers.go:445] Upgrade: SPDY/3.1
round_trippers.go:445] X-Stream-Protocol-Version: v4.channel.k8s.io
round_trippers.go:445] Date: Fri, 23 Mar 2018 03:34:50 GMT
round_trippers.go:414] GET https://192.168.3.236:6443/api/v1/namespaces/default/pods/xnode-2-56cb894476-w9thk
round_trippers.go:421] Request Headers:
round_trippers.go:424] Accept: application/json, */*
round_trippers.go:424] User-Agent: kubectl/v1.9.5 (linux/amd64) kubernetes/f01a2bf
round_trippers.go:439] Response Status: 200 OK in 4 milliseconds
round_trippers.go:442] Response Headers:
round_trippers.go:445] Content-Length: 2594
round_trippers.go:445] Date: Fri, 23 Mar 2018 03:34:50 GMT
round_trippers.go:445] Content-Type: application/json
request.go:873] Response Body: {"kind":"Pod","apiVersion":"v1","metadata":{"name":"xnode-2-56cb894476-w9thk","generateName":"xnode-2-56cb894476-","namespace":"default","selfLink":"/api/v1/namespaces/default/pods/xnode-2-56cb894476-w9thk","uid":"bd88c607-2db6-11e8-aa6f-525400ddd5c6","resourceVersion":"1213768","creationTimestamp":"2018-03-22T09:52:32Z","labels":{"pod-template-hash":"1276450032","run":"xnode-2"},"ownerReferences":[{"apiVersion":"extensions/v1beta1","kind":"ReplicaSet","name":"xnode-2-56cb894476","uid":"bd78a06e-2db6-11e8-aa6f-525400ddd5c6","controller":true,"blockOwnerDeletion":true}]},"spec":{"volumes":[{"name":"default-token-mf6z4","secret":{"secretName":"default-token-mf6z4","defaultMode":420}}],"containers":[{"name":"xnode-2","image":"engg-nexus.com:8511/ms-linux","args":["/bin/bash"],"env":[{"name":"JAVA_HOME","value":"/usr/orps/java/jdk1.8.0_144"},{"name":"DISPLAY","value":":1"}],"resources":{},"volumeMounts":[{"name":"default-token-mf6z4","readOnly":true,"mountPath":"/var/run/secrets/kubernetes.io/s [truncated 1570 chars]
round_trippers.go:414] POST https://192.168.3.236:6443/api/v1/namespaces/default/pods/xnode-2-56cb894476-w9thk/exec?command=tar&command=xf&command=-&command=-C&command=%2Fhome%2Foracle%2F%2Fconfig&container=xnode-2&container=xnode-2&stderr=true&stdin=true&stdout=true
round_trippers.go:421] Request Headers:
round_trippers.go:424] X-Stream-Protocol-Version: v4.channel.k8s.io
round_trippers.go:424] X-Stream-Protocol-Version: v3.channel.k8s.io
round_trippers.go:424] X-Stream-Protocol-Version: v2.channel.k8s.io
round_trippers.go:424] X-Stream-Protocol-Version: channel.k8s.io
round_trippers.go:424] User-Agent: kubectl/v1.9.5 (linux/amd64) kubernetes/f01a2bf
round_trippers.go:439] Response Status: 101 Switching Protocols in 69 milliseconds
round_trippers.go:442] Response Headers:
round_trippers.go:445] Connection: Upgrade
round_trippers.go:445] Upgrade: SPDY/3.1
round_trippers.go:445] X-Stream-Protocol-Version: v4.channel.k8s.io
round_trippers.go:445] Date: Fri, 23 Mar 2018 03:34:50 GMT
```
这可能是由于 docker 客户端中的错误导致客户端未关闭输入流。
请参阅 https://github.com/moby/moby/issues/36516 for the docker issue and https://github.com/kubernetes/kubernetes/issues/61557 了解对 kubectl 的影响