Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not use variables in addonTemplate for namespace filed of resources #256

Closed
zhujian7 opened this issue Aug 25, 2023 · 4 comments
Closed
Labels
bug Something isn't working

Comments

@zhujian7
Copy link
Member

Describe the bug
I have a addonTemplate yaml, in which I want to set the namespace of the addon agent deployment a variable so it can be rendered by the managedclusteraddon.spec.installnamespace when deploying the agent.

apiVersion: addon.open-cluster-management.io/v1alpha1
kind: AddOnTemplate
metadata:
  name: hello-template
spec:
  addonName: hello-template
  agentSpec:
      workload:
        manifests:
          - kind: Deployment
            apiVersion: apps/v1
            metadata:
              name: hello-template-agent
              namespace: "{{INSTALL_NAMESPACE}}"   // error
              labels:
                app: hello-template-agent
            spec:
              replicas: 1
              selector:
                matchLabels:
                  app: hello-template-agent
              template:
                metadata:
                  labels:
                    app: hello-template-agent
                spec:
                  serviceAccountName: hello-template-agent-sa
                  containers:
                    - name: helloworld-agent
                      image: quay.io/open-cluster-management/addon-examples
                      imagePullPolicy: IfNotPresent
                      args:
                        - "/helloworld_helm"
                        - "agent"
                        - "--cluster-name={{CLUSTER_NAME}}"
                        - "--addon-namespace=open-cluster-management-agent-addon"
                        - "--addon-name=hello-template"
                        - "--hub-kubeconfig={{HUB_KUBECONFIG}}"
                      env:
                        - name: LOG_LEVEL
                          value: "{{LOG_LEVEL}}" # addonDeploymentConfig variables

But when I tried to create this addonTemplate, I got:

The AddOnTemplate "hello-template" is invalid: spec.agentSpec.workload.manifests[0].metadata.namespace: Invalid value: "{{INSTALL_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])?')

To Reproduce

  1. Create the above addontemplate yaml to a kubernetes cluster

Expected behavior
The addon template can be created successfully

Environment ie: OCM version, Kubernetes version and provider:
OCM version: the latest commit: 36e389c

Additional context

@zhujian7 zhujian7 added the bug Something isn't working label Aug 25, 2023
Copy link

This issue is stale because it has been open for 120 days with no activity. After 14 days of inactivity, it will be closed. Remove the stable label to prevent this issue from being closed.

@github-actions github-actions bot added the Stale label Dec 24, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 7, 2024
@zhujian7 zhujian7 reopened this Jan 8, 2024
@github-actions github-actions bot removed the Stale label Jan 9, 2024
@zhujian7
Copy link
Member Author

With this PR #417, even if we can not use variables for the namespace, we can configure the namespace by an addonDeploymentConfig.

@qiujian16 qiujian16 moved this to Done in OCM releases May 10, 2024
@qiujian16
Copy link
Member

/close

@openshift-ci openshift-ci bot closed this as completed May 22, 2024
Copy link
Contributor

openshift-ci bot commented May 22, 2024

@qiujian16: Closing this issue.

In response to this:

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

2 participants