Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

[WIP]: Kong ingress controller #7350

Closed
wants to merge 6 commits into from
Closed

[WIP]: Kong ingress controller #7350

wants to merge 6 commits into from

Conversation

merqurio
Copy link
Contributor

What this PR does / why we need it:
Adds a kong ingress controller deployment to the chart. This enables the management of kong using custom resources.

Which issue this PR fixes:
fixes Kong/kubernetes-ingress-controller/issues/36

Special notes for your reviewer:
It's a first approach, it's working for us, please, I'm open to suggestions and reviews.

It's limited to Kong CE 0.13.X, but support for 0.14.0 was merged a couple of days. @shashiranjan84, can you release a new version of the docker image ?

@hbagdi, I wasn't able to make it work when the kong-admin port is secured, is this the expeceted behaviour ? It makes sense to me, but I wanted to check first:

ingress-controller:
 main.go:144] Get https://localhost:8444/: x509: certificate signed by unknown authority

Thanks !

@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Aug 25, 2018
@k8s-ci-robot
Copy link
Contributor

Hi @merqurio. Thanks for your PR.

I'm waiting for a helm member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Aug 25, 2018
@merqurio
Copy link
Contributor Author

/check-cla

1 similar comment
@merqurio
Copy link
Contributor Author

/check-cla

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Aug 25, 2018
@hbagdi
Copy link
Collaborator

hbagdi commented Aug 27, 2018

@hbagdi, I wasn't able to make it work when the kong-admin port is secured, is this the expeceted behaviour ?

Yes, the ingress controller currently does not take into account any authentication applied on the Admin port of Kong.


# Ingress Controller:
# A controller watches for kubernetes resources defined with a
# CustomResourceDefinition that represent the configuration of a deployment.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Kong Ingress Controller's primary purpose is to satisfy Ingress resources created in k8s.
It uses CRDs for more fine grained control over routing and for Kong specific configuration.

@merqurio Could you update the description to communicate this? Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Thanks,

@hbagdi
Copy link
Collaborator

hbagdi commented Aug 27, 2018

ping @shashiranjan84

@shashiranjan84
Copy link
Collaborator

I will try to review it as soon as possible.

@hbagdi
Copy link
Collaborator

hbagdi commented Aug 27, 2018

I would like to list out two approaches to do this:

  1. Put the controller into the same chart as Kong as done in this PR.
  2. Create another Chart kong-ingress which adds kong chart as a dependency.

I currently don't have a preference, although (2) will be better in the longer term?
If there's an idiomatic way to do this with Helm, we should do that.

path: "/healthz"
port: 10254
scheme: HTTP
initialDelaySeconds: 30
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we bump this up to 180 as set for Kong Admin and proxy pods?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I took that from here, changing to 180.

periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
readinessProbe:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we add a initialDelaySeconds of 120 for readinessProbe as set for Kong pods?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, it was missing here, modified to 102, thanks

@@ -0,0 +1,7 @@
{{- if .Values.ingressController.enabled -}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we name this file controller-service-account?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, thanks for the suggestion.

@@ -0,0 +1,15 @@
{{- if .Values.ingressController.enabled -}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we name this file controller-rbac-role-binding since kong is redundant here?

@@ -0,0 +1,42 @@
{{- if .Values.ingressController.enabled -}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we name this file controller-rbac-role?

@@ -0,0 +1,63 @@
{{- if .Values.ingressController.enabled -}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we name this file controller-cluster-role?

@@ -0,0 +1,14 @@
{{- if .Values.ingressController.enabled -}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we name this file controller-rbac-cluster-role-binding?

@@ -0,0 +1,13 @@
{{- if .Values.ingressController.enabled -}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we keep the names of the files for all CRDs singular?
Like crd-kongconsumer for this file? Thanks!

@@ -0,0 +1,119 @@
{{- if .Values.ingressController.enabled -}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we rename this to controller-deployment?

livenessProbe:
{{ toYaml .Values.ingressController.livenessProbe | indent 10 }}
resources:
{{ toYaml .Values.ingressController.resources | indent 10 }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

@merqurio Could you explain you've included this Volume mount?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed. It came from here I wasn't sure if it was necessary. thanks

@hbagdi
Copy link
Collaborator

hbagdi commented Aug 27, 2018

@shashiranjan84
A couple of questions,

  1. Migrations are run as a batch job. What is the behavior with it when during a Kong version upgrade? Will it be ensured that the job is fired once again or is the migration job run only once at the start of this deployment?

  2. We currently use an Ingress rule to expose Kong Proxy and Admin, this sounds a bit weird now, since Kong itself is an Ingress controller, which will satisfy the ingress now. Thoughts?

@shashiranjan84
Copy link
Collaborator

@merqurio Before I review this PR I am wondering why can't we have Kong-ingress as separate chart?

@mattfarina mattfarina added the Contribution Allowed If the contributor has signed the DCO or the CNCF CLA (prior to the move to a DCO). label Aug 27, 2018
@merqurio
Copy link
Contributor Author

Put the controller into the same chart as Kong as done in this PR.

Personally I think this is the best approach, due to the templating nature of Helm, setting the ingress controller as a feature feels more natural to me. nginx is also available as an ingress chart. Of course if you consider that it really should be another chart, I don't mind creating a new chart, I just thought that the kong ingress controller was the most kubernetes friendly approach to kong.

Migrations are run as a batch job. What is the behavior with it when during a Kong version upgrade? Will it be ensured that the job is fired once again or is the migration job run only once at the start of this deployment?

I do like the init-container approach i saw in the kong ingress examples. I just modified that too, as I consider that as a kong maintainer you understand better the lifecycle.

We currently use an Ingress rule to expose Kong Proxy and Admin, this sounds a bit weird now, since Kong itself is an Ingress controller, which will satisfy the ingress now. Thoughts?

I completely agree. I didn't want to be too destructive with the existing chart. @shashiranjan84, you're the main maintainer, thoughts on that ? I will remove them in the meantime.

@shashiranjan84
Copy link
Collaborator

@merqurio thanks again for PR. I discussed it with @hbagdi and we planned to keep it separate as both Kong as application and as ingress controller behave in a different way. Matter of fact we were planning to create a new chart for ingress controller last week. So I would request you to send a separate PR with a new chart for Kong ingress controller.

I do like the init-container approach i saw in the kong ingress examples. I just modified that too, as I consider that as a kong maintainer you understand better the lifecycle.

init-container is not the right approach. Goal was to not start multiple kong pods running migration at once and a separate migration job handles it well.

@merqurio
Copy link
Contributor Author

Thanks @shashiranjan84 for the feedback, I'll move things around and push back as a new chart. I prefer to keep the changes on the same PR to make it easier to follow. I will create the chart in the incubator directory.

@shashiranjan84
Copy link
Collaborator

Thanks @merqurio. Feel free to drop any question here. Me and @hbagdi will work along with you to get 1st version out.

@merqurio
Copy link
Contributor Author

Problems that have emerged due to the split chart approach:

  • There is no support for recursive dependency solving for requirements (at least yet), so deploying Postgres or Cassandra is totally up to the user in charts where kong-ingress is a dependency.
  • I took advanvantage that template names are global to override some values in the kong chart (db related oned). Feels nasty.
  • I still don't like this approach from a users perspective. To trigger a migration I have to modify a value for a subchart in the parent. This is suboptimal for complex charts, where kong-ingress itself might be a dependency, adding more complexity.
  • There are many kong-ingress values defined at the subchart level. It doesn't make much sense to override so many values.

I really think the one chart solution is much more elegant and simpler to maintain. Please, think about complex charts where the ingress will be used.

A couple of questions:

  • Why does the proxy/admin have service of type NodePort ?

@merqurio merqurio changed the title Kong ingress controller [WIP]: Kong ingress controller Aug 28, 2018
@merqurio
Copy link
Contributor Author

merqurio commented Aug 28, 2018

For some reason even if kong.postgresql.enabled: false is set as default or set manually the postgresql chart is deployed anyway. Not sure why. Tested on minikube and kubernetes testing cluster.

@merqurio
Copy link
Contributor Author

Thanks @shashiranjan84 and @hbagdi for the support, I really appreciate @Kong presence to make this chart reliable and focused in the long term.

@hbagdi
Copy link
Collaborator

hbagdi commented Aug 30, 2018

Hello @merqurio,

@shashiranjan84 and I had a discussion on this and we've agreed on keeping the ingress controller chart as part of the kong chart. We apologize for the extra work you had to do around separating things out.

Could you revert it to the original PR you had?
We will review it, test it and then work together to get this merged in.

Thank you for taking the initiative to make this possible!

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: merqurio
To fully approve this pull request, please assign additional approvers.
We suggest the following additional approver: unguiculus

If they are not already assigned, you can assign the PR to them by writing /assign @unguiculus in a comment when ready.

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@RTodorov
Copy link
Contributor

RTodorov commented Oct 19, 2018

Hello guys! Great work with this chart, looking forward to getting this very important improvement merged.

Once this PR is merged, I'd like to add support to customized ingress class name, via - '--ingress-class=kong', as described here.

Do you think it would make sense? If yes, I could work on that PR.

My use case is that I'll have a normal nginx-ingress serving internal stuff (like prometheus, grafana etc) and Kong serving my microservices endpoints.

Thanks for your input and hard work on this PR!

@hbagdi
Copy link
Collaborator

hbagdi commented Oct 19, 2018

@RTodorov Sounds good, thank you!

@hbagdi
Copy link
Collaborator

hbagdi commented Oct 22, 2018

@merqurio Could you merge and resolve conflicts and add docs? Let's wrap this up soon to avoid staleness.

@helm-bot helm-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. Contribution Allowed If the contributor has signed the DCO or the CNCF CLA (prior to the move to a DCO). labels Oct 24, 2018
Signed-off-by: Gabriel de Maeztu <gabriel.maeztu@gmail.com>
@helm-bot helm-bot added Contribution Allowed If the contributor has signed the DCO or the CNCF CLA (prior to the move to a DCO). size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Oct 24, 2018
@helm-bot helm-bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. Contribution Allowed If the contributor has signed the DCO or the CNCF CLA (prior to the move to a DCO). labels Oct 24, 2018
@hbagdi
Copy link
Collaborator

hbagdi commented Oct 25, 2018

@cpanato @mattfarina @davidkarlsen Could you guys /ok-to-test?

@@ -10,5 +10,5 @@ maintainers:
name: kong
sources:
- https://github.com/Kong/kong
version: 0.5.0
version: 0.5.1
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's bump this up to 0.6.0 since there are other PRs on this charts which might cause conflicts and I want to minimize back and forth on this PR now.

| Parameter | Description | Default |
| ------------------------------ | -------------------------------------------------------------------------------- | ------------------- |
| image.repository | Kong image | `kong` |
| image.tag | Kong image version | `0.14.0` |
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we keep this to 0.14.1, I think this could came in here due to a rebase/merge from master.

kong run the following command:

```bash
helm install . \
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems like it's being used during development but end users shouldn't really need to do it.
Should it rather be helm install stable/kong?

@@ -97,7 +97,7 @@ livenessProbe:
path: "/status"
port: admin
scheme: HTTPS
initialDelaySeconds: 30
initialDelaySeconds: 180
Copy link
Collaborator

Choose a reason for hiding this comment

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

2 and 3 minutes are extremely high.
@shashiranjan84 has shown concern around this change in one of this past review.

@hbagdi
Copy link
Collaborator

hbagdi commented Oct 30, 2018

@merqurio Gentle nudge for this. We're at the last mile I believe!

@cpanato
Copy link
Member

cpanato commented Nov 1, 2018

@merqurio please rebase and also sign the DCO

@hbagdi
Copy link
Collaborator

hbagdi commented Nov 7, 2018

/hold
This has moved to #9020. Please close this PR.
Thank you for contributing this @merqurio. I'll be making some changes and merging it soon.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 7, 2018
@cpanato
Copy link
Member

cpanato commented Nov 8, 2018

/hold cancel
/close

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 8, 2018
@hbagdi
Copy link
Collaborator

hbagdi commented Nov 13, 2018

/close

1 similar comment
@hbagdi
Copy link
Collaborator

hbagdi commented Nov 13, 2018

/close

@unguiculus unguiculus closed this Nov 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

<Feature Request> Helm Chart for Kong Ingress Controller