我想将一个文件夹复制到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
```
答案 0 :(得分:0)
这可能是由于docker客户端中的一个错误导致客户端没有关闭输入流。
有关docker问题的信息,请参见https://github.com/moby/moby/issues/36516;有关kubectl的影响,请参见https://github.com/kubernetes/kubernetes/issues/61557