kubectl apply does not allow more than 63 chars on metadata.labels values

4/1/2020

I'm trying to create a LoadBalancer in my OKE cluster(Oracle Cloud Container Engine for Kubernetes). I'm doing a kubectl apply -f on the file, but it gives me this error.

The Service "servicename" is invalid: metadata.labels: Invalid value: "ocid1.vcn.oc1.iad.xx...xx": must be no more than 63 characters.

Here's the yaml file

apiVersion: v1
kind: Service
metadata:
  name: my-nginx-svc
  labels:
    app: nginx
  annotations:
    service.beta.kubernetes.io/oci-load-balancer-internal: "true"
    service.beta.kubernetes.io/oci-load-balancer-subnet1: "ocid1.subnet.oc1..aaaaaa...xxxxx"
spec:
  type: LoadBalancer
  ports:
  - port: 8100
  selector:
    app: nginx

I see the issue is because the value for service.beta.kubernetes.io/oci-load-balancer-subnet1: is more than 63 chars. But I can't change the value of the OCID. Is there a fix for this?

-- RMNull
kubernetes
load-balancing
oracle-cloud-infrastructure

1 Answer

4/1/2020

As far as i know there is no solution for that. The names of object in Kubernetes (and your annotation will create an object with the given name) should be DNS RFC complaint which is < 63 chars in the hostname part.

sources : - https://tools.ietf.org/html/rfc1123 - https://kubernetes.io/docs/concepts/overview/working-with-objects/names/

-- webofmars
Source: StackOverflow