所以,我在这里写设置文件。
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: ingress-nginx
spec:
tls:
# This assumes tls-secret exists.
- secretName: tls-secret
rules:
- http:
paths:
- backend:
# This assumes http-svc exists and routes to healthy endpoints.
serviceName: http-svc
servicePort: 80
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: http-svc
spec:
replicas: 1
template:
metadata:
labels:
app: http-svc
spec:
containers:
- name: http-svc
image: gcr.io/google_containers/echoserver:1.8
ports:
- containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: http-svc
labels:
app: http-svc
spec:
ports:
- port: 80
targetPort: 8080
protocol: TCP
name: http
selector:
app: http-svc
执行以下命令。
kubectl create -f http-svc.yaml
但我得到了以下错误。
$ kubectl describe ingress
Name: ingress-nginx
Namespace: default
Address:
Default backend: default-http-backend:80 (10.56.2.5:8080)
TLS:
tls-secret terminates
Rules:
Host Path Backends
---- ---- --------
*
http-svc:80 (<none>)
Annotations:
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal ADD 8m loadbalancer-controller default/ingress-nginx
Warning GCE 2m (x17 over 7m) loadbalancer-controller googleapi: Error 400: Invalid value for field 'namedPorts[1].port': '0'. Must be greater than or equal to 1, invalid
如果发生这样的错误,原因是什么? kubectl version = v1.8.1
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"8", GitVersion:"v1.8.1", GitCommit:"f38e43b221d08850172a9a4ea785a86a3ffa3b3a", GitTreeState:"clean", BuildDate:"2017-10-12T00:45:05Z", GoVersion:"go1.9.1", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"7+", GitVersion:"v1.7.6-gke.1", GitCommit:"407dbfe965f3de06b332cc22d2eb1ca07fb4d3fb", GitTreeState:"clean", BuildDate:"2017-09-27T21:21:34Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}
答案 0 :(得分:0)
GCE load balancers don't work with services of type ClusterIP:
nodeport是GCE Ingress控制器(以及一般的云控制器)的要求。 &#34;在-PREM&#34;像nginx入口控制器这样的控制器可以与clusterip一起使用
您的服务没有定义类型,因此默认情况下类型为ClusterIP
。这种改变应该可以解决问题:
---
apiVersion: v1
kind: Service
metadata:
name: http-svc
labels:
app: http-svc
spec:
type: NodePort
ports:
- port: 80
targetPort: 8080
protocol: TCP
name: http
selector:
app: http-svc