Kong / Kong/charts

`kong`: Cannot install more than 1 ingress controller release with the same name in different namespace

Open
#910 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Mustache
Stars
300
Forks
489
Avg merge
1d 10h
Merged PRs (30d)
10

Description

### Problem statement

When using `kong` chart, users cannot install more than 1 ingress controller releases with the same name in different namespaces.

```
$ helm upgrade --install --create-namespace -n kong kic --values ./v_kic.yaml ./charts/kong
Release "kic" does not exist. Installing it now.
NAME: kic
LAST DEPLOYED: Fri Oct 20 17:55:54 2023
NAMESPACE: kong
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
To connect to Kong, please execute the following commands:

HOST=$(kubectl get svc --namespace kong kic-kong-proxy -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
PORT=$(kubectl get svc --namespace kong kic-kong-proxy -o jsonpath='{.spec.ports[0].port}')
export PROXY_IP=${HOST}:${PORT}
curl $PROXY_IP

Once installed, please follow along the getting started guide to start using
Kong: https://docs.konghq.com/kubernetes-ingress-controller/latest/guides/getting-started/
$ helm upgrade --install --create-namespace -n kong1 kic --values ./v_kic.yaml ./charts/kong
Release "kic" does not exist. Installing it now.
Error: Unable to continue with install: ClusterRole "kic-kong" in namespace "" exists and cannot be imported into the current release: invalid ownership metadata; annotation validation error: key "meta.helm.sh/release-namespace" must equal "kong1": current value is "kong"
```

Trying to fix the `ClusterRole` issue by including the namespace in the name

```diff
diff --git a/charts/kong/templates/_helpers.tpl b/charts/kong/templates/_helpers.tpl
index 7564c2e..1a77fc8 100644
--- a/charts/kong/templates/_helpers.tpl
+++ b/charts/kong/templates/_helpers.tpl
@@ -18,7 +18,7 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this

{{- define "kong.fullname" -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
-{{- default (printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-") .Values.fullnameOverride -}}
+{{- default (printf "%s-%s-%s" .Release.Namespace .Release.Name $name | trunc 63 | trimSuffix "-") .Values.fullnameOverride -}}
{{- end -}}

{{- define "kong.chart" -}}
```

Doesn't solve the problem because then we're conflicting owners of the `IngressClass`

```
Error: Unable to continue with install: IngressClass "kong" in namespace "" exists and cannot be imported into the current release: invalid ownership metadata; annotation validation error: key "meta.helm.sh/release-namespace" must equal "kong1": current value is "kong"
```

Surprisingly, installing in the same namespace with different release name works. The helm `annotations` on the `IngressClass` are then retained to refer to the first release.

### Proposed solution(s)

- Leave this as is and document properly
- Allow installing with the same release name in different namespaces and account for that in cluster wide resources
- Might be problematic when we take into account the fact that a lot of places that use this chart use the hardcoded `kong` `IngressClass` and that would have to be changed then

Contributor guide

Open the contributing guide

Research direction

Start with charts/kong/templates/_helpers.tpl and inspect how the chart names and annotates the cluster-wide ClusterRole and IngressClass resources. Compare the two proposed approaches, including the hardcoded kong IngressClass usage, and determine whether the result should support identical release names across namespaces or document the limitation; done means the chosen behavior is consistent for both resources.

Written by the indexing model from the issue text.

Assessment

Tech stack
helm, kubernetes
Domain
devops, infrastructure
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.