If CHE_INFRA_KUBERNETES_NAMESPACE_DEFAULT=foo-<username>
then the runtime value for CHE_WORKSPACE_NAMESPACE on has the <username> part.
The namespace itself is correct; just the env variable value is wrong.
We don't expose the name of the Kubernetes namespace (or OpenShift project) the workspace runs in. The CHE_WORKSPACE_NAMESPACE environment variable contains what can basically be described as the name of the owner of the workspace. I've created a PR to the Che documentation to clarify the meaning of that environment variable.
@metlos @mingfang
Does it mean that the issue is solved?
@metlos @mingfang
Does it mean that the issue is solved?
What is the reason you don't expose the name of the Kubernetes namespace?
I workaround this issue using the Downwards API like this
https://github.com/mingfang/terraform-provider-k8s/blob/master/devfile.yaml#L33
@metlos I can't make sense of what is being said here. The var name, CHE_WORKSPACE_NAMESPACE, clearly indicates that it would contain the namespace. Also why would this info not be exposed. It is actually useful info. If you need a var that contains the owner then create a var that is named something that communicates that it contains the owner. Reasonable expectation is violated when the var CHE_WORKSPACE_NAMESPACE does not contain the namespace. If the names match the contents then documentation should be superfluous.
@mingfang @jflowers let's start from expectation. What do you want to see in the workspace?
CHE_WORKSPACE_NAMESPACE https://github.com/eclipse/che/blob/93ba5ef2f36a52206e8bb7bc7e8827a75de1022d/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/WorkspaceNamespaceNameEnvVarProvider.java#L31 right?
Wait there is a Che concept of namespace that is distinct from the kubernetes namespace?
Wait there is a Che concept of namespace that is distinct from the kubernetes namespace?
yes. As @metlos mention https://github.com/eclipse/che/issues/16325#issuecomment-598068062 it can be a username(in 99% cases) or organization name https://www.eclipse.org/che/docs/che-7/using-organizations/
I don't see the word namespace in that at all. It sounds like this variable was named poorly. I can't find in documentation anywhere that Che has a concept of a namespace distinct from kubernetes.
you right. That is a concept of che comes before the k8s era. We definitely need to improve our docs in this area.
okay, that is unfortunate.
To get back to you question... I am interested in knowing the kubernetes namespace so I can programmatically construct a URL to and endpoint in the Che Workspace...
If I set the endpoint name in the devfile.yaml I can use:
https://docs.openshift.com/enterprise/3.0/architecture/additional_concepts/networking.html
<endpoint_from_devfile>.<namespace>.endpoints.cluster.local
then I can run a selenium test against that from a Selenium Grid hosted in the same cluster
here is an example:
https://github.com/jflowers/spring-petclinic/blob/master/devfile.yaml
@mingfang @jflowers let's start from expectation. What do you want to see in the workspace?
- Che namespace of workspace
CHE_WORKSPACE_NAMESPACEhttps://github.com/eclipse/che/blob/93ba5ef2f36a52206e8bb7bc7e8827a75de1022d/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/spi/provision/env/WorkspaceNamespaceNameEnvVarProvider.java#L31- Kubernetes namespace of workspace. AFAIK no such variable at this moment.
right?
I was thinking of Kubernetes Namepspace
@jflowers you probably wants something like this https://github.com/eclipse/che/issues/15021 no?
@mingfang if there is no such information already exist I think it's legitimate request to add it.
@skabashnyuk that would be great, yes