Skip to content

Commit

Permalink
Merge pull request #14346 from mrizzi/issues-14345
Browse files Browse the repository at this point in the history
Remove ApplyLabelSelectorDecorator from MinikubeHandler
  • Loading branch information
geoand authored Feb 2, 2021
2 parents 483d142 + 0ac4ea3 commit b8f4acd
Show file tree
Hide file tree
Showing 8 changed files with 344 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import io.dekorate.kubernetes.decorator.AddServiceResourceDecorator;
import io.dekorate.kubernetes.decorator.ApplyHeadlessDecorator;
import io.dekorate.kubernetes.decorator.ApplyImageDecorator;
import io.dekorate.kubernetes.decorator.ApplyLabelSelectorDecorator;
import io.dekorate.kubernetes.decorator.ApplyReplicasDecorator;
import io.dekorate.project.ApplyProjectInfo;
import io.dekorate.project.Project;
Expand Down Expand Up @@ -125,7 +124,6 @@ protected void addDecorators(String group, KubernetesConfig config) {
}

resources.decorate(group, new AddIngressDecorator(config, Labels.createLabelsAsMap(config, "Ingress")));
resources.decorate(group, new ApplyLabelSelectorDecorator(createSelector(config)));
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# invoker.goals=clean package -Dquarkus.container.build=true -Dquarkus.package.type=native
invoker.goals=clean package
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.acme</groupId>
<artifactId>minikube-with-existing-manifest</artifactId>
<version>0.1-SNAPSHOT</version>
<properties>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<surefire-plugin.version>3.0.0-M5</surefire-plugin.version>
<maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-bom</artifactId>
<version>@project.version@</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-kubernetes</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-minikube</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-container-image-docker</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<configuration>
<systemPropertyVariables>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>${native.surefire.skip}</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<goals>
<goal>native-image</goal>
</goals>
<configuration>
<enableHttpUrlHandler>true</enableHttpUrlHandler>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<systemPropertyVariables>
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
####
# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
#
# Before building the docker image run:
#
# mvn package
#
# Then, build the image with:
#
# docker build -f src/main/docker/Dockerfile.jvm -t quarkus/getting-started-jvm .
#
# Then run the container using:
#
# docker run -i --rm -p 8080:8080 quarkus/getting-started-jvm
#
###
FROM fabric8/java-alpine-openjdk8-jre
ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
ENV AB_ENABLED=jmx_exporter
COPY target/lib/* /deployments/lib/
COPY target/*-runner.jar /deployments/app.jar
ENTRYPOINT [ "/deployments/run-java.sh" ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.acme;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

@Path("/hello")
public class Hello {

@GET
@Produces(MediaType.TEXT_PLAIN)
public String hello() {
return "hello";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
[
{
"apiVersion": "v1",
"kind": "Service",
"metadata": {
"labels": {
"app.kubernetes.io/name": "postgres",
"app.kubernetes.io/version" : "10.6"
},
"name": "postgres"
},
"spec": {
"ports": [
{
"name": "tcp",
"port": 5432,
"protocol": "TCP",
"targetPort": 5432
}
],
"selector": {
"app.kubernetes.io/name": "postgres",
"app.kubernetes.io/version" : "10.6"
},
"sessionAffinity": "None",
"type": "ClusterIP"
}
},
{
"apiVersion": "apps/v1",
"kind": "Deployment",
"metadata": {
"labels": {
"app.kubernetes.io/name": "postgres",
"app.kubernetes.io/version" : "10.6"
},
"name": "postgres"
},
"spec": {
"progressDeadlineSeconds": 600,
"replicas": 1,
"selector" : {
"matchLabels": {
"app.kubernetes.io/name": "postgres",
"app.kubernetes.io/version" : "10.6"
}
},
"strategy": {
"rollingUpdate": {
"maxSurge": "25%",
"maxUnavailable": "25%"
},
"type": "RollingUpdate"
},
"template": {
"metadata": {
"labels": {
"app.kubernetes.io/name": "postgres",
"app.kubernetes.io/version" : "10.6"
}
},
"spec": {
"containers": [
{
"env": [
{
"name": "POSTGRES_USER",
"value": "controls"
},
{
"name": "POSTGRES_PASSWORD",
"value": "controls"
},
{
"name": "POSTGRES_DB",
"value": "controls_db"
}
],
"image": "postgres:10.6",
"imagePullPolicy": "IfNotPresent",
"name": "postgres",
"ports": [
{
"containerPort": 5432,
"protocol": "TCP"
}
],
"readinessProbe": {
"timeoutSeconds": 1,
"initialDelaySeconds": 5,
"exec": {
"command": [ "psql", "-U", "$(POSTGRES_USER)", "-d", "$(POSTGRES_DB)", "-c", "SELECT 1" ]
}
},
"livenessProbe": {
"timeoutSeconds": 10,
"initialDelaySeconds": 120,
"exec": {
"command": [ "psql", "-U", "$(POSTGRES_USER)", "-d", "$(POSTGRES_DB)", "-c", "SELECT 1" ]
}
},
"resources": {},
"securityContext": {
"privileged": false
},
"terminationMessagePath": "/dev/termination-log",
"terminationMessagePolicy": "File"
}
],
"dnsPolicy": "ClusterFirst",
"restartPolicy": "Always",
"schedulerName": "default-scheduler",
"securityContext": {},
"terminationGracePeriodSeconds": 30
}
}
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Configuration file
# key = value
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import io.dekorate.utils.Serialization
import io.dekorate.deps.kubernetes.api.model.KubernetesList
import io.dekorate.deps.kubernetes.api.model.Container
import io.dekorate.deps.kubernetes.api.model.Service
import io.dekorate.deps.kubernetes.api.model.apps.Deployment;

//Check that file exits
String base = basedir
File kubernetesYml = new File(base, "target/kubernetes/minikube.yml")
assert kubernetesYml.exists()
kubernetesYml.withInputStream { stream ->
//Check that its parse-able
KubernetesList list = Serialization.unmarshalAsList(stream)
assert list != null

//Check that it contains the existing Service provided
Service service = list.items.find{ r -> r.kind == "Service" && r.metadata.name == "postgres"}
assert service != null
assert service.metadata.labels.get("app.kubernetes.io/name") == "postgres"
assert service.metadata.labels.get("app.kubernetes.io/version") == "10.6"
assert service.spec.selector.get("app.kubernetes.io/name") == "postgres"
assert service.spec.selector.get("app.kubernetes.io/version") == "10.6"

//Check that it contains the existing Deployment with provided labels and selector
Deployment deploymentProvided = list.items.find{r -> r.kind == "Deployment" && r.metadata.name == "postgres"}
assert deploymentProvided != null
assert deploymentProvided.metadata.labels.get("app.kubernetes.io/name") == "postgres"
assert deploymentProvided.metadata.labels.get("app.kubernetes.io/version") == "10.6"
assert deploymentProvided.spec.replicas == 1

assert deploymentProvided.spec.selector.matchLabels.get("app.kubernetes.io/name") == "postgres"
assert deploymentProvided.spec.selector.matchLabels.get("app.kubernetes.io/version") == "10.6"

Container container = deploymentProvided.spec.template.spec.containers[0]
assert container != null
assert container.name == "postgres"
assert container.ports.find{p -> p.protocol = "TCP"}.containerPort == 5432

//Check that it created the application's Deployment with right labels and selector
Deployment deployment = list.items.find{r -> r.kind == "Deployment" && r.metadata.name == "minikube-with-existing-manifest"}
assert deployment != null
assert deployment.metadata.labels.get("app.kubernetes.io/name") == "minikube-with-existing-manifest"
assert deployment.metadata.labels.get("app.kubernetes.io/version") == "0.1-SNAPSHOT"
assert deployment.spec.replicas == 1

assert deployment.spec.selector.matchLabels.get("app.kubernetes.io/name") == "minikube-with-existing-manifest"
assert deployment.spec.selector.matchLabels.get("app.kubernetes.io/version") == "0.1-SNAPSHOT"
}

0 comments on commit b8f4acd

Please sign in to comment.