-
Notifications
You must be signed in to change notification settings - Fork 68
Specifying servicePort by name instead of port number prevents the configuration of the desired health check #196
Comments
Interesting. I think this case is supposed to work. Here's where that code is: I should be able to take a look at this next week. |
Hi, looks like I was wrong about the 'fix' I described earlier. This problem seems to occur when the Kubernetes Service's port number (80 above) doesn't match the containerPort number in the pod spec, or when the name doesn't match. What I see from my side is: Doesn't work: ==> kube.yaml <==
apiVersion: v1
kind: Service
metadata:
name: hello-service
labels:
app: hello
spec:
type: NodePort
selector:
app: hello
ports:
- name: http
protocol: TCP
port: 8083
targetPort: hello-port
nodePort: 30091
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: hello-deployment
labels:
app: hello
spec:
replicas: 1
selector:
matchLabels:
app: hello
template:
metadata:
labels:
app: hello
spec:
containers:
- name: hello-container
image: gcr.io/google-samples/hello-app:1.0
ports:
- name: hello-port
containerPort: 8080
readinessProbe:
httpGet:
path: /healthz
port: hello-port
initialDelaySeconds: 25
periodSeconds: 5
==> ingress.yaml <==
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: hc-from-probe
annotations:
kubernetes.io/ingress.class: gce-multi-cluster
spec:
backend:
serviceName: hello-service
servicePort: http Works: ==> kube.yaml <==
apiVersion: v1
kind: Service
metadata:
name: hello-service
labels:
app: hello
spec:
type: NodePort
selector:
app: hello
ports:
- name: http
protocol: TCP
port: 8080 # Changed
targetPort: http # Changed
nodePort: 30091
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: hello-deployment
labels:
app: hello
spec:
replicas: 1
selector:
matchLabels:
app: hello
template:
metadata:
labels:
app: hello
spec:
containers:
- name: hello-container
image: gcr.io/google-samples/hello-app:1.0
ports:
- name: http # Changed
containerPort: 8080
readinessProbe:
httpGet:
path: /healthz
port: http # Changed
initialDelaySeconds: 25
periodSeconds: 5
==> ingress.yaml <==
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: hc-from-probe
annotations:
kubernetes.io/ingress.class: gce-multi-cluster
spec:
backend:
serviceName: hello-service
servicePort: http Doesn't work: ==> kube.yaml <==
apiVersion: v1
kind: Service
metadata:
name: hello-service
labels:
app: hello
spec:
type: NodePort
selector:
app: hello
ports:
- name: http
protocol: TCP
port: 8080
targetPort: hello-http # Changed
nodePort: 30091
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: hello-deployment
labels:
app: hello
spec:
replicas: 1
selector:
matchLabels:
app: hello
template:
metadata:
labels:
app: hello
spec:
containers:
- name: hello-container
image: gcr.io/google-samples/hello-app:1.0
ports:
- name: hello-http # Changed
containerPort: 8080
readinessProbe:
httpGet:
path: /healthz
port: hello-http # Changed
initialDelaySeconds: 25
periodSeconds: 5
==> ingress.yaml <==
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: hc-from-probe
annotations:
kubernetes.io/ingress.class: gce-multi-cluster
spec:
backend:
serviceName: hello-service
servicePort: http Works: ==> kube.yaml <==
apiVersion: v1
kind: Service
metadata:
name: hello-service
labels:
app: hello
spec:
type: NodePort
selector:
app: hello
ports:
- name: http
protocol: TCP
port: 8080
targetPort: hello-http
nodePort: 30091
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: hello-deployment
labels:
app: hello
spec:
replicas: 1
selector:
matchLabels:
app: hello
template:
metadata:
labels:
app: hello
spec:
containers:
- name: hello-container
image: gcr.io/google-samples/hello-app:1.0
ports:
- name: hello-http
containerPort: 8080
readinessProbe:
httpGet:
path: /healthz
port: hello-http
initialDelaySeconds: 25
periodSeconds: 5
==> ingress.yaml <==
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: hc-from-probe
annotations:
kubernetes.io/ingress.class: gce-multi-cluster
spec:
backend:
serviceName: hello-service
servicePort: 8080 # Changed |
Looks like you figured out that the Service's port.Name needs to match up with the Deployment's container.port. It seems like most, if not all, of the problem is setting up the Ingress, Service & Deployment wrong. Do you agree? If so, can we close this as Working-As-Intended? |
I'm not sure if I set up the kubernetes manifests wrong. Is this requirement placed specifically by kubemci? My first example, with a Service port.name 'http' and Service port 8083 mismatched with Deployment spec's containerPort 8080 and container port.name 'hello-port' works correctly with GKE's ingress-gce. |
No, we don't have this requirement from Kubemci. (Its main requirement is that the same NodePorts are used across clusters.) @nicksardo to comment on why/whether things should work as you describe in the previous comment. |
That configuration should be allowed. The non-MCI ingress controller seems to behave as expected: https://github.com/kubernetes/ingress-gce/blob/master/pkg/controller/translator/translator.go#L228-L274. |
I am also having issues with this. My configuration is as follows. service.yaml
deploy.yaml
ingress.yaml
Curling the When i manually update the health check with the /ping endpoint the LB works. This seems to be an issue recognizing the alternate endpoint from the getProbe call and subsequently updating the healthcheck. The kubemci log:
|
+1 |
I discovered that the only case it works is if the containerPort is named, and the servicePort is numeric. It does not work with a numeric containerPort. (I didn't try a named servicePort because the original report in this issue is about that) |
I find it suspicious that
|
Given Kubernetes manifests
and then an Ingress spec that specifies servicePort by name instead of port number:
kubemci will fail to recognize the readiness probe with:
It works if you change the last line in the ingress spec to:
The text was updated successfully, but these errors were encountered: