“kubectl应用/创建”;未执行的EOF“;

“kubectl应用/创建”;未执行的EOF“;,eof,kubectl,Eof,Kubectl,My kubectl无法读取文件,每次都返回“错误:意外EOF” kubectl apply -f service.yaml > error: unexpected EOF 我使用了一个非常简单的service.yaml,就像这样,我试图用kubectl读取的每个文件上都会出现这种情况: apiVersion: v1 kind: Service metadata: name: myapp spec: selector: app: myapp ports: - pr

My kubectl无法读取文件,每次都返回“错误:意外EOF”

kubectl apply -f service.yaml
> error: unexpected EOF
我使用了一个非常简单的service.yaml,就像这样,我试图用kubectl读取的每个文件上都会出现这种情况:

apiVersion: v1
kind: Service
metadata:
  name: myapp
spec:
  selector:
    app: myapp
  ports:
  - protocol: TCP
    port: 80
    targetPort: 8090
  type: NodePort
kubectl create-f service.yaml和
cat service.yaml|kubectl apply-f-

已通过gcloud将其删除并安装/更新/重新安装:

gcloud version
>Google Cloud SDK 219.0.1
>core 2018.09.28
>docker-credential-gcr 
>gsutil 4.34
>kubectl 2018.09.17

这可能不是kubectl中的错误,而是kubectl用来读取文件的系统中的其他组件上的错误。但我不知道去哪里找

系统Ubuntu 18.04.1 LTS,一切都是最新的

更新: 我用
-v8
选项再次检查d以进行调试

I1013 11:31:43.750810   17705 loader.go:357] Config loaded from file /home/arno/.kube/config
I1013 11:31:43.751750   17705 round_trippers.go:384] GET https://[clusterIP]/openapi/v2
I1013 11:31:43.751766   17705 round_trippers.go:391] Request Headers:
I1013 11:31:43.751772   17705 round_trippers.go:394]     Accept: application/com.github.proto-openapi.spec.v2@v1.0+protobuf
I1013 11:31:43.751778   17705 round_trippers.go:394]     User-Agent: kubectl/v1.10.7 (linux/amd64) kubernetes/0c38c36
I1013 11:31:44.653232   17705 round_trippers.go:409] Response Status: 404 Not Found in 901 milliseconds
I1013 11:31:44.653254   17705 round_trippers.go:412] Response Headers:
I1013 11:31:44.653263   17705 round_trippers.go:415]     Content-Type: application/json
I1013 11:31:44.653270   17705 round_trippers.go:415]     Content-Length: 524
I1013 11:31:44.653285   17705 round_trippers.go:415]     Date: Sat, 13 Oct 2018 09:31:44 GMT
I1013 11:31:44.653291   17705 round_trippers.go:415]     Audit-Id: e765ef72-8c26-4b67-9039-901efc147cba
I1013 11:31:44.654650   17705 request.go:874] Response Body: {
"paths": [
 "/apis",
 "/apis/",
 "/apis/apiextensions.k8s.io",
 "/apis/apiextensions.k8s.io/v1beta1",
 "/healthz",
 "/healthz/etcd",
 "/healthz/ping",
 "/healthz/poststarthook/generic-apiserver-start-informers",
 "/healthz/poststarthook/start-apiextensions-controllers",
 "/healthz/poststarthook/start-apiextensions-informers",
 "/metrics",
 "/swagger-2.0.0.json",
 "/swagger-2.0.0.pb-v1",
 "/swagger-2.0.0.pb-v1.gz",
 "/swagger.json",
 "/swaggerapi",
 "/version"
 ]
}
I1013 11:31:44.663105   17705 round_trippers.go:384] GET https://[clusterIP]/swagger-2.0.0.pb-v1
I1013 11:31:44.663130   17705 round_trippers.go:391] Request Headers:
I1013 11:31:44.663138   17705 round_trippers.go:394]     User-Agent: kubectl/v1.10.7 (linux/amd64) kubernetes/0c38c36
I1013 11:31:44.663144   17705 round_trippers.go:394]     Accept: application/json, */*
I1013 11:31:44.688907   17705 round_trippers.go:409] Response Status: 200 OK in 25 milliseconds
I1013 11:31:44.688928   17705 round_trippers.go:412] Response Headers:
I1013 11:31:44.688935   17705 round_trippers.go:415]     Date: Sat, 13 Oct 2018 09:31:44 GMT
I1013 11:31:44.688942   17705 round_trippers.go:415]     Etag: "629C2395D5FEDD5D2ED46FE7C691E126BE621789A85F507C44292E9B50E3285AEBBA55D242800C3C9B0A9258E64444CE3B55BD8E485788936DAE773C6548EA64"
I1013 11:31:44.688951   17705 round_trippers.go:415]     Last-Modified: Sun, 08 Jul 2018 16:39:40 GMT
I1013 11:31:44.688960   17705 round_trippers.go:415]     Vary: Accept-Encoding
I1013 11:31:44.688969   17705 round_trippers.go:415]     X-From-Cache: 1
I1013 11:31:44.688976   17705 round_trippers.go:415]     Accept-Ranges: bytes
I1013 11:31:44.688983   17705 round_trippers.go:415]     Content-Type: application/octet-stream
I1013 11:31:44.785113   17705 request.go:872] Response Body:
00000000  0a 03 32 2e 30 12 14 0a  0a 4b 75 62 65 72 6e 65  |..2.0....Kuberne|
00000010  74 65 73 12 06 76 31 2e  39 2e 37 42 d4 e0 5f 12  |tes..v1.9.7B.._.|
00000020  ca 02 0a 05 2f 61 70 69  2f 12 c0 02 12 bd 02 0a  |..../api/.......|
00000030  04 63 6f 72 65 1a 1a 67  65 74 20 61 76 61 69 6c  |.core..get avail|
00000040  61 62 6c 65 20 41 50 49  20 76 65 72 73 69 6f 6e  |able API version|
00000050  73 2a 12 67 65 74 43 6f  72 65 41 50 49 56 65 72  |s*.getCoreAPIVer|
00000060  73 69 6f 6e 73 32 10 61  70 70 6c 69 63 61 74 69  |sions2.applicati|
00000070  6f 6e 2f 6a 73 6f 6e 32  10 61 70 70 6c 69 63 61  |on/json2.applica|
00000080  74 69 6f 6e 2f 79 61 6d  6c 32 23 61 70 70 6c 69  |tion/yaml2#appli|
00000090  63 61 74 69 6f 6e 2f 76  6e 64 2e 6b 75 62 65 72  |cation/vnd.kuber|
000000a0  6e 65 74 65 73 2e 70 72  6f 74 6f 62 75 66 3a 10  |netes.protobuf:.|
000000b0  61 70 70 6c 69 63 61 74  69 6f 6e 2f 6a 73 6f 6e  |application/json|
000000c0  3a 10 61 70 70 6c 69 63  61 74 69 6f 6e 2f 79 61  |:.application/y [truncated 10504225 chars]
F1013 11:31:44.806007   17705 helpers.go:119] error: unexpected EOF

响应失败的部件表示版本不匹配:

I1013 11:31:43.751750   17705 round_trippers.go:384] GET https://[clusterIP]/openapi/v2
I1013 11:31:43.751766   17705 round_trippers.go:391] Request Headers:
I1013 11:31:43.751772   17705 round_trippers.go:394]     Accept: application/com.github.proto-openapi.spec.v2@v1.0+protobuf
I1013 11:31:43.751778   17705 round_trippers.go:394]     User-Agent: kubectl/v1.10.7 (linux/amd64) kubernetes/0c38c36
I1013 11:31:44.653232   17705 round_trippers.go:409] Response Status: 404 Not Found in 901 milliseconds

google kubernetes集群使用的是较旧的版本,类似于
1.9.x
,我的gcloud kubectl是
1.10.7
。更新群集后,它会再次工作。

您是否检查了群集运行和系统机架的运行状况:
kubectl Cluster info
kubectl-get-pods-所有名称空间-o-wide
kubectl-cluster-info
get-pods
工作正常您是否在
kube-system
名称空间下启动并加热了所有群集运行时组件?
I1013 11:31:43.751750   17705 round_trippers.go:384] GET https://[clusterIP]/openapi/v2
I1013 11:31:43.751766   17705 round_trippers.go:391] Request Headers:
I1013 11:31:43.751772   17705 round_trippers.go:394]     Accept: application/com.github.proto-openapi.spec.v2@v1.0+protobuf
I1013 11:31:43.751778   17705 round_trippers.go:394]     User-Agent: kubectl/v1.10.7 (linux/amd64) kubernetes/0c38c36
I1013 11:31:44.653232   17705 round_trippers.go:409] Response Status: 404 Not Found in 901 milliseconds