code-to-prod-demo icon indicating copy to clipboard operation
code-to-prod-demo copied to clipboard

All application resources are created in gitops-demo namespace and not the one which is defined in kustomization.yaml for stage and prod branches.

Open lniesz opened this issue 2 years ago • 2 comments

Hi,

I'm trying your solution in RHACM (v2.4 on Openshift 4.10). After following the deployment and run steps all application related resources, which is set on https://github.com/mvazquezc/reverse-words-cicd repo for stage and prod branches are defined in gitops-demo namespace on the stage and production clusters and not in the one specified in kustomization.yaml. Have you seen this problem and what could be the solution. As I know the none of the RHACM application, subscription and placementrule can be used to specify target namespace.

Best Regards, Laszlo

lniesz avatar May 31 '22 09:05 lniesz

Hey @lniesz, does the user that creates the RHACM subscription have the subscription-admin role assigned? If not, that subscription won't be able to create objects outside of the subscription's namespace on the managed cluster.

mvazquezc avatar Jun 01 '22 13:06 mvazquezc

Hi @mvazquezc, Yes I've run the command, which was in your guide: oc adm policy add-cluster-role-to-user open-cluster-management:subscription-admin $(oc whoami) Now I have a new CRB with my user (which is admin, as I'm testing this method now) as subject. Still the resources were created in the subscription namespace on both my clusters, however on the remote cluster there is nothing else just the application resources in it. After some reading I've found a solution, which maybe is not the best, but I could override the target namespace with the following in the subscription yaml file: overrides: - clusterName: / clusterOverrides: - path: metadata.namespace value: reverse-words-stage In the documentation I found this annotation: "apps.open-cluster-management.io/current-namespace-scoped: true", but if this is not the default behavior and I do not put there, then it should create the resources based on the kustomization.yaml file on the Git repo, in case I'm subscription admin. Am I missing something here?

lniesz avatar Jun 01 '22 16:06 lniesz