edgexfoundry / edgex-examples

Apache License 2.0
51 stars 52 forks source link

helm deployment: Container port names are not API spec compliant #168

Closed bnevis-i closed 1 year ago

bnevis-i commented 1 year ago

🐞 Bug Report

Affected Services [REQUIRED]

helm deployment

Is this a regression?

No

Description and Minimal Reproduction [REQUIRED]

For all Deployment resources

According to the Kubernetes API spec, the port.name field must be an IANA_SVC_NAME.

https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#containerport-v1-core "If specified, this must be an IANA_SVC_NAME and unique within the pod. Each named port in a pod must have a unique name. Name for the port that can be referred to by services."

Here the name is taken from the following table: https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml

In may cases, the name in the rendered helm chart (install with --dry-run --debug and inspect the resulting output), is just a number.

The intended use for this port is that a Kubernetes service could reference the port by name. See https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#serviceport-v1-core "targetPort: Number or name of the port to access on the pods targeted by the service. Number must be in the range 1 to 65535. Name must be an IANA_SVC_NAME. If this is a string, it will be looked up as a named port in the target Pod's container ports. If this is not specified, the value of the 'port' field is used (an identity map). This field is ignored for services with clusterIP=None, and should be omitted or set equal to the 'port' field. More info: https://kubernetes.io/docs/concepts/services-networking/service/#defining-a-service"

The port name should be brought into spec compliance.

For all Service resources

name must be a DNS label:

RFC 1123 Label Names

Some resource types require their names to follow the DNS label standard as defined in RFC 1123. This means the name must:

Therefore all services in the helm charts that a numeric only name are non-compliant.

Suggest that for us, we make the service port a combination of the service name, a hypen, then the port.name from the deployment, e.g. core-data-http

🔥 Exception or Error

No error is produced.