How do you access configmaps created in non-default namespace?

4,881 views
Skip to first unread message
Assigned to manojkuma...@gmail.com by me

Manoj Khotele

unread,
Sep 21, 2016, 12:50:09 AM9/21/16
to Kubernetes user discussion and Q&A
Hello,

I have created a configmap, let's say, named 'my-configmap' in let's say 'non-default-namespace' namespace.
I am trying to create a deployment in the same 'non-default-namespace' itself, which refers to the config-map to get the values of env var populated.

But I am always getting the error which indicates that k8s could not find the configmap.

I tried almost all the combinations for mentioning the name of config-maps for accessing the key-values from deployment file; like:
non-default-namespace.my-configmap, my-configmap.non-default-namespace, my-configmap

I tried separators other than '.' as well, like '/' and ':'.

Please help.

I am working with k8s v 1.3.4.

Best Regards,
Manoj

Brandon Philips

unread,
Sep 21, 2016, 1:04:27 AM9/21/16
to Kubernetes user discussion and Q&A
Please attach or paste in the json/yaml for the configmap and deployment so we can help debug.

--
You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-use...@googlegroups.com.
To post to this group, send email to kubernet...@googlegroups.com.
Visit this group at https://groups.google.com/group/kubernetes-users.
For more options, visit https://groups.google.com/d/optout.

Manoj Khotele

unread,
Sep 21, 2016, 2:54:29 AM9/21/16
to kubernet...@googlegroups.com
Hello Brandon,

Please find attached the files which I have tried and tested against k8s-v1.3.4.
Just go on creating namespace, configmap and then deployment.

Then describe the pod created. You will get this error - Error syncing pod, skipping: failed to "StartContainer" for "logstash" with RunContainerError: "GenerateRunContainerOptions: configmaps \"my-configmap.non-default-namespace\" not found"

Thanks in advance,
Manoj

On Wed, Sep 21, 2016 at 10:34 AM, Brandon Philips <brandon...@coreos.com> wrote:
Please attach or paste in the json/yaml for the configmap and deployment so we can help debug.

On Tue, Sep 20, 2016 at 9:50 PM Manoj Khotele <manojkuma...@gmail.com> wrote:
Hello,

I have created a configmap, let's say, named 'my-configmap' in let's say 'non-default-namespace' namespace.
I am trying to create a deployment in the same 'non-default-namespace' itself, which refers to the config-map to get the values of env var populated.

But I am always getting the error which indicates that k8s could not find the configmap.

I tried almost all the combinations for mentioning the name of config-maps for accessing the key-values from deployment file; like:
non-default-namespace.my-configmap, my-configmap.non-default-namespace, my-configmap

I tried separators other than '.' as well, like '/' and ':'.

Please help.

I am working with k8s v 1.3.4.

Best Regards,
Manoj

--
You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-users+unsubscribe@googlegroups.com.
To post to this group, send email to kubernetes-users@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kubernetes-users/cVxRal4WU8k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kubernetes-users+unsubscribe@googlegroups.com.
To post to this group, send email to kubernetes-users@googlegroups.com.
cm-ns-issue-files.zip

Manoj Khotele

unread,
Sep 21, 2016, 5:20:54 AM9/21/16
to Kubernetes user discussion and Q&A
One more observation worth mentioning.

I can't access the configmap from a deployment which is created in non-default-namespace, even if the configmap is created in default namespace.
I can access the configmaps only if both deployment and configmap created only in default namespace.

Best Regards,
Manoj

Manoj Khotele

unread,
Sep 21, 2016, 5:31:21 AM9/21/16
to Kubernetes user discussion and Q&A
Even one more observation.

You can't use field 'namespace' in 'ConfigMapKeySelector'. 
Else you get error something like "error validating "my-logstash-deployment.yml": error validating data: found invalid field namespace for v1.ConfigMapKeySelector; if you choose to ignore these errors, turn validation off with --validate=false"

Best Regards,
Manoj

Jimmi Dyson

unread,
Sep 21, 2016, 5:31:22 AM9/21/16
to kubernet...@googlegroups.com
AFAIK you can't reference config maps across namespaces. Try creating the configmap & deployment in the same namespace, & setting the configMapKeyRef.name to simply the name of the configmap (my-configmap in your example).

On Wed, 21 Sep 2016 at 07:54 Manoj Khotele <manojkuma...@gmail.com> wrote:
Hello Brandon,

Please find attached the files which I have tried and tested against k8s-v1.3.4.
Just go on creating namespace, configmap and then deployment.

Then describe the pod created. You will get this error - Error syncing pod, skipping: failed to "StartContainer" for "logstash" with RunContainerError: "GenerateRunContainerOptions: configmaps \"my-configmap.non-default-namespace\" not found"

Thanks in advance,
Manoj

On Wed, Sep 21, 2016 at 10:34 AM, Brandon Philips <brandon...@coreos.com> wrote:
Please attach or paste in the json/yaml for the configmap and deployment so we can help debug.

On Tue, Sep 20, 2016 at 9:50 PM Manoj Khotele <manojkuma...@gmail.com> wrote:
Hello,

I have created a configmap, let's say, named 'my-configmap' in let's say 'non-default-namespace' namespace.
I am trying to create a deployment in the same 'non-default-namespace' itself, which refers to the config-map to get the values of env var populated.

But I am always getting the error which indicates that k8s could not find the configmap.

I tried almost all the combinations for mentioning the name of config-maps for accessing the key-values from deployment file; like:
non-default-namespace.my-configmap, my-configmap.non-default-namespace, my-configmap

I tried separators other than '.' as well, like '/' and ':'.

Please help.

I am working with k8s v 1.3.4.

Best Regards,
Manoj

--
You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-use...@googlegroups.com.
To post to this group, send email to kubernet...@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kubernetes-users/cVxRal4WU8k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kubernetes-use...@googlegroups.com.

To post to this group, send email to kubernet...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-use...@googlegroups.com.
To post to this group, send email to kubernet...@googlegroups.com.

Manoj Khotele

unread,
Sep 21, 2016, 5:42:06 AM9/21/16
to Kubernetes user discussion and Q&A
Thanks a lot Jimmi. It worked.

Jimmi Dyson

unread,
Sep 21, 2016, 5:53:36 AM9/21/16
to Kubernetes user discussion and Q&A
In general, try not to specify namespace in your resource manifests. That makes them more portable (i.e. able to create the same resources in different namespaces that the user chooses at deploy time via kubectl --namespace flag or similar).
Reply all
Reply to author
Forward
0 new messages