-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Conversation
If everything is ok, I will push a migration note in the wiki |
* If true, TLS will be enabled on the exposed service | ||
*/ | ||
@ConfigItem(defaultValue = "true") | ||
boolean secure; |
There was a problem hiding this comment.
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 :).
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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, ...)
There was a problem hiding this comment.
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 :).
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
Thanks for your review @iocanel, I will update the code. |
@iocanel I pushed a new version of the code. As you suggested, I implemented a custom |
6caecc2
to
f787595
Compare
@iocanel could you review the new version of the code? |
@iocanel I just fixed conflicts, could you have a look ? |
Yes for sure @geoand. It should be good now :) |
Thanks! |
There was a problem hiding this 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.*; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent, thanks 👍
@geoand should we merge this ? |
Absolutely! |
This branch introduce a new config group for route/ingress specific configuration.
To configure a route, we can use the following configuration:
For kubernetes, an ingress can be configured using the same config group, such as:
This will add the same
dekorate
properties as before.The only
feature
in this branch is thesecure
property which is enable by default and add the following annotation:close #12630