Skip to content

Commit

Permalink
Merge pull request quarkusio#24960 from gsmet/2.8.1-backports-2
Browse files Browse the repository at this point in the history
2.8.1 backports 2
  • Loading branch information
gsmet authored Apr 15, 2022
2 parents 4681627 + 51d279e commit 030c699
Show file tree
Hide file tree
Showing 34 changed files with 565 additions and 85 deletions.
10 changes: 5 additions & 5 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@
<commons-lang3.version>3.12.0</commons-lang3.version>
<commons-codec.version>1.15</commons-codec.version>
<classmate.version>1.5.1</classmate.version>
<hibernate-orm.version>5.6.7.Final</hibernate-orm.version> <!-- When updating, align bytebuddy.version to Hibernate needs as well (just below): -->
<bytebuddy.version>1.12.8</bytebuddy.version> <!-- Version controlled by Hibernate ORM's needs -->
<hibernate-orm.version>5.6.8.Final</hibernate-orm.version> <!-- When updating, align bytebuddy.version to Hibernate needs as well (just below): -->
<bytebuddy.version>1.12.9</bytebuddy.version> <!-- Version controlled by Hibernate ORM's needs -->
<hibernate-reactive.version>1.1.4.Final</hibernate-reactive.version>
<hibernate-validator.version>6.2.3.Final</hibernate-validator.version>
<hibernate-search.version>6.1.3.Final</hibernate-search.version>
Expand Down Expand Up @@ -153,7 +153,7 @@
<kotlin.version>1.6.10</kotlin.version>
<kotlin.coroutine.version>1.6.0</kotlin.coroutine.version>
<kotlin-serialization.version>1.3.2</kotlin-serialization.version>
<dekorate.version>2.9.0</dekorate.version>
<dekorate.version>2.9.2</dekorate.version>
<maven-invoker.version>3.1.0</maven-invoker.version>
<awaitility.version>4.2.0</awaitility.version>
<jboss-logmanager.version>1.0.9</jboss-logmanager.version>
Expand Down Expand Up @@ -195,8 +195,8 @@
<apicurio-registry.version>2.2.1.Final</apicurio-registry.version>
<apicurio-common-rest-client.version>0.1.7.Final</apicurio-common-rest-client.version> <!-- must be the version Apicurio Registry uses -->
<jacoco.version>0.8.7</jacoco.version>
<testcontainers.version>1.16.3</testcontainers.version> <!-- Make sure to also update docker-java.version to match its needs -->
<docker-java.version>3.2.12</docker-java.version> <!-- must be the version Testcontainers use -->
<testcontainers.version>1.17.1</testcontainers.version> <!-- Make sure to also update docker-java.version to match its needs -->
<docker-java.version>3.2.13</docker-java.version> <!-- must be the version Testcontainers use -->
<aesh-readline.version>2.2</aesh-readline.version>
<aesh.version>2.6</aesh.version>
<!-- these two artifacts needs to be compatible together -->
Expand Down
1 change: 0 additions & 1 deletion devtools/cli/distribution/jreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ distributions:
executable:
name: quarkus
windowsExtension: bat
executableExtension: bat
tags:
- quarkus
- cli
Expand Down
2 changes: 1 addition & 1 deletion devtools/cli/distribution/release-cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export JRELEASER_PROJECT_VERSION=${VERSION}
export JRELEASER_BRANCH=${BRANCH}
export JRELEASER_CHOCOLATEY_GITHUB_BRANCH=${BRANCH}

jbang org.jreleaser:jreleaser:1.0.0-M3 full-release \
jbang org.jreleaser:jreleaser:1.0.0 full-release \
--git-root-search \
-od target

Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/asciidoc/building-my-first-extension.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ mvn io.quarkus.platform:quarkus-maven-plugin:{quarkus-version}:create \
-DprojectGroupId=org.acme \
-DprojectArtifactId=greeting-app \
-Dextensions="org.acme:greeting-extension:1.0.0-SNAPSHOT" \
-DnoExamples
-DnoCode
----

`cd` into `greeting-app`.
Expand Down
97 changes: 97 additions & 0 deletions docs/src/main/asciidoc/kafka.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2401,6 +2401,103 @@ quarkus.log.category."org.apache.kafka.common.utils".level=INFO
quarkus.log.category."org.apache.kafka.common.metrics".level=INFO
----

== Connecting to Managed Kafka clusters

This section explains how to connect to notorious Kafka Cloud Services.

=== Azure Event Hub

https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-for-kafka-ecosystem-overview[Azure Event Hub] provides an endpoint compatible with Apache Kafka.

NOTE: Azure Event Hubs for Kafka is not available in the _basic_ tier.
You need at least the _standard_ tier to use Kafka.
See https://azure.microsoft.com/en-us/pricing/details/event-hubs/[Azure Event Hubs Pricing] to see the other options.

To connect to Azure Event Hub, using the Kafka protocol with TLS, you need the following configuration:

[source, properties]
----
kafka.bootstrap.servers=my-event-hub.servicebus.windows.net:9093 # <1>
kafka.security.protocol=SASL_SSL
kafka.sasl.mechanism=PLAIN
kafka.sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required \ # <2>
username="$ConnectionString" \ # <3>
password="<YOUR.EVENTHUBS.CONNECTION.STRING>"; # <4>
----
<1> The port is `9093`.
<2> You need to use the JAAS `PlainLoginModule`.
<3> The username is the `$ConnectionString` string.
<4> The Event Hub connection string given by Azure.

Replace `<YOUR.EVENTHUBS.CONNECTION.STRING>` with the connection string for your Event Hubs namespace.
For instructions on getting the connection string, see https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-get-connection-string[Get an Event Hubs connection string].
The result would be something like:

[source, properties]
----
kafka.sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required \
username="$ConnectionString" \
password="Endpoint=sb://my-event-hub.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=XXXXXXXXXXXXXXXX";
----

This configuration can be global (as above), or set in the channel configuration:

[source, properties]
----
mp.messaging.incoming.$channel.bootstrap.servers=my-event-hub.servicebus.windows.net:9093
mp.messaging.incoming.$channel.security.protocol=SASL_SSL
mp.messaging.incoming.$channel.sasl.mechanism=PLAIN
mp.messaging.incoming.$channel.sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required \
username="$ConnectionString" \
password="Endpoint=sb://my-event-hub.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=...";
----

=== Red Hat OpenShift Streams for Apache Kafka

https://cloud.redhat.com/[Red Hat OpenShift Streams for Apache Kafka] provides managed Kafka brokers.
First, follow the instructions from https://access.redhat.com/documentation/en-us/red_hat_openshift_streams_for_apache_kafka/1/guide/88e1487a-2a14-4b35-85b9-a7a2d67a37f3[Getting started with the `rhoas` CLI for Red Hat OpenShift Streams for Apache Kafka] to create your Kafka broker instance.
Make sure you copied the client id and client secret associated with the _ServiceAccount_ you created.

Then, you can configure the Quarkus application to connect to the broker as follows:

[source, properties]
----
kafka.bootstrap.servers=<connection url> # <1>
kafka.security.protocol=SASL_SSL
kafka.sasl.mechanism=PLAIN
kafka.sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required \
username="${KAFKA_USERNAME}" \ # <2>
password="${KAFKA_PASSWORD}"; # <3>
----
<1> The connection string, given on the admin console, such as `demo-c--bjsv-ldd-cvavkc-a.bf2.kafka.rhcloud.com:443`
<2> The kafka username (the client id from the service account)
<3> the kafka password (the client secret from the service account)

NOTE: In general, these properties are prefixed using `%prod` to enable them only when running in production mode.

IMPORTANT: As explained in https://access.redhat.com/documentation/en-us/red_hat_openshift_streams_for_apache_kafka/1/guide/88e1487a-2a14-4b35-85b9-a7a2d67a37f3[Getting started with the rhoas CLI for Red Hat OpenShift Streams for Apache Kafka], to use Red Hat OpenShift Streams for Apache Kafka, you must create the topic beforehand, create a _Service Account_, and provide permissions to read and write to your topic from that service account.
The authentication data (client id and secret) relates to the service account, which means you can implement fine-grain permissions and restrict access to the topic.

When using Kubernetes, it is recommended to set the client id and secret in a Kubernetes secret:

[source, yaml]
----
apiVersion: v1
kind: Secret
metadata:
name: kafka-credentials
stringData:
KAFKA_USERNAME: "..."
KAFKA_PASSWORD: "..."
----

To allow your Quarkus application to use that secret, add the following line to the `application.properties` file:

[source, properties]
----
%prod.quarkus.openshift.env.secrets=kafka-credentials
----

== Going further

This guide has shown how you can interact with Kafka using Quarkus.
Expand Down
4 changes: 2 additions & 2 deletions docs/src/main/asciidoc/rest-client.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ public class WireMockExtensions implements QuarkusTestResourceLifecycleManager {
wireMockServer = new WireMockServer();
wireMockServer.start(); // <3>
stubFor(get(urlEqualTo("/extensions?id=io.quarkus:quarkus-rest-client")) // <4>
wireMockServer.stubFor(get(urlEqualTo("/extensions?id=io.quarkus:quarkus-rest-client")) // <4>
.willReturn(aResponse()
.withHeader("Content-Type", "application/json")
.withBody(
Expand All @@ -695,7 +695,7 @@ public class WireMockExtensions implements QuarkusTestResourceLifecycleManager {
"}]"
)));
stubFor(get(urlMatching(".*")).atPriority(10).willReturn(aResponse().proxiedFrom("https://stage.code.quarkus.io/api"))); // <5>
wireMockServer.stubFor(get(urlMatching(".*")).atPriority(10).willReturn(aResponse().proxiedFrom("https://stage.code.quarkus.io/api"))); // <5>
return Collections.singletonMap("quarkus.rest-client.\"org.acme.rest.client.ExtensionsService\".url", wireMockServer.baseUrl()); // <6>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static AzureDiskVolume convert(Map.Entry<String, AzureDiskVolumeConfig> e

private static AzureDiskVolumeBuilder convert(AzureDiskVolumeConfig c) {
AzureDiskVolumeBuilder b = new AzureDiskVolumeBuilder();
b.withNewDiskName(c.diskName);
b.withDiskName(c.diskName);
b.withDiskURI(c.diskURI);
b.withKind(c.kind.name());
b.withCachingMode(c.cachingMode.name());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@
import io.dekorate.knative.decorator.ApplyGlobalTargetUtilizationDecorator;
import io.dekorate.knative.decorator.ApplyLocalContainerConcurrencyDecorator;
import io.dekorate.knative.decorator.ApplyRevisionNameDecorator;
import io.dekorate.knative.decorator.ApplyServiceAccountToRevisionSpecDecorator;
import io.dekorate.knative.decorator.ApplyTrafficDecorator;
import io.dekorate.kubernetes.config.EnvBuilder;
import io.dekorate.kubernetes.decorator.AddConfigMapDataDecorator;
import io.dekorate.kubernetes.decorator.AddEnvVarDecorator;
import io.dekorate.kubernetes.decorator.AddImagePullSecretToServiceAccountDecorator;
import io.dekorate.kubernetes.decorator.AddLabelDecorator;
import io.dekorate.kubernetes.decorator.AddServiceAccountResourceDecorator;
import io.dekorate.kubernetes.decorator.ApplicationContainerDecorator;
import io.dekorate.project.Project;
import io.quarkus.container.spi.BaseImageInfoBuildItem;
Expand Down Expand Up @@ -136,17 +139,20 @@ public List<DecoratorBuildItem> createDecorators(ApplicationInfoBuildItem applic
Optional<KubernetesHealthReadinessPathBuildItem> readinessPath,
List<KubernetesRoleBuildItem> roles,
List<KubernetesRoleBindingBuildItem> roleBindings,
Optional<CustomProjectRootBuildItem> customProjectRoot) {
Optional<CustomProjectRootBuildItem> customProjectRoot,
List<KubernetesDeploymentTargetBuildItem> targets) {

List<DecoratorBuildItem> result = new ArrayList<>();
String name = ResourceNameUtil.getResourceName(config, applicationInfo);
if (!targets.stream().filter(KubernetesDeploymentTargetBuildItem::isEnabled)
.anyMatch(t -> KNATIVE.equals(t.getName()))) {
return result;
}

String name = ResourceNameUtil.getResourceName(config, applicationInfo);
Optional<Project> project = KubernetesCommonHelper.createProject(applicationInfo, customProjectRoot, outputTarget,
packageConfig);
result.addAll(KubernetesCommonHelper.createDecorators(project, KNATIVE, name, config,
metricsConfiguration, annotations,
labels, command,
ports, livenessPath, readinessPath, roles, roleBindings));
result.addAll(KubernetesCommonHelper.createDecorators(project, KNATIVE, name, config, metricsConfiguration, annotations,
labels, command, ports, livenessPath, readinessPath, roles, roleBindings));

image.ifPresent(i -> {
result.add(new DecoratorBuildItem(KNATIVE, new ApplyContainerImageDecorator(name, i.getImage())));
Expand Down Expand Up @@ -294,6 +300,16 @@ public List<DecoratorBuildItem> createDecorators(ApplicationInfoBuildItem applic
result.add(new DecoratorBuildItem(new ApplyServiceAccountNameToRevisionSpecDecorator()));
}

//Handle Image Pull Secrets
config.getImagePullSecrets().ifPresent(imagePullSecrets -> {
String serviceAccountName = config.getServiceAccount().orElse(name);
result.add(new DecoratorBuildItem(KNATIVE, new AddServiceAccountResourceDecorator(name)));
result.add(
new DecoratorBuildItem(KNATIVE, new ApplyServiceAccountToRevisionSpecDecorator(name, serviceAccountName)));
result.add(new DecoratorBuildItem(KNATIVE,
new AddImagePullSecretToServiceAccountDecorator(serviceAccountName, imagePullSecrets)));
});

return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,16 @@ public static List<DecoratorBuildItem> createDecorators(Optional<Project> projec

//Handle RBAC
if (!roleBindings.isEmpty()) {
result.add(new DecoratorBuildItem(new ApplyServiceAccountNameDecorator()));
result.add(new DecoratorBuildItem(new AddServiceAccountResourceDecorator()));
roles.forEach(r -> result.add(new DecoratorBuildItem(new AddRoleResourceDecorator(name, r))));
result.add(new DecoratorBuildItem(target, new ApplyServiceAccountNameDecorator()));
result.add(new DecoratorBuildItem(target, new AddServiceAccountResourceDecorator()));
roles.forEach(r -> result.add(new DecoratorBuildItem(target, new AddRoleResourceDecorator(name, r))));
roleBindings.forEach(rb -> {
result.add(new DecoratorBuildItem(new AddRoleBindingResourceDecorator(rb.getName(), null, rb.getRole(),
rb.isClusterWide() ? AddRoleBindingResourceDecorator.RoleKind.ClusterRole
: AddRoleBindingResourceDecorator.RoleKind.Role)));
result.add(new DecoratorBuildItem(target,
new AddRoleBindingResourceDecorator(rb.getName(), null, rb.getRole(),
rb.isClusterWide() ? AddRoleBindingResourceDecorator.RoleKind.ClusterRole
: AddRoleBindingResourceDecorator.RoleKind.Role)));
labels.forEach(l -> {
result.add(new DecoratorBuildItem(
result.add(new DecoratorBuildItem(target,
new AddLabelDecorator(rb.getName(), l.getKey(), l.getValue(), "RoleBinding")));
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import io.dekorate.kubernetes.decorator.AddServiceResourceDecorator;
import io.dekorate.kubernetes.decorator.ApplyHeadlessDecorator;
import io.dekorate.kubernetes.decorator.ApplyImageDecorator;
import io.dekorate.kubernetes.decorator.ApplyReplicasDecorator;
import io.dekorate.kubernetes.decorator.ApplyReplicasToDeploymentDecorator;
import io.dekorate.project.ApplyProjectInfo;
import io.dekorate.project.Project;
import io.dekorate.utils.Images;
Expand All @@ -48,11 +48,8 @@ public class MinikubeManifestGenerator extends AbstractKubernetesManifestGenerat
private static final String METADATA_NAMESPACE = "metadata.namespace";
private static final String MINIKUBE = "minikube";

private final ConfigurationRegistry configurationRegistry;

public MinikubeManifestGenerator(ResourceRegistry resourceRegistry, ConfigurationRegistry configurationRegistry) {
super(resourceRegistry);
this.configurationRegistry = configurationRegistry;
super(resourceRegistry, configurationRegistry);
}

@Override
Expand Down Expand Up @@ -86,7 +83,9 @@ public void generate(KubernetesConfig config) {
}

if (config.getReplicas() != 1) {
resourceRegistry.decorate(MINIKUBE, new ApplyReplicasDecorator(config.getName(), config.getReplicas()));
resourceRegistry.decorate(MINIKUBE, new ApplyReplicasToDeploymentDecorator(config.getName(), config.getReplicas()));
resourceRegistry.decorate(MINIKUBE,
new ApplyReplicasToStatefulSetDecorator(config.getName(), config.getReplicas()));
}

String image = Strings.isNotNullOrEmpty(imageConfig.getImage())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import io.dekorate.kubernetes.decorator.ApplyImagePullPolicyDecorator;
import io.dekorate.kubernetes.decorator.RemoveFromSelectorDecorator;
import io.dekorate.kubernetes.decorator.RemoveLabelDecorator;
import io.dekorate.openshift.decorator.ApplyReplicasDecorator;
import io.dekorate.openshift.decorator.ApplyReplicasToDeploymentConfigDecorator;
import io.dekorate.project.Project;
import io.dekorate.s2i.config.S2iBuildConfig;
import io.dekorate.s2i.config.S2iBuildConfigBuilder;
Expand Down Expand Up @@ -175,9 +175,15 @@ public List<DecoratorBuildItem> createDecorators(ApplicationInfoBuildItem applic
Optional<KubernetesHealthReadinessPathBuildItem> readinessPath,
List<KubernetesRoleBuildItem> roles,
List<KubernetesRoleBindingBuildItem> roleBindings,
Optional<CustomProjectRootBuildItem> customProjectRoot) {
Optional<CustomProjectRootBuildItem> customProjectRoot,
List<KubernetesDeploymentTargetBuildItem> targets) {

List<DecoratorBuildItem> result = new ArrayList<>();
if (!targets.stream().filter(KubernetesDeploymentTargetBuildItem::isEnabled)
.anyMatch(t -> OPENSHIFT.equals(t.getName()))) {
return result;
}

String name = ResourceNameUtil.getResourceName(config, applicationInfo);

Optional<Project> project = KubernetesCommonHelper.createProject(applicationInfo, customProjectRoot, outputTarget,
Expand Down Expand Up @@ -215,10 +221,11 @@ public List<DecoratorBuildItem> createDecorators(ApplicationInfoBuildItem applic

if (config.getReplicas() != 1) {
// This only affects DeploymentConfig
result.add(new DecoratorBuildItem(OPENSHIFT, new ApplyReplicasDecorator(name, config.getReplicas())));
result.add(new DecoratorBuildItem(OPENSHIFT,
new ApplyReplicasToDeploymentConfigDecorator(name, config.getReplicas())));
// This only affects Deployment
result.add(new DecoratorBuildItem(OPENSHIFT,
new io.dekorate.kubernetes.decorator.ApplyReplicasDecorator(name, config.getReplicas())));
new io.dekorate.kubernetes.decorator.ApplyReplicasToDeploymentDecorator(name, config.getReplicas())));
// This only affects StatefulSet
result.add(new DecoratorBuildItem(OPENSHIFT, new ApplyReplicasToStatefulSetDecorator(name, config.getReplicas())));
}
Expand Down
Loading

0 comments on commit 030c699

Please sign in to comment.