Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Usage:
* Fix #3809: Actuator liveness and readiness probe not getting generated with Spring boot 4.x.x
* Fix #3707: Setting readOnly flag in VolumeConfig has no effect
* Fix #1458: Consideration of "ssl.enabled" properties to enable liveness/readiness probe for Spring Boot Actuator
* Fix #2758: Inconsistency when merging fragments with same file name with different profiles

### 1.18.2 (2025-11-03)
* Fix #3750: Remove unneeded XMLUtil.createNewDocument method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,68 @@ Defaults to 0.

| *resourceEnvironment*
| Environment name where resources are placed. For example, if you set this property to dev and resourceDir is the
default one, plugin will look at `src/main/jkube/dev`. Multiple environments can also be provided in form of comma separated strings. Resource fragments in these directories will be combined while generating resources.
default one, plugin will look at `src/main/jkube/dev`. Multiple environments can also be provided in form of comma separated strings (e.g., `common,dev`).

When multiple environments are specified, resource fragments are processed and merged as follows:

*Processing Steps:*

. Fragments from all specified environment directories are collected (in order)
. Working directory is cleaned to remove stale files
. Each fragment is interpolated with project properties
. Fragments with the same filename are merged using Jackson YAML updater

*Merge Behavior for YAML Files:*

* *Objects/Maps*: Properties are deeply merged at all levels - new properties are added, existing properties are updated recursively
* *Arrays/Lists*: Elements from the new fragment are appended to the existing list
* *Scalar Values*: New values replace existing values

*Example Use Case:*

Given `common/deployment.yml`:
```yaml
spec:
replicas: 2
template:
spec:
containers:
- env:
- name: SPRING_PROFILES_ACTIVE
value: common
```

And `dev/deployment.yml`:
```yaml
metadata:
labels:
environment: development
spec:
replicas: 1
template:
spec:
containers:
- env:
- name: LOG_LEVEL
value: DEBUG
```

The merged result will be:
```yaml
metadata:
labels:
environment: development # from dev
spec:
replicas: 1 # from dev (overrides common)
template:
spec:
containers:
- env:
- name: SPRING_PROFILES_ACTIVE # from common
value: common
- name: LOG_LEVEL # from dev (appended to list)
value: DEBUG
```

Defaults to `null`.
| `jkube.environment`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* 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
*/
plugins {
id 'org.eclipse.jkube.openshift' version "${jKubeVersion}"
id 'org.springframework.boot' version '2.7.17'
id 'io.spring.dependency-management' version '1.0.15.RELEASE'
id 'java'
}

group = 'org.eclipse.jkube.integration.tests.gradle'
version = '0.1-SNAPSHOT'

repositories {
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
}

openshift {
offline = true
resourceEnvironment = 'common,dev'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
---
apiVersion: v1
kind: List
items:
- apiVersion: v1
kind: Service
metadata:
annotations:
prometheus.io/scrape: "true"
prometheus.io/path: /metrics
prometheus.io/port: "9779"
jkube.eclipse.org/git-commit: "@ignore@"
jkube.eclipse.org/git-url: "@ignore@"
app.openshift.io/vcs-ref: "@ignore@"
app.openshift.io/vcs-uri: "@ignore@"
jkube.eclipse.org/git-branch: "@ignore@"
labels:
app: multi-env-same-kind-profile-overridden
provider: jkube
version: 0.1-SNAPSHOT
group: org.eclipse.jkube.integration.tests.gradle
app.kubernetes.io/part-of: org.eclipse.jkube.integration.tests.gradle
app.kubernetes.io/managed-by: jkube
app.kubernetes.io/name: multi-env-same-kind-profile-overridden
app.kubernetes.io/version: 0.1-SNAPSHOT
name: multi-env-same-kind-profile-overridden
spec:
ports:
- name: http
port: 8080
protocol: TCP
targetPort: 8080
selector:
app: multi-env-same-kind-profile-overridden
provider: jkube
group: org.eclipse.jkube.integration.tests.gradle
app.kubernetes.io/name: multi-env-same-kind-profile-overridden
app.kubernetes.io/part-of: org.eclipse.jkube.integration.tests.gradle
app.kubernetes.io/managed-by: jkube
- apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
annotations:
jkube.eclipse.org/git-commit: "@ignore@"
jkube.eclipse.org/git-url: "@ignore@"
app.openshift.io/vcs-ref: "@ignore@"
app.openshift.io/vcs-uri: "@ignore@"
jkube.eclipse.org/git-branch: "@ignore@"
labels:
app: multi-env-same-kind-profile-overridden
provider: jkube
version: 0.1-SNAPSHOT
group: org.eclipse.jkube.integration.tests.gradle
app.kubernetes.io/part-of: org.eclipse.jkube.integration.tests.gradle
app.kubernetes.io/managed-by: jkube
app.kubernetes.io/name: multi-env-same-kind-profile-overridden
app.kubernetes.io/version: 0.1-SNAPSHOT
name: multi-env-same-kind-profile-overridden
spec:
replicas: 1
revisionHistoryLimit: 2
selector:
app: multi-env-same-kind-profile-overridden
provider: jkube
group: org.eclipse.jkube.integration.tests.gradle
app.kubernetes.io/name: multi-env-same-kind-profile-overridden
app.kubernetes.io/part-of: org.eclipse.jkube.integration.tests.gradle
app.kubernetes.io/managed-by: jkube
strategy:
rollingParams:
timeoutSeconds: 3600
type: Rolling
template:
metadata:
annotations:
jkube.eclipse.org/git-commit: "@ignore@"
jkube.eclipse.org/git-url: "@ignore@"
app.openshift.io/vcs-ref: "@ignore@"
app.openshift.io/vcs-uri: "@ignore@"
jkube.eclipse.org/git-branch: "@ignore@"
labels:
app: multi-env-same-kind-profile-overridden
provider: jkube
version: 0.1-SNAPSHOT
group: org.eclipse.jkube.integration.tests.gradle
app.kubernetes.io/part-of: org.eclipse.jkube.integration.tests.gradle
app.kubernetes.io/managed-by: jkube
app.kubernetes.io/name: multi-env-same-kind-profile-overridden
app.kubernetes.io/version: 0.1-SNAPSHOT
name: multi-env-same-kind-profile-overridden
spec:
containers:
- env:
- name: KUBERNETES_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
image: multi-env-same-kind-profile-overridden:latest
imagePullPolicy: IfNotPresent
name: spring-boot
ports:
- containerPort: 8080
name: http
protocol: TCP
- containerPort: 9779
name: prometheus
protocol: TCP
- containerPort: 8778
name: jolokia
protocol: TCP
securityContext:
privileged: false
triggers:
- type: ConfigChange
- imageChangeParams:
automatic: true
containerNames:
- spring-boot
from:
kind: ImageStreamTag
name: multi-env-same-kind-profile-overridden:latest
type: ImageChange
- apiVersion: route.openshift.io/v1
kind: Route
metadata:
annotations:
cert-manager.io/issuer-name: letsencrypt-common
haproxy.router.openshift.io/timeout: 120s
cert-manager.io/issuer-kind: ClusterIssuer
jkube.eclipse.org/git-commit: "@ignore@"
jkube.eclipse.org/git-url: "@ignore@"
app.openshift.io/vcs-ref: "@ignore@"
app.openshift.io/vcs-uri: "@ignore@"
jkube.eclipse.org/git-branch: "@ignore@"
labels:
app: multi-env-same-kind-profile-overridden
provider: jkube
version: 0.1-SNAPSHOT
group: org.eclipse.jkube.integration.tests.gradle
app.kubernetes.io/part-of: org.eclipse.jkube.integration.tests.gradle
app.kubernetes.io/managed-by: jkube
app.kubernetes.io/name: multi-env-same-kind-profile-overridden
app.kubernetes.io/version: 0.1-SNAPSHOT
name: multi-env-same-kind-profile-overridden
namespace: demo-namespace
spec:
host: demoapp.apps.example.com
port:
targetPort: http
tls:
insecureEdgeTerminationPolicy: Allow
termination: dev-overridden
to:
kind: Service
name: multi-env-same-kind-profile-overridden
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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;

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);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#
# 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
#

metadata:
annotations:
cert-manager.io/issuer-kind: ClusterIssuer
cert-manager.io/issuer-name: letsencrypt-common
haproxy.router.openshift.io/timeout: 120s
spec:
tls:
termination: edge
insecureEdgeTerminationPolicy: Redirect
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
#

metadata:
namespace: demo-namespace
spec:
host: demoapp.apps.example.com
tls:
termination: dev-overridden
insecureEdgeTerminationPolicy: Allow
35 changes: 35 additions & 0 deletions gradle-plugin/it/src/it/multi-env-same-kind/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* 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
*/
plugins {
id 'org.eclipse.jkube.openshift' version "${jKubeVersion}"
id 'org.springframework.boot' version '2.7.17'
id 'io.spring.dependency-management' version '1.0.15.RELEASE'
id 'java'
}

group = 'org.eclipse.jkube.integration.tests.gradle'
version = '0.1-SNAPSHOT'

repositories {
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
}

openshift {
offline = true
resourceEnvironment = 'common,dev'
}
Loading