使用 Ansibl 创建命名空间。导出命名空间=awx
Create namespace with Ansibl. Export NAMESPACE=awx
您好!
我厌倦了使用安装手册创建一些用于部署“AWX Operator”和 Kubernetes 的剧本 Install AWX Operator
我有命令:
export NAMESPACE=awx
kubectl create ns ${NAMESPACE}
我创建了任务:
- name: Echo export NAMESPACE awx
shell: "export NAMESPACE=awx"
environment:
NAMESPACE: awx
- name: my_env_var
shell: "kubectl create ns NAMESPACE"
但是我得到一个错误:
fatal: [jitsi]: FAILED! => {"changed": true, "cmd": "kubectl create ns NAMESPACE", "delta": "0:00:00.957414", "end": "2021-10-22 13:25:16.822714", "msg": "non-zero return code", "rc": 1, "start": "2021-10-22 13:25:15.865300", "stderr": "The Namespace \"NAMESPACE\" is invalid: metadata.name: Invalid value: \"NAMESPACE\": a lowercase RFC 1123 label must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name', or '123-abc', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?')", "stderr_lines": ["The Namespace \"NAMESPACE\" is invalid: metadata.name: Invalid value: \"NAMESPACE\": a lowercase RFC 1123 label must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name', or '123-abc', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?')"], "stdout": "", "stdout_lines": []}
你能帮我提点建议吗? 谢谢。
你把所有的东西都写在了这个错误中:)
命令有问题
kubectl create ns NAMESPACE
您想创建一个名为 NAMESPACE
的名称空间,这是错误的。 您不能在命名空间的名称中使用大写字母。您可以从这条消息中得到提示:
Invalid value: \"NAMESPACE\": a lowercase RFC 1123 label must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name', or '123-abc'
如何解决?您需要更改此行:
shell: "kubectl create ns NAMESPACE"
您需要正确设置不带大写字母的命名空间。
示例:
shell: "kubectl create ns my-namespace"
shell: "kubectl create ns my-name"
shell: "kubectl create ns whatever-you-want"
您好!
我厌倦了使用安装手册创建一些用于部署“AWX Operator”和 Kubernetes 的剧本 Install AWX Operator
我有命令:
export NAMESPACE=awx
kubectl create ns ${NAMESPACE}
我创建了任务:
- name: Echo export NAMESPACE awx
shell: "export NAMESPACE=awx"
environment:
NAMESPACE: awx
- name: my_env_var
shell: "kubectl create ns NAMESPACE"
但是我得到一个错误:
fatal: [jitsi]: FAILED! => {"changed": true, "cmd": "kubectl create ns NAMESPACE", "delta": "0:00:00.957414", "end": "2021-10-22 13:25:16.822714", "msg": "non-zero return code", "rc": 1, "start": "2021-10-22 13:25:15.865300", "stderr": "The Namespace \"NAMESPACE\" is invalid: metadata.name: Invalid value: \"NAMESPACE\": a lowercase RFC 1123 label must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name', or '123-abc', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?')", "stderr_lines": ["The Namespace \"NAMESPACE\" is invalid: metadata.name: Invalid value: \"NAMESPACE\": a lowercase RFC 1123 label must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name', or '123-abc', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?')"], "stdout": "", "stdout_lines": []}
你能帮我提点建议吗? 谢谢。
你把所有的东西都写在了这个错误中:)
命令有问题
kubectl create ns NAMESPACE
您想创建一个名为 NAMESPACE
的名称空间,这是错误的。 您不能在命名空间的名称中使用大写字母。您可以从这条消息中得到提示:
Invalid value: \"NAMESPACE\": a lowercase RFC 1123 label must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name', or '123-abc'
如何解决?您需要更改此行:
shell: "kubectl create ns NAMESPACE"
您需要正确设置不带大写字母的命名空间。
示例:
shell: "kubectl create ns my-namespace"
shell: "kubectl create ns my-name"
shell: "kubectl create ns whatever-you-want"