我正在尝试将 git repo url 添加到 openshift 中的 pod 注释中。然而,部署抱怨特殊字符不允许作为
app.openshift.io/vcs-uri
的值
这是错误:
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])?')
这是我的示例舵图:
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:
.......
标签值或名称中不能包含特殊字符,例如
@
或 /
。错误消息明确指出:
consist of alphanumeric characters, '-', '' or '.'
错误消息中甚至还有一个正则表达式:
'(([A-Za-z0-9][-A-Za-z0-9.]*)?[A-Za-z0-9])?'
您可以将该正则表达式插入任何选择的工具(例如 regex101.com),并检查您的标签值是否有效。
但是,如 Kubernetes 文档
中所述,注释的限制要少一些除了 Rick Rackow 提到的之外,
app.openshift.io/vcs-uri
应该是注释,而不是标签。
尝试这样的事情:
apiVersion: v1
kind: Service
metadata:
name: test-app
namespace: test-poc
annotations:
app.openshift.io/vcs-uri: "git://github.com/myrepo/testrepo.git"
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
spec:
type: ClusterIP
ports:
.......
参见:https://github.com/redhat-developer/app-labels/blob/master/labels-annotation-for-openshift.adoc