Moving to use kubernetes-maven-plugin to support java 17 (#956)

* Moving to use kubernetes-maven-plugin to support java 17

* Fixing plugin in build command

* Moving enricher config to jkube

* Moving k8s templates to jkube directory and pointing arquillian to them

* pushing images

* review: K8s integration tests JKube compatible

Co-authored-by: Marc Nuri <marc@marcnuri.com>
This commit is contained in:
Ryan Baxter
2022-01-19 15:18:42 -05:00
committed by GitHub
parent 7b8121bcd5
commit 8df6c71c76
25 changed files with 103 additions and 96 deletions

View File

@@ -133,7 +133,7 @@ jobs:
/snap/bin/microk8s.kubectl config view --raw > /tmp/kubeconfig
export KUBECONFIG=/tmp/kubeconfig
cd spring-cloud-kubernetes-integration-tests
../mvnw -Ddocker.host='unix:///var/snap/microk8s/current/docker.sock' -Dimage.registry='localhost:32000' clean package fabric8:build verify -Pfmp,it,spring
../mvnw -Djkube.docker.host='unix:///var/snap/microk8s/current/docker.sock' clean package verify -Pk8s,it,spring
- run:
name: "Aggregate test results"
when: always

View File

@@ -72,7 +72,7 @@
<maven-deploy-plugin.version>2.8.2</maven-deploy-plugin.version>
<maven-failsafe-plugin.version>2.22.2</maven-failsafe-plugin.version>
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<fabric8.maven.plugin.version>4.4.0</fabric8.maven.plugin.version>
<kubernetes.maven.plugin.version>1.5.1</kubernetes.maven.plugin.version>
<groovy.version>2.4.12</groovy.version>
<restassured.version>3.0.2</restassured.version>

View File

@@ -124,9 +124,9 @@
</configuration>
</plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<version>${fabric8.maven.plugin.version}</version>
<groupId>org.eclipse.jkube</groupId>
<artifactId>kubernetes-maven-plugin</artifactId>
<version>${kubernetes.maven.plugin.version}</version>
<executions>
<execution>
<id>fmp</id>
@@ -145,9 +145,9 @@
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<version>${fabric8.maven.plugin.version}</version>
<groupId>org.eclipse.jkube</groupId>
<artifactId>kubernetes-maven-plugin</artifactId>
<version>${kubernetes.maven.plugin.version}</version>
<executions>
<execution>
<id>fmp</id>
@@ -160,9 +160,9 @@
<configuration>
<enricher>
<config>
<fmp-service>
<jkube-service>
<type>NodePort</type>
</fmp-service>
</jkube-service>
</config>
</enricher>
</configuration>
@@ -175,9 +175,9 @@
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<version>${fabric8.maven.plugin.version}</version>
<groupId>org.eclipse.jkube</groupId>
<artifactId>kubernetes-maven-plugin</artifactId>
<version>${kubernetes.maven.plugin.version}</version>
<executions>
<execution>
<id>fmp</id>
@@ -197,9 +197,9 @@
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<version>${fabric8.maven.plugin.version}</version>
<groupId>org.eclipse.jkube</groupId>
<artifactId>kubernetes-maven-plugin</artifactId>
<version>${kubernetes.maven.plugin.version}</version>
<executions>
<execution>
<id>fmp</id>

View File

@@ -60,9 +60,9 @@
<pluginManagement>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<version>${fabric8.maven.plugin.version}</version>
<groupId>org.eclipse.jkube</groupId>
<artifactId>kubernetes-maven-plugin</artifactId>
<version>${kubernetes.maven.plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -100,8 +100,8 @@
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<groupId>org.eclipse.jkube</groupId>
<artifactId>kubernetes-maven-plugin</artifactId>
<executions>
<execution>
<id>fmp</id>
@@ -114,9 +114,9 @@
<configuration>
<enricher>
<config>
<fmp-service>
<jkube-service>
<type>NodePort</type>
</fmp-service>
</jkube-service>
</config>
</enricher>
</configuration>

View File

@@ -38,8 +38,8 @@
</plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<groupId>org.eclipse.jkube</groupId>
<artifactId>kubernetes-maven-plugin</artifactId>
<executions>
<execution>
<id>fmp</id>

View File

@@ -39,8 +39,8 @@
</plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<groupId>org.eclipse.jkube</groupId>
<artifactId>kubernetes-maven-plugin</artifactId>
<executions>
<execution>
<id>fmp</id>

View File

@@ -18,9 +18,9 @@
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<version>${fabric8.maven.plugin.version}</version>
<groupId>org.eclipse.jkube</groupId>
<artifactId>kubernetes-maven-plugin</artifactId>
<version>${kubernetes.maven.plugin.version}</version>
<executions>
<execution>
<id>fmp</id>
@@ -33,9 +33,9 @@
<configuration>
<enricher>
<config>
<fmp-service>
<jkube-service>
<type>NodePort</type>
</fmp-service>
</jkube-service>
</config>
</enricher>
</configuration>
@@ -48,9 +48,9 @@
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<version>${fabric8.maven.plugin.version}</version>
<groupId>org.eclipse.jkube</groupId>
<artifactId>kubernetes-maven-plugin</artifactId>
<version>${kubernetes.maven.plugin.version}</version>
<executions>
<execution>
<id>fmp</id>
@@ -70,9 +70,9 @@
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<version>${fabric8.maven.plugin.version}</version>
<groupId>org.eclipse.jkube</groupId>
<artifactId>kubernetes-maven-plugin</artifactId>
<version>${kubernetes.maven.plugin.version}</version>
<executions>
<execution>
<id>fmp</id>

View File

@@ -104,9 +104,9 @@
</plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<version>${fabric8.maven.plugin.version}</version>
<groupId>org.eclipse.jkube</groupId>
<artifactId>kubernetes-maven-plugin</artifactId>
<version>${kubernetes.maven.plugin.version}</version>
<executions>
<execution>
<id>fmp</id>
@@ -118,12 +118,12 @@
<configuration>
<enricher>
<config>
<fmp-controller>
<jkube-controller>
<name>spring-cloud-reload</name>
</fmp-controller>
<fmp-service>
</jkube-controller>
<jkube-service>
<name>spring-cloud-reload</name>
</fmp-service>
</jkube-service>
</config>
</enricher>
</configuration>
@@ -137,9 +137,9 @@
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<version>${fabric8.maven.plugin.version}</version>
<groupId>org.eclipse.jkube</groupId>
<artifactId>kubernetes-maven-plugin</artifactId>
<version>${kubernetes.maven.plugin.version}</version>
<executions>
<execution>
<id>fmp</id>
@@ -152,13 +152,13 @@
<configuration>
<enricher>
<config>
<fmp-controller>
<jkube-controller>
<name>spring-cloud-reload</name>
</fmp-controller>
<fmp-service>
</jkube-controller>
<jkube-service>
<name>spring-cloud-reload</name>
<type>NodePort</type>
</fmp-service>
</jkube-service>
</config>
</enricher>
</configuration>
@@ -171,9 +171,9 @@
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<version>${fabric8.maven.plugin.version}</version>
<groupId>org.eclipse.jkube</groupId>
<artifactId>kubernetes-maven-plugin</artifactId>
<version>${kubernetes.maven.plugin.version}</version>
<executions>
<execution>
<id>fmp</id>
@@ -193,9 +193,9 @@
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<version>${fabric8.maven.plugin.version}</version>
<groupId>org.eclipse.jkube</groupId>
<artifactId>kubernetes-maven-plugin</artifactId>
<version>${kubernetes.maven.plugin.version}</version>
<executions>
<execution>
<id>fmp</id>

View File

@@ -8,12 +8,12 @@ lifecycle of the test applications is controlled by [Arquillian Cube](http://arq
# Basics
With FMP and Arquillian Cube setup for our project we need to configure the following things in order to properly get
With JKube and Arquillian Cube setup for our project we need to configure the following things in order to properly get
our test applications onto our cluster of choice:
* The `KUBECONFIG` environment variable needs to be set to the location of the Kubernetes configuration file
we will use to access our cluster (this can be skipped if this file is already present in the standard locations that kubectl assumes)
* The `docker.host` system property needs to be set to the URL where the docker daemon we will use to build images is listening
* The `jkube.docker.host` system property needs to be set to the URL where the docker daemon we will use to build images is listening
This can be skipped when we use the default unix socket on a Linux machine
* The Docker image registry were out built images will be stored needs to be set using the `image.registry` environment variable
@@ -78,7 +78,7 @@ microk8s.kubectl create -f .circleci/istio-test-namespace.yml
```bash
cd spring-cloud-kubernetes-integration-tests
KUBECONFIG=/tmp/kubeconfig mvn -Ddocker.host='unix:///var/snap/microk8s/current/docker.sock' -Dimage.registry='localhost:32000' clean package fabric8:build verify -Pfmp,it
KUBECONFIG=/tmp/kubeconfig mvn -Djkube.docker.host='unix:///var/snap/microk8s/current/docker.sock' clean package verify -Pk8s,it,spring
```
The command above will for each test project:
@@ -106,7 +106,7 @@ provide a Kubernetes server runs within a Docker container on your local system.
** `docker run -d -p 5000:5000 --restart=always --name registry registry:2`
* [Configure the Docker daemon to trust the local registry](https://docs.docker.com/docker-for-mac/#daemon)
* Export the docker config `kubectl config view --raw > /tmp/kubeconfig`
* Run the tests `KUBECONFIG=/tmp/kubeconfig mvn -Ddocker.host='unix:///var/run/docker.sock' -Dimage.registry='127.0.0.1:5000' clean package fabric8:build verify -Pfmp,it,spring`
* Run the tests `KUBECONFIG=/tmp/kubeconfig mvn -Djkube.docker.host='unix:///var/snap/microk8s/current/docker.sock' clean package verify -Pk8s,it,spring`
## Launching one of the applications manually
@@ -115,12 +115,12 @@ For example to launch the `simple-core` application
```bash
cd spring-cloud-kubernetes-integration-tests/simple-core
KUBECONFIG=/tmp/kubeconfig mvn -Ddocker.host='unix:///var/snap/microk8s/current/docker.sock' -Dimage.registry='localhost:32000' clean package fabric8:build fabric8:deploy -Pfmp
KUBECONFIG=/tmp/kubeconfig mvn -Djkube.docker.host='unix:///var/snap/microk8s/current/docker.sock' clean package verify -Pk8s,it,spring
```
When it's time to take down the application, simply execute:
```bash
KUBECONFIG=/tmp/kubeconfig mvn fabric8:undeploy -Pfmp
KUBECONFIG=/tmp/kubeconfig mvn k8s:undeploy -Pk8s
```

View File

@@ -1,4 +1,4 @@
# we are using an FMP fragment to ensure that NodePort is used correctly
# we are using a JKube fragment to ensure that NodePort is used correctly
kind: Service
apiVersion: v1
metadata:

View File

@@ -1,4 +1,4 @@
# we are using an FMP fragment to ensure that NodePort is used correctly
# we are using a JKube fragment to ensure that NodePort is used correctly
kind: Service
apiVersion: v1
metadata:

View File

@@ -68,8 +68,8 @@
</configuration>
</plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<groupId>org.eclipse.jkube</groupId>
<artifactId>kubernetes-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
@@ -83,8 +83,8 @@
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<groupId>org.eclipse.jkube</groupId>
<artifactId>kubernetes-maven-plugin</artifactId>
<configuration>
<skip>false</skip>
<profile>aggregate</profile>

View File

@@ -4,6 +4,7 @@
<extension qualifier="kubernetes">
<property name="namespace.use.existing">default</property>
<property name="env.config.url">file:./target/classes/META-INF/jkube/kubernetes.yml</property>
</extension>
</arquillian>

View File

@@ -1,4 +1,4 @@
# we are using an FMP fragment to ensure that NodePort is used correctly
# we are using a JKube fragment to ensure that NodePort is used correctly
kind: Service
apiVersion: v1
metadata:

View File

@@ -4,6 +4,7 @@
<extension qualifier="kubernetes">
<property name="namespace.use.existing">istio-test</property>
<property name="env.config.url">file:./target/classes/META-INF/jkube/kubernetes.yml</property>
</extension>
</arquillian>

View File

@@ -18,8 +18,7 @@
</description>
<properties>
<java.version>1.8</java.version>
<fmp.version>3.5.42</fmp.version>
<java.version>17</java.version>
<arquillian-cube.version>1.18.2</arquillian-cube.version>
<arquillian.version>1.4.0.Final</arquillian.version>
<rest-assured.version>3.2.0</rest-assured.version>
@@ -54,29 +53,33 @@
<profiles>
<profile>
<id>fmp</id>
<id>k8s</id>
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<version>${fmp.version}</version>
<groupId>org.eclipse.jkube</groupId>
<artifactId>kubernetes-maven-plugin</artifactId>
<configuration>
<!--
FMP can work with Openshift as well, so here we explicitly force it
to work with vanilla Kubernetes and Docker builds
-->
<buildStrategy>docker</buildStrategy>
<mode>kubernetes</mode>
<pushRegistry>${image.registry}</pushRegistry>
<generator>
<includes>
<include>spring-boot</include>
</includes>
<config>
<spring-boot>
<!-- TODO: Remove when Eclipse JKube 1.6.0 is released -->
<from>quay.io/jkube/jkube-java:0.0.13</from>
</spring-boot>
</config>
</generator>
</configuration>
<executions>
<execution>
<id>fabric8</id>
<id>jkube</id>
<goals>
<goal>resource</goal>
<goal>build</goal>
<goal>resource</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
@@ -156,15 +159,15 @@
<modules>
<module>simple-core</module>
<module>simple-configmap</module>
<!-- <module>istio</module>-->
<!-- <module>istio</module>-->
<module>discovery</module>
<module>load-balancer</module>
<!-- Add this module back once we convert everything over to kind -->
<!-- <module>spring-cloud-kubernetes-client-config-it</module>-->
<!-- <module>spring-cloud-kubernetes-client-loadbalancer-it</module>-->
<!-- <module>spring-cloud-kubernetes-client-reactive-discovery-client-it</module>-->
<!-- <module>spring-cloud-kubernetes-configuration-watcher-it</module>-->
<!-- <module>spring-cloud-kubernetes-configuration-watcher-it</module>-->
<!-- <module>spring-cloud-kubernetes-core-k8s-client-it</module>-->
<!-- Add this module back once we convert everything over to kind -->
<!-- <module>spring-cloud-kubernetes-client-config-it</module>-->
<!-- <module>spring-cloud-kubernetes-client-loadbalancer-it</module>-->
<!-- <module>spring-cloud-kubernetes-client-reactive-discovery-client-it</module>-->
<!-- <module>spring-cloud-kubernetes-configuration-watcher-it</module>-->
<!-- <module>spring-cloud-kubernetes-configuration-watcher-it</module>-->
<!-- <module>spring-cloud-kubernetes-core-k8s-client-it</module>-->
</modules>
</project>

View File

@@ -1,4 +1,4 @@
# We are using an FMP fragment to ensure that NodePort is used correctly
# We are using a JKube fragment to ensure that NodePort is used correctly
spec:
ports:
- protocol: TCP

View File

@@ -4,6 +4,7 @@
<extension qualifier="kubernetes">
<property name="namespace.use.existing">default</property>
<property name="env.config.url">file:./target/classes/META-INF/jkube/kubernetes.yml</property>
</extension>
</arquillian>

View File

@@ -1,4 +1,4 @@
# we are using an FMP fragment to ensure that NodePort is used correctly
# we are using a JKube fragment to ensure that NodePort is used correctly
kind: Service
apiVersion: v1
metadata:

View File

@@ -4,6 +4,7 @@
<extension qualifier="kubernetes">
<property name="namespace.use.existing">default</property>
<property name="env.config.url">file:./target/classes/META-INF/jkube/kubernetes.yml</property>
</extension>
</arquillian>