Error from server: Get “https://[::1]:6443/api/v1/namespaces/victor/resourcequotas“: dial tcp [::1]:
安装完k8s之后,创建命名空间时,报错:Error from server: Get "https://[::1]:6443/api/v1/namespaces/victor/resourcequotas": dial tcp [::1]:
·
K8S版本
[root@victor-master ~]# kubectl version
Client Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.15", GitCommit:"1d79bc3bcccfba7466c44cc2055d6e7442e140ea", GitTreeState:"clean", BuildDate:"2022-09-21T12:18:10Z", GoVersion:"go1.16.15", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.15", GitCommit:"1d79bc3bcccfba7466c44cc2055d6e7442e140ea", GitTreeState:"clean", BuildDate:"2022-09-21T12:12:26Z", GoVersion:"go1.16.15", Compiler:"gc", Platform:"linux/amd64"}
问题:
安装完k8s之后,创建命名空间时,报错:Error from server: Get "https://[::1]:6443/api/v1/namespaces/victor/resourcequotas": dial tcp [::1]:
[root@victor-master ~]# kubectl create ns victor
Error from server: Get "https://[::1]:6443/api/v1/namespaces/victor/resourcequotas": dial tcp [::1]:6443: connect: network is unreachable
kubectl日志如下:
[root@victor-master ~]# kubectl create ns victor -v9
I1026 16:26:46.153543 1597583 loader.go:372] Config loaded from file: /root/.kube/config
I1026 16:26:46.155521 1597583 request.go:1181] Request Body: {"kind":"Namespace","apiVersion":"v1","metadata":{"name":"victor","creationTimestamp":null},"spec":{},"status":{}}
I1026 16:26:46.155660 1597583 round_trippers.go:435] curl -v -XPOST -H "Accept: application/json, */*" -H "Content-Type: application/json" -H "User-Agent: kubectl/v1.22.15 (linux/amd64) kubernetes/1d79bc3" 'https://172.30.93.66:6443/api/v1/namespaces?fieldManager=kubectl-create'
I1026 16:26:46.165645 1597583 round_trippers.go:454] POST https://172.30.93.66:6443/api/v1/namespaces?fieldManager=kubectl-create 500 Internal Server Error in 9 milliseconds
I1026 16:26:46.165659 1597583 round_trippers.go:460] Response Headers:
I1026 16:26:46.165665 1597583 round_trippers.go:463] Audit-Id: 563be252-4da3-4465-88a8-1f9006ff2fff
I1026 16:26:46.165670 1597583 round_trippers.go:463] Cache-Control: no-cache, private
I1026 16:26:46.165674 1597583 round_trippers.go:463] Content-Type: application/json
I1026 16:26:46.165679 1597583 round_trippers.go:463] X-Kubernetes-Pf-Flowschema-Uid: 9ddd0f6c-bb21-44b3-a9d0-9179053e9ad7
I1026 16:26:46.165683 1597583 round_trippers.go:463] X-Kubernetes-Pf-Prioritylevel-Uid: 8c8459fc-8ce5-4726-848a-a2127a1ba9ad
I1026 16:26:46.165688 1597583 round_trippers.go:463] Content-Length: 213
I1026 16:26:46.165692 1597583 round_trippers.go:463] Date: Wed, 26 Oct 2022 08:26:46 GMT
I1026 16:26:46.165717 1597583 request.go:1181] Response Body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"Get \"https://[::1]:6443/api/v1/namespaces/victor/resourcequotas\": dial tcp [::1]:6443: connect: network is unreachable","code":500}
I1026 16:26:46.166202 1597583 helpers.go:217] server response object: [{
"metadata": {},
"status": "Failure",
"message": "Get \"https://[::1]:6443/api/v1/namespaces/victor/resourcequotas\": dial tcp [::1]:6443: connect: network is unreachable",
"code": 500
}]
F1026 16:26:46.166234 1597583 helpers.go:116] Error from server: Get "https://[::1]:6443/api/v1/namespaces/victor/resourcequotas": dial tcp [::1]:6443: connect: network is unreachable
原因:
发现报错是因为本地调用ipv6的api-server的接口报错,突然想到,可能是因为修改了Linux内核参数的原因。
报错时的内核参数如下所示:
net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.default.disable_ipv6=1
net.ipv6.conf.lo.disable_ipv6=1
net.ipv6.conf.lo.disable_ipv6
:是否关闭ipv6回环地址。因此,这个地方要打开ipv6回环地址,相应地建议上面两项IPV6配置也设为0
因此,修改内核参数:
[root@victor-master ~]# cat << EOF >> /etc/sysctl.conf
> net.ipv6.conf.all.disable_ipv6=0
> net.ipv6.conf.default.disable_ipv6=0
> net.ipv6.conf.lo.disable_ipv6=0
> EOF
重新加载配置:
sysctl --system
搞定:
[root@victor-master ~]# kubectl create ns victor
namespace/victor created
更多推荐
已为社区贡献3条内容
所有评论(0)