Add vcs-url label to pod in openshift with app.openshift.io/vcs-uri annotation

Viewed 21

I am trying to add git repo url to pod annotation in openshift. However deployment complains about special character is not allowed as value for app.openshift.io/vcs-uri

Here is the error:

Deploy failed: The Deployment "test-app" is invalid: metadata.labels: Invalid value: "git://github.com/myrepo/testrepo.git": a valid label must be an empty string or consist of alphanumeric characters, '-', '' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue', or 'my_value', or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9.]*)?[A-Za-z0-9])?')

Here is my sample helm chart:

apiVersion: v1
kind: Service
metadata:
  name: test-app
  namespace: test-poc
  labels:
    helm.sh/chart: poc-0.0.1
    app.kubernetes.io/name: angular
    app.kubernetes.io/instance: test-app
    app.kubernetes.io/version: "2.4"
    app.kubernetes.io/managed-by: Helm
    app.openshift.io/runtime: angularjs
    app.openshift.io/vcs-uri: "git://github.com/myrepo/testrepo.git"
spec:
  type: ClusterIP
  ports:
  .......
1 Answers

You cannot have special characters like @ or / in your label value or name. The error message clearly states that:

consist of alphanumeric characters, '-', '' or '.'

There is even a regex in the error message:

'(([A-Za-z0-9][-A-Za-z0-9.]*)?[A-Za-z0-9])?'

You can plug that Regular Expression into any choice of tool like regex101.com and check if your label value works.

However, annotations are a little less restricted as described in the Kubernetes Documentation

Related