Minikube Kubernetes Ingress 创建总是抛出错误
Minikube Kubernetes Ingress create always throws errors
我正在使用:
minikube 版本:v1.0.0
我现在需要创建 Ingress 资源:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: test-ingress
spec:
backend:
serviceName: testsvc
servicePort: 80
然后我运行kubectl apply -f ./ingress.yaml
发生错误:
error: SchemaError(io.k8s.api.core.v1.CinderVolumeSource): invalid
object doesn't have additional properties
我的 kubectl 版本是:
客户端版本:version.Info{主要版本:“1”,次要版本:“10”,GitVersion:"v1.10.0",GitCommit:"fc32d2f3698e36b93322a3465f63a14e9f0eaead",GitTreeState:"clean",构建日期:“2018-03-26T16:55:54Z”,GoVersion:"go1.9.3",编译器:"gc",平台:"darwin/amd64"}
服务器版本:version.Info{主要:“1”,次要:“14”,GitVersion:"v1.14.0",GitCommit:“641856db18352033a0d96dbc99153fa3b27298e5”,GitTreeState:"clean",BuildDate:“2019-03- 25T15:45:25Z",GoVersion:"go1.12.1",编译器:"gc",平台:"linux/amd64"}
升级kubectl版本到v1.14.0后,我可以正常创建ingress了。但是现在,问题是入口没有重定向到 pod:
这是我的 ingress.yaml:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: dv
spec:
rules:
- host: ui.dv.com
http:
paths:
- path: /
backend:
serviceName: ngsc
servicePort: 3000
这是我的服务:
apiVersion: v1
kind: Service
metadata:
name: ngsc
spec:
type: NodePort
selector:
app: ngsc
ports:
- port: 3000
nodePort: 30080
name: http
targetPort: 3000
这是我的部署:
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: ngsc
spec:
replicas: 2
template:
metadata:
name: ngsc
labels:
app: ngsc
spec:
containers:
- image: myimage
name: ngsc
imagePullPolicy: IfNotPresent
我已经把ui.dv.com加到/etc/hosts里了,全部启动后,用curl http://ui.dv.com,没有反应
我查看了nginx日志:
获取服务端点时出错 "default/ngsc":本地存储中没有匹配键 "default/ngsc" 的对象
所有 pods、
default api-server-84dd8bcfc8-2hvlh 1/1 Running 26 3h23m
default api-server-84dd8bcfc8-s697x 1/1 Running 28 3h23m
default api-server-84dd8bcfc8-vq4vn 1/1 Running 26 3h23m
default ngsc-559cbf57df-bcjb7 1/1 Running 3 3h27m
default ngsc-559cbf57df-j5v68 1/1 Running 2 3h27m
kube-system coredns-fb8b8dccf-ghj4l 1/1 Running 42 36h
kube-system coredns-fb8b8dccf-rwhw5 1/1 Running 41 36h
kube-system default-http-backend-6864bbb7db-p8fld 1/1 Running 47 36h
kube-system etcd-minikube 1/1 Running 3 36h
kube-system kube-addon-manager-minikube 1/1 Running 4 36h
kube-system kube-apiserver-minikube 1/1 Running 27 36h
kube-system kube-controller-manager-minikube 0/1 Error 4 11m
kube-system kube-proxy-skn58 1/1 Running 2 12h
kube-system kube-scheduler-minikube 0/1 CrashLoopBackOff 40 36h
kube-system nginx-ingress-controller-f5744c676-j5r25 1/1 Running 47 3h16m
kube-system storage-provisioner 1/1 Running 7 36h
这里,入口控制器是运行ning
现在运行宁:
kubectl describe pods -n kube-system nginx-ingress-controller-f5744c676-j5r25
我有这个:
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning Unhealthy 41m (x98 over 3h9m) kubelet, minikube Liveness probe failed: Get http://172.17.0.7:10254/healthz: net/http: request canceled (Client.Timeout exceeded while awaiting headers)
Warning Unhealthy 25m (x208 over 3h10m) kubelet, minikube Readiness probe failed: Get http://172.17.0.7:10254/healthz: net/http: request canceled (Client.Timeout exceeded while awaiting headers)
Warning Unhealthy 5m46s (x4 over 12m) kubelet, minikube Readiness probe failed: Get http://172.17.0.6:10254/healthz: net/http: request canceled (Client.Timeout exceeded while awaiting headers)
Warning BackOff 35s (x448 over 3h3m) kubelet, minikube Back-off restarting failed container
描述入口:
Namespace: default
Address:
Default backend: default-http-backend:80 ()
Rules:
Host Path Backends
---- ---- --------
*
/ui ngsc:3000 (172.17.0.10:3000,172.17.0.7:3000)
*
/api api-server:8083 (172.17.0.5:8083,172.17.0.9:8083)
Annotations:
kubectl get ing
名称主机地址端口年龄
数据浏览器 * 10.0.2.15 80 3h12m
最后:
挂了,又停了
这里有什么问题吗?
请查看社区评论:
您能否验证您的 "kubectl" 和 minikube 版本。
安装过程中有没有错误?
请检查日志和事件。
请尝试创建其他部署以查看是否还有其他错误。
为了故障排除,请使用:
kubectl get pods
kubectl get events
kubectl logs "your_pod"
请分享您的发现
您的清单中没有错误,显然,您使用了错误的 kubectl 版本。
kubectl 需要在您使用的集群的 1 个次要范围内,如所述here。
You must use a kubectl version that is within one minor version difference of your cluster. For example, a v1.2 client should work with v1.1, v1.2, and v1.3 master. Using the latest version of kubectl helps avoid unforeseen issues.
您可以使用
检查您的版本
kubectl version
我正在使用: minikube 版本:v1.0.0 我现在需要创建 Ingress 资源:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: test-ingress
spec:
backend:
serviceName: testsvc
servicePort: 80
然后我运行kubectl apply -f ./ingress.yaml
发生错误:
error: SchemaError(io.k8s.api.core.v1.CinderVolumeSource): invalid object doesn't have additional properties
我的 kubectl 版本是:
客户端版本:version.Info{主要版本:“1”,次要版本:“10”,GitVersion:"v1.10.0",GitCommit:"fc32d2f3698e36b93322a3465f63a14e9f0eaead",GitTreeState:"clean",构建日期:“2018-03-26T16:55:54Z”,GoVersion:"go1.9.3",编译器:"gc",平台:"darwin/amd64"} 服务器版本:version.Info{主要:“1”,次要:“14”,GitVersion:"v1.14.0",GitCommit:“641856db18352033a0d96dbc99153fa3b27298e5”,GitTreeState:"clean",BuildDate:“2019-03- 25T15:45:25Z",GoVersion:"go1.12.1",编译器:"gc",平台:"linux/amd64"}
升级kubectl版本到v1.14.0后,我可以正常创建ingress了。但是现在,问题是入口没有重定向到 pod:
这是我的 ingress.yaml:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: dv
spec:
rules:
- host: ui.dv.com
http:
paths:
- path: /
backend:
serviceName: ngsc
servicePort: 3000
这是我的服务:
apiVersion: v1
kind: Service
metadata:
name: ngsc
spec:
type: NodePort
selector:
app: ngsc
ports:
- port: 3000
nodePort: 30080
name: http
targetPort: 3000
这是我的部署:
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: ngsc
spec:
replicas: 2
template:
metadata:
name: ngsc
labels:
app: ngsc
spec:
containers:
- image: myimage
name: ngsc
imagePullPolicy: IfNotPresent
我已经把ui.dv.com加到/etc/hosts里了,全部启动后,用curl http://ui.dv.com,没有反应
我查看了nginx日志:
获取服务端点时出错 "default/ngsc":本地存储中没有匹配键 "default/ngsc" 的对象
所有 pods、
default api-server-84dd8bcfc8-2hvlh 1/1 Running 26 3h23m
default api-server-84dd8bcfc8-s697x 1/1 Running 28 3h23m
default api-server-84dd8bcfc8-vq4vn 1/1 Running 26 3h23m
default ngsc-559cbf57df-bcjb7 1/1 Running 3 3h27m
default ngsc-559cbf57df-j5v68 1/1 Running 2 3h27m
kube-system coredns-fb8b8dccf-ghj4l 1/1 Running 42 36h
kube-system coredns-fb8b8dccf-rwhw5 1/1 Running 41 36h
kube-system default-http-backend-6864bbb7db-p8fld 1/1 Running 47 36h
kube-system etcd-minikube 1/1 Running 3 36h
kube-system kube-addon-manager-minikube 1/1 Running 4 36h
kube-system kube-apiserver-minikube 1/1 Running 27 36h
kube-system kube-controller-manager-minikube 0/1 Error 4 11m
kube-system kube-proxy-skn58 1/1 Running 2 12h
kube-system kube-scheduler-minikube 0/1 CrashLoopBackOff 40 36h
kube-system nginx-ingress-controller-f5744c676-j5r25 1/1 Running 47 3h16m
kube-system storage-provisioner 1/1 Running 7 36h
这里,入口控制器是运行ning
现在运行宁:
kubectl describe pods -n kube-system nginx-ingress-controller-f5744c676-j5r25
我有这个:
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning Unhealthy 41m (x98 over 3h9m) kubelet, minikube Liveness probe failed: Get http://172.17.0.7:10254/healthz: net/http: request canceled (Client.Timeout exceeded while awaiting headers)
Warning Unhealthy 25m (x208 over 3h10m) kubelet, minikube Readiness probe failed: Get http://172.17.0.7:10254/healthz: net/http: request canceled (Client.Timeout exceeded while awaiting headers)
Warning Unhealthy 5m46s (x4 over 12m) kubelet, minikube Readiness probe failed: Get http://172.17.0.6:10254/healthz: net/http: request canceled (Client.Timeout exceeded while awaiting headers)
Warning BackOff 35s (x448 over 3h3m) kubelet, minikube Back-off restarting failed container
描述入口:
Namespace: default
Address:
Default backend: default-http-backend:80 ()
Rules:
Host Path Backends
---- ---- --------
*
/ui ngsc:3000 (172.17.0.10:3000,172.17.0.7:3000)
*
/api api-server:8083 (172.17.0.5:8083,172.17.0.9:8083)
Annotations:
kubectl get ing 名称主机地址端口年龄 数据浏览器 * 10.0.2.15 80 3h12m
最后:
挂了,又停了
这里有什么问题吗?
请查看社区评论:
您能否验证您的 "kubectl" 和 minikube 版本。
安装过程中有没有错误?
请检查日志和事件。
请尝试创建其他部署以查看是否还有其他错误。为了故障排除,请使用:
kubectl get pods kubectl get events kubectl logs "your_pod"
请分享您的发现
您的清单中没有错误,显然,您使用了错误的 kubectl 版本。
kubectl 需要在您使用的集群的 1 个次要范围内,如所述here。
You must use a kubectl version that is within one minor version difference of your cluster. For example, a v1.2 client should work with v1.1, v1.2, and v1.3 master. Using the latest version of kubectl helps avoid unforeseen issues.
您可以使用
检查您的版本kubectl version