Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[kong] use latest available Ingress version #446

Merged
merged 5 commits into from
Aug 20, 2021
Merged

Conversation

rainest
Copy link
Contributor

@rainest rainest commented Aug 19, 2021

What this PR does / why we need it:

Add support for networking.k8s.io/v1beta1 and networking.k8s.io/v1
Ingress resources. Generate Ingress resources with the newest available
version on the cluster.

Add support for the ingressClassName field and IngressClass resource.

We need Ingress v1 support for 1.22. These are fairly recent, however, so instead of blanket changes to v1, this auto-detects the latest available version and creates resources according.

Which issue this PR fixes

(optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged)

Special notes for your reviewer:

Does anyone know of a local K8S environment <1.18 that still works? KIND and Minikube are both failing to start for me on 1.17 and 1.16 images, and I can't find related issues with a fix in those projects.

I can force the extensions content to render with invalid versions:

diff --git a/charts/kong/templates/_helpers.tpl b/charts/kong/templates/_helpers.tpl
index 268182f45..386ade324 100644
--- a/charts/kong/templates/_helpers.tpl
+++ b/charts/kong/templates/_helpers.tpl
@@ -1076,9 +1076,9 @@ Kubernetes resources it uses to build Kong configuration.
 {{- end -}}
 
 {{- define "kong.ingressVersion" -}}
-{{- if (.Capabilities.APIVersions.Has "networking.k8s.io/v1") -}}
+{{- if (.Capabilities.APIVersions.Has "anetworking.k8s.io/v1") -}}
 networking.k8s.io/v1
-{{- else if (.Capabilities.APIVersions.Has "networking.k8s.io/v1beta1") -}}
+{{- else if (.Capabilities.APIVersions.Has "anetworking.k8s.io/v1beta1") -}}
 networking.k8s.io/v1beta1
 {{- else -}}
 extensions/v1beta1

Which makes helm template trk /tmp/symkong -f ~/src/charts/charts/kong/example-values/minimal-kong-controller.yaml --set admin.enabled=true --set admin.ingress.enabled=true > /tmp/fakeold.yaml render fakeold.yaml.txt

Checklist

[Place an '[x]' (no spaces) in all applicable fields. Please remove unrelated fields.]

  • PR is based off the current tip of the next branch and targets next, not main
  • New or modified sections of values.yaml are documented in the README.md
  • Title of the PR and commit headers start with chart name (e.g. [kong])

@rainest rainest requested a review from a team as a code owner August 19, 2021 22:16
Add support for networking.k8s.io/v1beta1 and networking.k8s.io/v1
Ingress resources. Generate Ingress resources with the newest available
version on the cluster.

Add support for the ingressClassName field and IngressClass resource.
@rainest rainest force-pushed the feat/ingress-version branch 3 times, most recently from e277d59 to 2447119 Compare August 19, 2021 23:18
Copy link
Contributor

@ccfishk ccfishk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Member

@shaneutt shaneutt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would ask that we add some integration tests for this functionality, and then 👍

@rainest rainest merged commit 1308ba3 into next Aug 20, 2021
@rainest rainest deleted the feat/ingress-version branch August 20, 2021 23:35
rainest added a commit that referenced this pull request Sep 2, 2021
Add support for networking.k8s.io/v1beta1 and networking.k8s.io/v1
Ingress resources. Generate Ingress resources with the newest available
version on the cluster.

Add support for the ingressClassName field and IngressClass resource.

Delete test installs after completion.
@Nica-Alex
Copy link

This is not working with my 1.18 cluster: no matches for kind "Ingress" in version "networking.k8s.io/v1"
I think your condition

{{- if (.Capabilities.APIVersions.Has "networking.k8s.io/v1") -}}
 networking.k8s.io/v1
 {{- else if (.Capabilities.APIVersions.Has "networking.k8s.io/v1beta1") -}}
 networking.k8s.io/v1beta1
 {{- else -}}
 extensions/v1beta1
 {{- end -}}

is wrong, as k8s 1.18 has networking.k8s.io/v1 but it doesn't contain Ingress until 1.19.

This is what I had to do in one of my charts:

{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.Version -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0, <1.19-0" .Capabilities.KubeVersion.Version -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}

Check this issue here.

@robincher
Copy link
Member

Hi,

Upon installing kong ingress controller, i run 'kubectl get ingressclass ", but for some reasons i am unable to find the corresponding ingress class for kong. I guess this Pull Request will address the issue i encountered?

#values.yaml
 ingressController:
      enabled: true
      ingressClass: kong

@rainest rainest mentioned this pull request Oct 29, 2021
3 tasks
@rainest
Copy link
Contributor Author

rainest commented Oct 29, 2021

@robincher this is a completed PR. We don't normally track new comments on these. Please file an issue, ask a question in the #kong Kubernetes Slack channel, or make a post in Kong Nation in the future.

https://github.com/Kong/charts/pull/446/files#diff-1f3f47b958cb61ddd4f0d4a7882b8ebbe64b9771e80f4b76cd94bc327a30f107 should create one if you're on a version that supports it, but part of the check was backwards, so #485

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants