0

If I create project 'A' and want to deploy a template from inside it that creates objects in project 'A' and also in another project 'B' how would I achieve this. I tried simply specifying the namespace of project 'B' in the template but got the error

the namespace of the provided object does not match the namespace sent on the request

  • I think you required cluster-admin role to create resources across multiple projects, or you should assign permission to create resources in target projects. – Daein Park Dec 04 '19 at 14:12
  • Thanks Daein, I thought the same but I do have cluster admin and am still having the problem. The error message makes me think that the problem is in the actual template – Richard Chester Dec 04 '19 at 15:00

1 Answers1

1

According to documentation:

If an object definition’s metadata includes a fixed namespace field value, the field will be stripped out of the definition during template instantiation. If the namespace field contains a parameter reference, normal parameter substitution will be performed and the object will be created in whatever namespace the parameter substitution resolved the value to, assuming the user has permission to create objects in that namespace.

So just specify required namespaces as template's parameters. Usable example:

apiVersion: template.openshift.io/v1
kind: Template
metadata:
  name: xxx
parameters:
- name: ns1
  value: test1
- name: ns2
  value: test2
objects:
- apiVersion: v1
  data:
    key1: value1
  kind: ConfigMap
  metadata:
    namespace: ${ns1}
    name: cm1
- apiVersion: v1
  data:
    key2: value2
  kind: ConfigMap
  metadata:
    namespace: ${ns2}
    name: cm2
Oligzeev
  • 511
  • 3
  • 7