kyma: Installation CR is not found when namespace in KUBECONFIG is overridden
Description
In your code, you have assumption that the Installation CR will be created in default namespace, see: https://github.com/kyma-project/kyma/blob/master/components/installer/pkg/consts/const.go#L4
but the template does not ensure that this resource will be created in the default namespace, see:
- https://github.com/kyma-project/kyma/blob/master/installation/resources/installer-cr-cluster-xip-io.yaml.tpl#L3-L6
- https://github.com/kyma-project/kyma/blob/master/installation/resources/installer-cr-cluster.yaml.tpl#L3-L6
- https://github.com/kyma-project/kyma/blob/master/installation/resources/installer-cr.yaml.tpl#L3-L6
Your assumption is that when Namespace is not provided in resource YAML file then it is always created in default Namespace. This assumption is wrong.
If Namespace is not specified in given resource YAML file AND Namespace is not specified in KUBECONFIG file under the context property then the default Namespace is used. But when you have KUBECONFIG where under the context property someone will add the information about the namespace then this namespace name is used.
KUBECONFIG without namespace: $ kc config view
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: REDACTED
server: https://nightlyclusterkymacx.westeurope.cloudapp.azure.com
name: nightlyclusterkymacx
contexts:
- context:
cluster: nightlyclusterkymacx
user: nightlyclusterkymacx-admin
name: nightlyclusterkymacx
current-context: nightlyclusterkymacx
kind: Config
preferences: {}
users:
- name: nightlyclusterkymacx-admin
user:
client-certificate-data: REDACTED
client-key-data: REDACTED
KUBECONFIG with namespace specified: $ kc config view
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: REDACTED
server: https://nightlyclusterkymacx.westeurope.cloudapp.azure.com
name: nightlyclusterkymacx
contexts:
- context:
cluster: nightlyclusterkymacx
namespace: qa
user: nightlyclusterkymacx-admin
name: nightlyclusterkymacx
current-context: nightlyclusterkymacx
kind: Config
preferences: {}
users:
- name: nightlyclusterkymacx-admin
user:
client-certificate-data: REDACTED
client-key-data: REDACTED
NOTE: specifying this Namespace in Kubeconfig is a valid case, and this functionality is used by well-known helper tool https://github.com/ahmetb/kubectx
When creating the installation resources via kubectl with the second KUBECONFIG then the installation fails.
The reason is that the Installation CR is created, so your informer is detecting that but then you are trying to get this Installation CR in the default namespace.
I can see here two problems:
- Informer should be namespace scoped only to
defaultNamespace, so the installation won’t be triggered - The Installation CR YAML should have specified the Namespace property.
But for me is not clear why the Installation CRD is Namespace scoped? Shouldn’t be just a Cluster-wide? Thanks to that the above problems will be solved.
Steps to reproduce Execute this step from Kyma Installation documentation with the KUBECONFIG which has namespace defined under context property.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 15 (4 by maintainers)
Commits related to this issue
- Whitesource fix (#2134) — committed to grischperl/kyma by kasiakepka 4 years ago
Dear stale bot, I can confirm that it is still very valid 😉