forked from eclipse-jkube/jkube
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix : Spring Boot actuator endpoints don't generate if `deployment.ym…
…l` fragment is used (eclipse-jkube#1295) Right now with DeploymentConfigBuilder, TypedVisitor<ContainerBuilder> is visiting ContainerBuilder twice instead of visiting it once. This is generating list with duplicate ContainerBuilder elements. Move DeploymentConfigEnricher lower than Health Check enrichers in order to do conversion after health checks have been added to Deployment. Signed-off-by: Rohan Kumar <rohaan@redhat.com>
- Loading branch information
1 parent
d1152b1
commit 01c0fb5
Showing
11 changed files
with
349 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
gradle-plugin/it/src/it/spring-boot-with-fragment/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
plugins { | ||
id 'org.eclipse.jkube.kubernetes' version "${jKubeVersion}" | ||
id 'org.eclipse.jkube.openshift' version "${jKubeVersion}" | ||
id 'org.springframework.boot' version '2.5.2' | ||
id 'io.spring.dependency-management' version '1.0.11.RELEASE' | ||
id 'java' | ||
} | ||
|
||
group = 'org.eclipse.jkube.integration.tests.gradle' | ||
version = '0.0.1-SNAPSHOT' | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation 'org.springframework.boot:spring-boot-starter-web' | ||
implementation 'org.springframework.boot:spring-boot-starter-actuator' | ||
} | ||
|
||
kubernetes { | ||
offline = true | ||
} | ||
openshift { | ||
offline = true | ||
} |
103 changes: 103 additions & 0 deletions
103
gradle-plugin/it/src/it/spring-boot-with-fragment/expected/kubernetes.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: List | ||
items: | ||
- apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
annotations: | ||
prometheus.io/path: /metrics | ||
jkube.io/git-branch: "@ignore@" | ||
prometheus.io/port: "@ignore@" | ||
prometheus.io/scrape: "@ignore@" | ||
jkube.io/git-url: "@ignore@" | ||
jkube.io/git-commit: "@ignore@" | ||
labels: | ||
expose: "true" | ||
app: spring-boot-with-fragment | ||
provider: jkube | ||
version: "@ignore@" | ||
group: org.eclipse.jkube.integration.tests.gradle | ||
name: spring-boot-with-fragment | ||
spec: | ||
ports: | ||
- name: http | ||
port: 8080 | ||
protocol: TCP | ||
targetPort: 8080 | ||
selector: | ||
app: spring-boot-with-fragment | ||
provider: jkube | ||
group: org.eclipse.jkube.integration.tests.gradle | ||
- apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
annotations: | ||
jkube.io/git-url: "@ignore@" | ||
jkube.io/git-commit: "@ignore@" | ||
jkube.io/git-branch: "@ignore@" | ||
labels: | ||
app: spring-boot-with-fragment | ||
provider: jkube | ||
version: "@ignore@" | ||
group: org.eclipse.jkube.integration.tests.gradle | ||
name: spring-boot-with-fragment | ||
spec: | ||
replicas: 1 | ||
revisionHistoryLimit: 2 | ||
selector: | ||
matchLabels: | ||
app: spring-boot-with-fragment | ||
provider: jkube | ||
group: org.eclipse.jkube.integration.tests.gradle | ||
template: | ||
metadata: | ||
annotations: | ||
jkube.io/git-url: "@ignore@" | ||
jkube.io/git-commit: "@ignore@" | ||
jkube.io/git-branch: "@ignore@" | ||
labels: | ||
app: spring-boot-with-fragment | ||
provider: jkube | ||
version: "@ignore@" | ||
group: org.eclipse.jkube.integration.tests.gradle | ||
spec: | ||
containers: | ||
- env: | ||
- name: ABC | ||
value: dummy | ||
- name: KUBERNETES_NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
image: gradle/spring-boot-with-fragment:latest | ||
imagePullPolicy: IfNotPresent | ||
livenessProbe: | ||
failureThreshold: 3 | ||
httpGet: | ||
path: /actuator/health | ||
port: 8080 | ||
scheme: HTTP | ||
initialDelaySeconds: 180 | ||
successThreshold: 1 | ||
name: spring-boot | ||
ports: | ||
- containerPort: 8080 | ||
name: http | ||
protocol: TCP | ||
- containerPort: 9779 | ||
name: prometheus | ||
protocol: TCP | ||
- containerPort: 8778 | ||
name: jolokia | ||
protocol: TCP | ||
readinessProbe: | ||
failureThreshold: 3 | ||
httpGet: | ||
path: /actuator/health | ||
port: 8080 | ||
scheme: HTTP | ||
initialDelaySeconds: 10 | ||
successThreshold: 1 | ||
securityContext: | ||
privileged: false |
92 changes: 92 additions & 0 deletions
92
gradle-plugin/it/src/it/spring-boot-with-fragment/expected/openshift.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# | ||
# Copyright (c) 2019 Red Hat, Inc. | ||
# This program and the accompanying materials are made | ||
# available under the terms of the Eclipse Public License 2.0 | ||
# which is available at: | ||
# | ||
# https://www.eclipse.org/legal/epl-2.0/ | ||
# | ||
# SPDX-License-Identifier: EPL-2.0 | ||
# | ||
# Contributors: | ||
# Red Hat, Inc. - initial API and implementation | ||
# | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: List | ||
items: | ||
- apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: spring-boot-with-fragment | ||
spec: | ||
ports: | ||
- name: http | ||
port: 8080 | ||
protocol: TCP | ||
targetPort: 8080 | ||
selector: | ||
app: spring-boot-with-fragment | ||
provider: jkube | ||
group: org.eclipse.jkube.integration.tests.gradle | ||
- apiVersion: apps.openshift.io/v1 | ||
kind: DeploymentConfig | ||
metadata: | ||
labels: | ||
provider: jkube | ||
app: spring-boot-with-fragment | ||
version: "@ignore@" | ||
group: org.eclipse.jkube.integration.tests.gradle | ||
name: spring-boot-with-fragment | ||
spec: | ||
replicas: 1 | ||
selector: | ||
app: spring-boot-with-fragment | ||
provider: jkube | ||
group: org.eclipse.jkube.integration.tests.gradle | ||
template: | ||
metadata: | ||
labels: | ||
provider: jkube | ||
app: spring-boot-with-fragment | ||
version: "@ignore@" | ||
group: org.eclipse.jkube.integration.tests.gradle | ||
spec: | ||
containers: | ||
- env: | ||
- name: ABC | ||
value: dummy | ||
- name: KUBERNETES_NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
image: spring-boot-with-fragment:latest | ||
imagePullPolicy: IfNotPresent | ||
livenessProbe: | ||
httpGet: | ||
path: /actuator/health | ||
port: 8080 | ||
scheme: HTTP | ||
initialDelaySeconds: 180 | ||
name: spring-boot | ||
ports: | ||
- containerPort: 8080 | ||
name: http | ||
protocol: TCP | ||
- containerPort: 9779 | ||
name: prometheus | ||
protocol: TCP | ||
- containerPort: 8778 | ||
name: jolokia | ||
protocol: TCP | ||
readinessProbe: | ||
httpGet: | ||
path: /actuator/health | ||
port: 8080 | ||
scheme: HTTP | ||
initialDelaySeconds: 10 | ||
securityContext: | ||
privileged: false | ||
triggers: | ||
- type: ConfigChange |
26 changes: 26 additions & 0 deletions
26
...boot-with-fragment/src/main/java/org/eclipse/jkube/it/gradle/spring/boot/Application.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* Copyright (c) 2019 Red Hat, Inc. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at: | ||
* | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
package org.eclipse.jkube.it.gradle.spring.boot; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class Application { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(Application.class, args); | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
gradle-plugin/it/src/it/spring-boot-with-fragment/src/main/jkube/deployment.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# | ||
# Copyright (c) 2019 Red Hat, Inc. | ||
# This program and the accompanying materials are made | ||
# available under the terms of the Eclipse Public License 2.0 | ||
# which is available at: | ||
# | ||
# https://www.eclipse.org/legal/epl-2.0/ | ||
# | ||
# SPDX-License-Identifier: EPL-2.0 | ||
# | ||
# Contributors: | ||
# Red Hat, Inc. - initial API and implementation | ||
# | ||
|
||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- env: | ||
- name: ABC | ||
value: dummy |
68 changes: 68 additions & 0 deletions
68
...ugin/it/src/test/java/org/eclipse/jkube/gradle/plugin/tests/SpringBootWithFragmentIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/** | ||
* Copyright (c) 2019 Red Hat, Inc. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at: | ||
* | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
package org.eclipse.jkube.gradle.plugin.tests; | ||
|
||
import net.minidev.json.parser.ParseException; | ||
import org.eclipse.jkube.kit.common.ResourceVerify; | ||
import org.gradle.testkit.runner.BuildResult; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.assertj.core.api.AssertionsForClassTypes.assertThat; | ||
|
||
public class SpringBootWithFragmentIT { | ||
@Rule | ||
public final ITGradleRunner gradleRunner = new ITGradleRunner(); | ||
|
||
@Test | ||
public void k8sResource_whenRun_generatesK8sManifests() throws IOException, ParseException { | ||
// When | ||
final BuildResult result = gradleRunner.withITProject("spring-boot-with-fragment") | ||
.withArguments("build", "k8sResource", "--stacktrace") | ||
.build(); | ||
// Then | ||
ResourceVerify.verifyResourceDescriptors(gradleRunner.resolveDefaultKubernetesResourceFile(), | ||
gradleRunner.resolveFile("expected", "kubernetes.yml")); | ||
assertThat(result).extracting(BuildResult::getOutput).asString() | ||
.contains("Running in Kubernetes mode") | ||
.contains("Running generator spring-boot") | ||
.contains("jkube-service: Adding a default service") | ||
.contains("jkube-healthcheck-spring-boot: Adding readiness probe on port 8080") | ||
.contains("jkube-healthcheck-spring-boot: Adding liveness probe on port 8080") | ||
.contains("jkube-service-discovery: Using first mentioned service port '8080' ") | ||
.contains("jkube-revision-history: Adding revision history limit to 2"); | ||
} | ||
|
||
@Test | ||
public void ocResource_whenRun_generatesOpenShiftManifests() throws IOException, ParseException { | ||
// When | ||
final BuildResult result = gradleRunner.withITProject("spring-boot-with-fragment") | ||
.withArguments("build", "ocResource", "--stacktrace") | ||
.build(); | ||
// Then | ||
ResourceVerify.verifyResourceDescriptors(gradleRunner.resolveDefaultOpenShiftResourceFile(), | ||
gradleRunner.resolveFile("expected", "openshift.yml")); | ||
assertThat(result).extracting(BuildResult::getOutput).asString() | ||
.contains("Running in OpenShift mode") | ||
.contains("Running generator spring-boot") | ||
.contains("jkube-service: Adding a default service") | ||
.contains("jkube-openshift-deploymentconfig: Converting Deployment to DeploymentConfig") | ||
.contains("jkube-healthcheck-spring-boot: Adding readiness probe on port 8080") | ||
.contains("jkube-healthcheck-spring-boot: Adding liveness probe on port 8080") | ||
.contains("jkube-service-discovery: Using first mentioned service port '8080' ") | ||
.contains("jkube-revision-history: Adding revision history limit to 2"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.