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

feat: Support Ingress Class Annotation in Argo CD CRD #636

Merged
merged 7 commits into from Jul 21, 2022

Conversation

sagikazarmark
Copy link
Contributor

@sagikazarmark sagikazarmark commented May 5, 2022

What type of PR is this?
/kind enhancement

What does this PR do / why we need it:
This PR adds IngressClass support to Ingress resources.

Have you updated the necessary documentation?

  • Documentation update is required by this PR.
  • Documentation has been updated.

Which issue(s) this PR fixes:

Fixes #626

How to test changes / Special notes to the reviewer:

Relevant tests can be run by the following command:

go test -v -run 'TestReconcileArgoCD_reconcile_.*Ingress_ingressClassName' ./controllers/argocd/

Change can be tested by setting up a dev environment and applying the following manifest:

apiVersion: argoproj.io/v1alpha1
kind: ArgoCD
metadata:
  name: example-argocd
  labels:
    example: ingress
spec:
  server:
    grpc:
      ingress:
        enabled: true
    ingress:
      enabled: true
      ingressClassName: nginx
    insecure: true

Note: As discussed in #626, this PR contains a breaking change: kubernetes.io/ingress.class annotation is no longer added and nginx is no longer the default ingress controller (Kubernetes will fall back to the default ingress class)

Default nginx annotations (SSL redirect, backend) are still added though.

Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
@CLAassistant
Copy link

CLAassistant commented May 5, 2022

CLA assistant check
All committers have signed the CLA.

@sagikazarmark sagikazarmark force-pushed the ingress-class branch 2 times, most recently from 300a423 to f4c4772 Compare May 5, 2022 10:23
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
This change also disables the old
`kubernetes.io/ingress.class` annotation added to
ingress resources by default.

Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
Signed-off-by: Mark Sagi-Kazar <mark.sagikazar@gmail.com>
@iam-veeramalla iam-veeramalla changed the title Ingress class Feat: Support Ingress Class Annotation in Argo CD CRD May 10, 2022
@iam-veeramalla iam-veeramalla changed the title Feat: Support Ingress Class Annotation in Argo CD CRD feat: Support Ingress Class Annotation in Argo CD CRD May 10, 2022
@iam-veeramalla
Copy link
Collaborator

@sagikazarmark , I was trying to test this changes on my minikube cluster which has the following IngressClass resource

apiVersion: networking.k8s.io/v1
kind: IngressClass
metadata:
  annotations:
    ingressclass.kubernetes.io/is-default-class: "true"

What I noticed is the IngressClass is always set to nginx. In a nutshell, .spec.server.ingress.ingressClassName is not respected.

@sagikazarmark
Copy link
Contributor Author

@iam-veeramalla Can you clarify what is always set to nginx means? Is it actually set to nginx? Or does it fallback to the above default (which is nginx)?

Do you have any other ingress classes defined in the cluster?

I tested it in a kind cluster with grpc and server ingress with grpc left empty (falling back to the default) and the server explicitly set to nginx. Both showed up with the correct ingress class (grpc: null, server: nginx).

@iam-veeramalla
Copy link
Collaborator

e any other ingress classes defined in the cluster?

Hi @sagikazarmark , I just have one IngressClass defined in the cluster and that is set to default -> "nginx".

I created an Argo CD instance with .spec.server.ingress.ingressClass: fake. Up on the reconciliation I see that the Ingress resource created for Argo CD server has IngressClass set to nginx, which I believe should be fake.

However, I can try it one more time on my Kind cluster.

@sagikazarmark
Copy link
Contributor Author

Just to clarify: the new field is called ingressClassName, not ingressClass.

I don't know how Kubernetes behaves if you specify a non-existent ingress class in the ingress resource, but falling back to the default one doesn't sound necessarily bad. Try to create an ingress class resource with that name.

I'll do some additional testing as well.

@iam-veeramalla
Copy link
Collaborator

Just to clarify: the new field is called ingressClassName, not ingressClass.

I don't know how Kubernetes behaves if you specify a non-existent ingress class in the ingress resource, but falling back to the default one doesn't sound necessarily bad. Try to create an ingress class resource with that name.

I'll do some additional testing as well.

Yeah ingressClassName.

Thank you !! I will do some additional testing as well !!

@sagikazarmark
Copy link
Contributor Author

@iam-veeramalla any updates?

@iam-veeramalla
Copy link
Collaborator

HI @sagikazarmark , Sorry I reviewed this and also tested before I went to vacation, Just forgot to merge it. I can confirm that this works :)

@iam-veeramalla iam-veeramalla self-requested a review July 21, 2022 12:04
Copy link
Collaborator

@iam-veeramalla iam-veeramalla left a comment

Choose a reason for hiding this comment

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

LGTM, Thanks :)

@iam-veeramalla iam-veeramalla merged commit 1927ddd into argoproj-labs:master Jul 21, 2022
@sagikazarmark sagikazarmark deleted the ingress-class branch July 21, 2022 17:08
@sagikazarmark
Copy link
Contributor Author

Awesome, thanks!

Copy link
Collaborator

@wtam2018 wtam2018 left a comment

Choose a reason for hiding this comment

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

@sagikazarmark @iam-veeramalla
I see the annotation kubernetes.io/ingress.class has been removed but the constant is still there in the code.
Any there any impact to upgrade by this change? That is, folks who may depend on this annotation. The default ingress class is empty. So, will this change break use cases which uses the old default annotation?

@iam-veeramalla
Copy link
Collaborator

iam-veeramalla commented Jul 25, 2022

ss is em

Hi @wtam2018 the old annotation cannot be used in anyways as the annotation is deprecated. This will be a breaking change as mentioned by @sagikazarmark in the comment
#626 (comment)

@wtam2018
Copy link
Collaborator

Well, introducing a break change for an enhancement without any mitigation does not seem to make too much sense. Let's hope no users are depending the old behavior. BTW, deprecation means can still be used.

@sagikazarmark
Copy link
Contributor Author

@sagikazarmark @iam-veeramalla I see the annotation kubernetes.io/ingress.class has been removed but the constant is still there in the code.

Correct, the annotation could be removed if nothing else uses it.

So, will this change break use cases which uses the old default annotation?

It depends: it might break on unsupported Kubernetes version or with old ingress controllers.

This PR changes a default that didn't really make sense in the first place (defaulting to an ingress class called "nginx" that may or may not exist in the first place).

The new default uses the new ingress class types and defaults to the default ingress controller.

To sum up: it may break in some edge cases, but the default makes more sense now and supports more setups, so I'd say it's an improvement even if it breaks in some cases.

@wtam2018
Copy link
Collaborator

Please push a PR to remove the unused constant. Please add doc about the removal of the annotation and the migration instructions for those who are upgrading with those use/edge cases. @iam-veeramalla

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.

Add ingressClassName to ArgoCDIngressSpec
4 participants