GoogleCloudPlatform / flink-on-k8s-operator

[DEPRECATED] Kubernetes operator for managing the lifecycle of Apache Flink and Beam applications.
Apache License 2.0
658 stars 265 forks source link

ExtraPorts option does not open ports on the service #340

Closed witzatom closed 4 years ago

witzatom commented 4 years ago

Hey, running the latest flink operator v1beta1-7 (gcr.io/flink-operator/flink-operator@sha256:e13804b93a988a4475e05b742eea9cd7dec5a5e36fc213e0ff8fe4d8ea963920). I use the config from https://github.com/GoogleCloudPlatform/flink-on-k8s-operator/blob/master/examples/prometheus/flink_metric_cluster.yaml.

The resulting jobmanager pod does get a port opened:

# kubectl describe pod/flink-metric-jobmanager-75c68cdd9f-ppxrb | grep Ports
    Ports:         6123/TCP, 6124/TCP, 6125/TCP, 8081/TCP, 9249/TCP
    Host Ports:    0/TCP, 0/TCP, 0/TCP, 0/TCP, 0/TCP

But the service does not, so its difficult to use the prometheus metrics in a prometheus setup:

# kubectl describe service/flink-metric-jobmanager | grep Port
Port:              rpc  6123/TCP
TargetPort:        rpc/TCP
Port:              blob  6124/TCP
TargetPort:        blob/TCP
Port:              query  6125/TCP
TargetPort:        query/TCP
Port:              ui  8081/TCP
TargetPort:        ui/TCP

Not sure if this is a bug or a feature request. However the actual pod ports are unlikely to be used unless they are exposed as service ports, so I think its a bug?

The issue is that this function here has no mention of the jobmanager extraPorts. Probably fixed by adding something similar to:

    for _, port := range jobManagerSpec.ExtraPorts {
        ports = append(ports, corev1.ContainerPort{Name: port.Name, ContainerPort: port.ContainerPort, Protocol: corev1.Protocol(port.Protocol)})
    }
functicons commented 4 years ago

This is not a bug, because PodMonitor doesn't require a Service, it directly selects Pods by labels, see the example:

spec:
  podTargetLabels:
    - cluster
    - component
  selector:
    matchLabels:
      app: flink
  # Specify the port name of the exposed metric port
  podMetricsEndpoints:
    - port: prom

Also, for TaskManagers, there is no Service for them.

witzatom commented 4 years ago

ok, agreed, i can use k8 discovery in prometheus to find the pods so dont need the static binding.