Skip to content

Commit

Permalink
Introduce app.kubernetes.io/managed-by label to k8s manifest generation
Browse files Browse the repository at this point in the history
  • Loading branch information
geoand committed Jan 24, 2023
1 parent d0658da commit 3f3e0c8
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public void createLabels(KubernetesConfig config, BuildProducer<KubernetesLabelB
labels.produce(new KubernetesLabelBuildItem(k, v, KIND));
imageLabels.produce(new ContainerImageLabelBuildItem(k, v));
});
labels.produce(new KubernetesLabelBuildItem(KubernetesLabelBuildItem.CommonLabels.MANAGED_BY, "quarkus", KIND));
}

@BuildStep
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ public String getValue() {
public String getTarget() {
return this.target;
}

public static class CommonLabels {

public static final String MANAGED_BY = "app.kubernetes.io/managed-by";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public void createLabels(OpenshiftConfig config, BuildProducer<KubernetesLabelBu
labels.produce(new KubernetesLabelBuildItem(k, v, OPENSHIFT));
imageLabels.produce(new ContainerImageLabelBuildItem(k, v));
});
labels.produce(new KubernetesLabelBuildItem(KubernetesLabelBuildItem.CommonLabels.MANAGED_BY, "quarkus", OPENSHIFT));
}

@BuildStep
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public void createLabels(KubernetesConfig config, BuildProducer<KubernetesLabelB
labels.produce(new KubernetesLabelBuildItem(k, v, KUBERNETES));
imageLabels.produce(new ContainerImageLabelBuildItem(k, v));
});
labels.produce(new KubernetesLabelBuildItem(KubernetesLabelBuildItem.CommonLabels.MANAGED_BY, "quarkus", KUBERNETES));
}

@BuildStep
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public void assertGeneratedResources() throws IOException {
assertThat(d.getSpec()).satisfies(deploymentSpec -> {
assertThat(deploymentSpec.getSelector()).isNotNull().satisfies(labelSelector -> {
assertThat(labelSelector.getMatchLabels()).containsOnly(entry("app.kubernetes.io/name", "basic"),
entry("app.kubernetes.io/version", "0.1-SNAPSHOT"));
entry("app.kubernetes.io/version", "0.1-SNAPSHOT"),
entry("app.kubernetes.io/managed-by", "quarkus"));
});

assertThat(deploymentSpec.getTemplate()).satisfies(t -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void assertGeneratedResources() throws IOException {
// spec assertions
assertThat(deployment.getSpec().getReplicas()).isEqualTo(1);
assertThat(deployment.getSpec().getSelector()).containsOnly(entry("app.kubernetes.io/name", "basic-openshift"),
entry("app.kubernetes.io/version", "0.1-SNAPSHOT"));
entry("app.kubernetes.io/version", "0.1-SNAPSHOT"), entry("app.kubernetes.io/managed-by", "quarkus"));

// containers assertions
assertThat(deployment.getSpec().getTemplate().getSpec().getContainers()).satisfiesExactly(container -> {
Expand Down

0 comments on commit 3f3e0c8

Please sign in to comment.