From 3777eeb61249ac74d57603788b76055c52859da6 Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Wed, 8 Jul 2020 10:11:54 +0300 Subject: [PATCH] Add labels and annotation to minikube manifests Fixes: #10167 --- .../quarkus/kubernetes/deployment/KubernetesProcessor.java | 2 ++ .../kubernetes/MinikubeWithApplicationPropertiesTest.java | 6 ++++++ .../src/test/resources/minikube-with-application.properties | 2 ++ 3 files changed, 10 insertions(+) diff --git a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesProcessor.java b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesProcessor.java index 1520a1defdecc..77a9b92bd80b3 100644 --- a/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesProcessor.java +++ b/extensions/kubernetes/vanilla/deployment/src/main/java/io/quarkus/kubernetes/deployment/KubernetesProcessor.java @@ -184,6 +184,7 @@ public List createAnnotations(KubernetesConfig ku Optional metricsConfiguration, List kubernetesPorts) { List result = new ArrayList(); addAnnotations(kubernetesConfig, KUBERNETES, metricsConfiguration, kubernetesPorts, result); + addAnnotations(kubernetesConfig, MINIKUBE, metricsConfiguration, kubernetesPorts, result); addAnnotations(openshiftConfig, OPENSHIFT, metricsConfiguration, kubernetesPorts, result); addAnnotations(knativeConfig, KNATIVE, metricsConfiguration, kubernetesPorts, result); return result; @@ -211,6 +212,7 @@ public void createLabels(KubernetesConfig kubernetesConfig, OpenshiftConfig open BuildProducer containerImageLabelsProducer) { kubernetesConfig.labels.forEach((k, v) -> { kubernetesLabelsProducer.produce(new KubernetesLabelBuildItem(k, v, KUBERNETES)); + kubernetesLabelsProducer.produce(new KubernetesLabelBuildItem(k, v, MINIKUBE)); containerImageLabelsProducer.produce(new ContainerImageLabelBuildItem(k, v)); }); openshiftConfig.labels.forEach((k, v) -> { diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/MinikubeWithApplicationPropertiesTest.java b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/MinikubeWithApplicationPropertiesTest.java index 659f5e0100b54..be7eb8fe46878 100644 --- a/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/MinikubeWithApplicationPropertiesTest.java +++ b/integration-tests/kubernetes/quarkus-standard-way/src/test/java/io/quarkus/it/kubernetes/MinikubeWithApplicationPropertiesTest.java @@ -1,6 +1,7 @@ package io.quarkus.it.kubernetes; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.entry; import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.IOException; @@ -42,6 +43,11 @@ public void assertGeneratedResources() throws IOException { assertThat(kubernetesList).filteredOn(i -> "Deployment".equals(i.getKind())).hasOnlyOneElementSatisfying(i -> { assertThat(i).isInstanceOfSatisfying(Deployment.class, d -> { + assertThat(d.getMetadata()).satisfies(m -> { + assertThat(m.getName()).isEqualTo("minikube-with-application-properties"); + assertThat(m.getLabels()).contains(entry("foo", "bar")); + assertThat(m.getAnnotations()).contains(entry("bar", "baz")); + }); assertThat(d.getSpec()).satisfies(deploymentSpec -> { assertThat(deploymentSpec.getReplicas()).isEqualTo(1); diff --git a/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/minikube-with-application.properties b/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/minikube-with-application.properties index ff43ba42df0f6..3a5e14e2660a1 100644 --- a/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/minikube-with-application.properties +++ b/integration-tests/kubernetes/quarkus-standard-way/src/test/resources/minikube-with-application.properties @@ -1,3 +1,5 @@ quarkus.kubernetes.deployment-target=minikube quarkus.http.port=9090 quarkus.kubernetes.node-port=31999 +quarkus.kubernetes.labels.foo=bar +quarkus.kubernetes.annotations.bar=baz