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

Extract route/ingress configuration into a specific config group #13068

Merged
merged 1 commit into from
Mar 1, 2021

Conversation

glefloch
Copy link
Member

@glefloch glefloch commented Nov 2, 2020

This branch introduce a new config group for route/ingress specific configuration.

To configure a route, we can use the following configuration:

quarkus.openshift.route.expose=true
quarkus.openshift.route.host=example.com
quarkus.openshift.route.secure=true

For kubernetes, an ingress can be configured using the same config group, such as:

quarkus.kubernetes.ingress.expose=true
quarkus.kubernetes.ingress.host=example.com
quarkus.kubernetes.ingress.secure=true

This will add the same dekorate properties as before.
The only feature in this branch is the secure property which is enable by default and add the following annotation:

kubernetes.io/tls-acme: true    

close #12630

@glefloch glefloch requested review from geoand, iocanel and gsmet and removed request for geoand November 2, 2020 15:52
@glefloch
Copy link
Member Author

glefloch commented Nov 2, 2020

If everything is ok, I will push a migration note in the wiki

@geoand
Copy link
Contributor

geoand commented Nov 2, 2020

Very nice, thanks!

@iocanel do you want to take a look?

@gsmet this probably interests you as well

* If true, TLS will be enabled on the exposed service
*/
@ConfigItem(defaultValue = "true")
boolean secure;
Copy link
Member

Choose a reason for hiding this comment

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

Any chance we could handle the annotations added to the route while we're at it?

At the moment, I added them globally but I think it makes sense to be able to define annotations specific to the route?

Note that I'm not an OpenShift expert so better check with @geoand and @iocanel if it makes sense :).

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you remind me again what annotation you needed on the Route?

Copy link
Member Author

Choose a reason for hiding this comment

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

Looking at dekorate, I'm not sure we can configure annotation for a specific type of object. But may be wrong.
I added the kubernetes.io/tls-acme annotation to enable tls. But as mentionned by @gsmet in an other comment, enabling tls may have more consequences than just adding an annotation (like certificate, key, ...)

Copy link
Member

Choose a reason for hiding this comment

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

So I needed an annotation for defining the secure route so it's mostly covered now :).

Copy link
Contributor

Choose a reason for hiding this comment

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

It does make sense!
And dekorate does support adding Labels and Annotations to specific resource types. See: dekorateio/dekorate#644

expositionConfig.host.ifPresent(
host -> unPrefixed.put(DEKORATE_PREFIX + platformConfiguration.getTargetPlatformName() + ".host",
host));
if (expositionConfig.secure) {
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't have more consequences? Asking that because it's a specific checkbox in the UI.

Copy link
Member

Choose a reason for hiding this comment

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

Asking because I remember trying to define the annotation afterwards and things didn't work and George recreated the route entirely and it worked. So I wonder if secure is more than just that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes that's possible. There is not much about tls in dekorate neither, maybe that would be a good use case. WDYT @iocanel?

Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIR, the particular file is meant to be used to provide support for the old style configuration. So, I think that we can entirely ignore that for this pull request. In fact, I think we have it long enough that we should probably get rid of it soon.

@@ -92,6 +92,8 @@

/**
* The host under which the application is going to be exposed
*
* @deprecated Use the {@code quarkus.kubernetes.ingress.host} instead
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we should try to add an automated warning when using deprecated configuration. Similar to the one we have for unused properties.

IMO, that's food for thoughts for later improvements but as for this PR is concerned, I wonder if we should at least add a warning when using these old configurations properties? Wondering also if we should handle the case when there is a conflict? I think the new ones should be prioritized but we should probably have a warning too.

Copy link
Member Author

Choose a reason for hiding this comment

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

I updated the code such as, the old properties are read only if new ones are not set. and in that case, there is a warning.

Copy link
Contributor

@iocanel iocanel left a comment

Choose a reason for hiding this comment

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

If I understand things correctly the pull requests, implements the feature via the KubernetsConfigUtil. This utility is mostly used to for backwards compatibility reasons and is likely to be removed in the future.

The recommended approach to functionality like this is by using:

  • KubernetesProcessor
  • OpenshiftProcessor

and provide the necessary Configuratiors and Decroators.

For example: I would use a Configurator to set the expose and host and possibly the labels.

If the difference between configurators and decorators is not obvious. The former modifies the Configuration object we pass to decroate. The latter acts directly on the generated resources.

@@ -611,7 +610,9 @@ The table below describe all the available configuration options.
| quarkus.kubernetes.liveness-probe | Probe | | ( see Probe )
| quarkus.kubernetes.readiness-probe | Probe | | ( see Probe )
| quarkus.kubernetes.sidecars | Map<String, Container> | |
| quarkus.kubernetes.expose | boolean | | false
Copy link
Contributor

Choose a reason for hiding this comment

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

We might want to keep this around for backwards compatibility reasons.
Don't have a very strong opinion about it. It`s what we use to do in related cases.

Copy link
Contributor

Choose a reason for hiding this comment

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

Never mind, just noticed that its only removed from the documentation.

* If true, TLS will be enabled on the exposed service
*/
@ConfigItem(defaultValue = "true")
boolean secure;
Copy link
Contributor

Choose a reason for hiding this comment

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

It does make sense!
And dekorate does support adding Labels and Annotations to specific resource types. See: dekorateio/dekorate#644

expositionConfig.host.ifPresent(
host -> unPrefixed.put(DEKORATE_PREFIX + platformConfiguration.getTargetPlatformName() + ".host",
host));
if (expositionConfig.secure) {
Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIR, the particular file is meant to be used to provide support for the old style configuration. So, I think that we can entirely ignore that for this pull request. In fact, I think we have it long enough that we should probably get rid of it soon.

for (String generator : EXPOSABLE_GENERATORS) {
boolean unprefixedExpose = config.getOptionalValue(generator + "." + EXPOSE_PROPERTY_NAME, Boolean.class)
.orElse(false);
boolean prefixedExpose = config
.getOptionalValue(QUARKUS_PREFIX + generator + "." + EXPOSE_PROPERTY_NAME, Boolean.class)
.orElse(false);
if (unprefixedExpose || prefixedExpose) {
if (generator == KUBERNETES) {
log.warn("Usage of quarkus.kubernetes.expose is deprecated in favor of quarkus.kubernetes.ingress.expose");
Copy link
Contributor

Choose a reason for hiding this comment

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

+1

@glefloch
Copy link
Member Author

Thanks for your review @iocanel, I will update the code.

@glefloch
Copy link
Member Author

@iocanel I pushed a new version of the code. As you suggested, I implemented a custom Configurator to handle the expose and host.
And I used a decorator to handle route/ingress specific annotation.

@glefloch glefloch force-pushed the fix/12630 branch 3 times, most recently from 6caecc2 to f787595 Compare November 16, 2020 13:54
@glefloch
Copy link
Member Author

@iocanel could you review the new version of the code?

@glefloch
Copy link
Member Author

@iocanel I just fixed conflicts, could you have a look ?

@geoand
Copy link
Contributor

geoand commented Feb 26, 2021

I would like to have this fixed.

@glefloch can you rebase please so @iocanel can take another look?

Thanks

@glefloch
Copy link
Member Author

Yes for sure @geoand. It should be good now :)

@geoand
Copy link
Contributor

geoand commented Feb 26, 2021

Thanks!

@geoand geoand requested a review from iocanel February 26, 2021 11:17
Copy link
Contributor

@iocanel iocanel left a comment

Choose a reason for hiding this comment

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

LGTM

import static io.quarkus.kubernetes.deployment.Constants.QUARKUS_ANNOTATIONS_BUILD_TIMESTAMP;
import static io.quarkus.kubernetes.deployment.Constants.QUARKUS_ANNOTATIONS_COMMIT_ID;
import static io.quarkus.kubernetes.deployment.Constants.QUARKUS_ANNOTATIONS_VCS_URL;
import static io.quarkus.kubernetes.deployment.Constants.*;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have the star imports removed please?

Copy link
Member Author

@glefloch glefloch Feb 26, 2021

Choose a reason for hiding this comment

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

yes, and I reconfigured my IDE so that should not happen again.

Copy link
Contributor

Choose a reason for hiding this comment

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

Excellent, thanks 👍

@geoand geoand added the triage/waiting-for-ci Ready to merge when CI successfully finishes label Feb 26, 2021
@glefloch
Copy link
Member Author

glefloch commented Mar 1, 2021

@geoand should we merge this ?

@geoand
Copy link
Contributor

geoand commented Mar 1, 2021

Absolutely!

@geoand geoand merged commit db322d5 into quarkusio:master Mar 1, 2021
@quarkus-bot quarkus-bot bot added this to the 1.13 - master milestone Mar 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/documentation area/kubernetes triage/waiting-for-ci Ready to merge when CI successfully finishes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve OpenShift route configuration
4 participants