From 4585ef963fc5d93b5d1b9905e64bd787a91a4b62 Mon Sep 17 00:00:00 2001 From: Marc Nuri Date: Mon, 2 Oct 2023 08:37:53 +0200 Subject: [PATCH] fix: Helm supports complex values in `values.yaml` fragments (such as annotations or arrays) Signed-off-by: Marc Nuri --- CHANGELOG.md | 1 + .../src/it/helm-complex-values/build.gradle | 67 +++++++ .../expected/inner-loop.yaml | 78 ++++++++ .../helm-complex-values/expected/values.yaml | 20 ++ .../helm-complex-values/gradle.dev.properties | 18 ++ .../src/main/jkube/deployment.yaml | 23 +++ .../src/main/jkube/service.yaml | 18 ++ .../src/main/jkube/values.helm.yaml | 33 ++++ .../src/it/helm-fragment-and-dsl/build.gradle | 3 + .../src/main/jkube/deployment.yaml | 3 + .../src/main/jkube/values.helm.yaml | 4 + .../plugin/tests/HelmComplexValuesIT.java | 71 +++++++ .../jkube/kit/common/ResourceVerify.java | 2 +- .../kit/resource/helm/HelmParameter.java | 6 +- .../kit/resource/helm/HelmParameterTest.java | 55 ++++++ quickstarts/maven/spring-boot-helm/pom.xml | 184 +++++++----------- .../src/main/jkube/complete-pod-template.yaml | 37 ---- .../src/main/jkube/deployment.yml | 12 +- ...l => spring-boot-helm-password-secret.yml} | 0 .../src/main/jkube/service.yml | 4 +- .../src/main/jkube/template.yaml | 8 +- .../src/main/jkube/values.helm.yaml | 25 +++ 22 files changed, 508 insertions(+), 164 deletions(-) create mode 100644 gradle-plugin/it/src/it/helm-complex-values/build.gradle create mode 100644 gradle-plugin/it/src/it/helm-complex-values/expected/inner-loop.yaml create mode 100644 gradle-plugin/it/src/it/helm-complex-values/expected/values.yaml create mode 100644 gradle-plugin/it/src/it/helm-complex-values/gradle.dev.properties create mode 100644 gradle-plugin/it/src/it/helm-complex-values/src/main/jkube/deployment.yaml create mode 100644 gradle-plugin/it/src/it/helm-complex-values/src/main/jkube/service.yaml create mode 100644 gradle-plugin/it/src/it/helm-complex-values/src/main/jkube/values.helm.yaml create mode 100644 gradle-plugin/it/src/test/java/org/eclipse/jkube/gradle/plugin/tests/HelmComplexValuesIT.java create mode 100644 jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmParameterTest.java delete mode 100644 quickstarts/maven/spring-boot-helm/src/main/jkube/complete-pod-template.yaml rename quickstarts/maven/spring-boot-helm/src/main/jkube/raw/{password-secret.yml => spring-boot-helm-password-secret.yml} (100%) create mode 100644 quickstarts/maven/spring-boot-helm/src/main/jkube/values.helm.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index cc8a745bbc..f36bba17fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ Usage: * Fix #2397: Default JKube work directory (`jkube.workDir`) changed from `${project.build.directory}/jkube` to `${project.build.directory}/jkube-temp` * Fix #2393: Remove timestamp from `org.label-schema.build-date` LABEL to utilize docker cache * Fix #2399: Helm no longer generates default function; broadens support for different value types +* Fix #2400: Helm supports complex values in `values.yaml` fragments (such as annotations or arrays) _**Note**_: - Container Images generated using jkube opinionated defaults no longer contain full timestamp in `org.label-schema.build-date` label. The label contains the build date in the format `yyyy-MM-dd`. diff --git a/gradle-plugin/it/src/it/helm-complex-values/build.gradle b/gradle-plugin/it/src/it/helm-complex-values/build.gradle new file mode 100644 index 0000000000..c229ec037b --- /dev/null +++ b/gradle-plugin/it/src/it/helm-complex-values/build.gradle @@ -0,0 +1,67 @@ +/* + * 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.kubernetes' version "${jKubeVersion}" + id 'org.eclipse.jkube.openshift' version "${jKubeVersion}" + id 'java' +} + +group = 'org.eclipse.jkube.integration.tests.gradle' +version = '0.0.1-SNAPSHOT' +sourceCompatibility = '11' + +repositories { + mavenCentral() +} + +def extensionConfig = { + offline = true + images { + image { + name = 'repository/helm:latest' + build { + from = 'repository/from:latest' + ports = [8080] + } + } + } + helm { + parameters = [ + { + name = 'deployment.annotations' + value = ''' + {{- toYaml .Values.common.annotations | nindent 4 }} + {{- toYaml .Values.deployment.annotations | nindent 4 }} + ''' + }, + { + name = 'deployment.hostAliases' + value = '{{- toYaml .Values.deployment.hostAliases | nindent 8 }}' + }, + { + name = 'service.annotations' + value = ''' + {{- toYaml .Values.common.annotations | nindent 4 }} + {{- toYaml .Values.service.annotations | nindent 4 }} + ''' + }, { + name = 'replicaCount' + value = 1 + }] + } +} + +kubernetes(extensionConfig) +openshift(extensionConfig) + diff --git a/gradle-plugin/it/src/it/helm-complex-values/expected/inner-loop.yaml b/gradle-plugin/it/src/it/helm-complex-values/expected/inner-loop.yaml new file mode 100644 index 0000000000..36e45ac78c --- /dev/null +++ b/gradle-plugin/it/src/it/helm-complex-values/expected/inner-loop.yaml @@ -0,0 +1,78 @@ +--- +apiVersion: v1 +kind: List +items: + - apiVersion: v1 + kind: Service + metadata: + labels: + app: helm-complex-values + provider: jkube + version: "@ignore@" + group: org.eclipse.jkube.integration.tests.gradle + name: helm-complex-values + annotations: + example.org/env: dev + example.org/kind: ServiceDev + spec: + ports: + - name: http + port: 8080 + protocol: TCP + targetPort: 8080 + selector: + app: helm-complex-values + provider: jkube + group: org.eclipse.jkube.integration.tests.gradle + - apiVersion: apps/v1 + kind: Deployment + metadata: + labels: + app: helm-complex-values + provider: jkube + version: "@ignore@" + group: org.eclipse.jkube.integration.tests.gradle + name: helm-complex-values + annotations: + example.org/env: dev + example.org/kind: DeploymentDev + spec: + replicas: 1 + revisionHistoryLimit: 2 + selector: + matchLabels: + app: helm-complex-values + provider: jkube + group: org.eclipse.jkube.integration.tests.gradle + template: + metadata: + annotations: "@ignore@" + labels: + app: helm-complex-values + provider: jkube + version: "@ignore@" + group: org.eclipse.jkube.integration.tests.gradle + spec: + hostAliases: + - hostnames: + - dev.example.com + ip: 127.0.0.1 + containers: + - env: + - name: KUBERNETES_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: HOSTNAME + valueFrom: + fieldRef: + fieldPath: metadata.name + image: repository/helm:latest + imagePullPolicy: IfNotPresent + name: repository-helm-complex-values + ports: + - containerPort: 8080 + name: http + protocol: TCP + securityContext: + privileged: false diff --git a/gradle-plugin/it/src/it/helm-complex-values/expected/values.yaml b/gradle-plugin/it/src/it/helm-complex-values/expected/values.yaml new file mode 100644 index 0000000000..711d3232a7 --- /dev/null +++ b/gradle-plugin/it/src/it/helm-complex-values/expected/values.yaml @@ -0,0 +1,20 @@ +--- +replicaCount: 1 +common: + annotations: + example.org/one: one + example.org/two: two + example.org/env: prod +deployment: + annotations: + example.org/kind: Deployment + hostAliases: + - ip: 1.1.1.1 + hostnames: + - one.example.com + - ip: 1.1.1.2 + hostnames: + - two.example.com +service: + annotations: + example.org/kind: Service diff --git a/gradle-plugin/it/src/it/helm-complex-values/gradle.dev.properties b/gradle-plugin/it/src/it/helm-complex-values/gradle.dev.properties new file mode 100644 index 0000000000..d84f5cd9f2 --- /dev/null +++ b/gradle-plugin/it/src/it/helm-complex-values/gradle.dev.properties @@ -0,0 +1,18 @@ +# +# 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 +# + +replicaCount = 1 +deployment.annotations = example.org/env: dev\n example.org/kind: DeploymentDev +deployment.hostAliases = - ip: 127.0.0.1\n hostnames: ['dev.example.com'] +service.annotations = example.org/env: dev\n example.org/kind: ServiceDev diff --git a/gradle-plugin/it/src/it/helm-complex-values/src/main/jkube/deployment.yaml b/gradle-plugin/it/src/it/helm-complex-values/src/main/jkube/deployment.yaml new file mode 100644 index 0000000000..c153f2a3fd --- /dev/null +++ b/gradle-plugin/it/src/it/helm-complex-values/src/main/jkube/deployment.yaml @@ -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: + ${deployment.annotations} +spec: + replicas: ${replicaCount} + template: + spec: + hostAliases: + ${deployment.hostAliases} diff --git a/gradle-plugin/it/src/it/helm-complex-values/src/main/jkube/service.yaml b/gradle-plugin/it/src/it/helm-complex-values/src/main/jkube/service.yaml new file mode 100644 index 0000000000..65cbfd8a21 --- /dev/null +++ b/gradle-plugin/it/src/it/helm-complex-values/src/main/jkube/service.yaml @@ -0,0 +1,18 @@ +# +# 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: + ${service.annotations} + diff --git a/gradle-plugin/it/src/it/helm-complex-values/src/main/jkube/values.helm.yaml b/gradle-plugin/it/src/it/helm-complex-values/src/main/jkube/values.helm.yaml new file mode 100644 index 0000000000..3553dac5f8 --- /dev/null +++ b/gradle-plugin/it/src/it/helm-complex-values/src/main/jkube/values.helm.yaml @@ -0,0 +1,33 @@ +# +# 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 +# + +common: + annotations: + example.org/one: one + example.org/two: two + example.org/env: prod + +deployment: + annotations: + example.org/kind: Deployment + hostAliases: + - ip: 1.1.1.1 + hostnames: + - one.example.com + - ip: 1.1.1.2 + hostnames: + - two.example.com +service: + annotations: + example.org/kind: Service diff --git a/gradle-plugin/it/src/it/helm-fragment-and-dsl/build.gradle b/gradle-plugin/it/src/it/helm-fragment-and-dsl/build.gradle index 3faf53d38b..1a8c7b62ce 100644 --- a/gradle-plugin/it/src/it/helm-fragment-and-dsl/build.gradle +++ b/gradle-plugin/it/src/it/helm-fragment-and-dsl/build.gradle @@ -55,6 +55,9 @@ def extensionConfig = { }] icon = 'https://example.com/icon-is-overridden' parameters = [{ + name = 'annotations' + value = '{{- toYaml .Values.annotations | nindent 4 }}' + }, { name = 'replicaCount' value = 1 }, { diff --git a/gradle-plugin/it/src/it/helm-fragment-and-dsl/src/main/jkube/deployment.yaml b/gradle-plugin/it/src/it/helm-fragment-and-dsl/src/main/jkube/deployment.yaml index 5c35313c99..3b49aad41c 100644 --- a/gradle-plugin/it/src/it/helm-fragment-and-dsl/src/main/jkube/deployment.yaml +++ b/gradle-plugin/it/src/it/helm-fragment-and-dsl/src/main/jkube/deployment.yaml @@ -12,6 +12,9 @@ # Red Hat, Inc. - initial API and implementation # +metadata: + annotations: + ${annotations} spec: replicas: ${replicaCount} template: diff --git a/gradle-plugin/it/src/it/helm-fragment-and-dsl/src/main/jkube/values.helm.yaml b/gradle-plugin/it/src/it/helm-fragment-and-dsl/src/main/jkube/values.helm.yaml index 53318f78c3..5852bc35f3 100644 --- a/gradle-plugin/it/src/it/helm-fragment-and-dsl/src/main/jkube/values.helm.yaml +++ b/gradle-plugin/it/src/it/helm-fragment-and-dsl/src/main/jkube/values.helm.yaml @@ -12,5 +12,9 @@ # Red Hat, Inc. - initial API and implementation # +annotations: + example.org/one: one + example.org/two: two + deployment: imagePullPolicy: Always diff --git a/gradle-plugin/it/src/test/java/org/eclipse/jkube/gradle/plugin/tests/HelmComplexValuesIT.java b/gradle-plugin/it/src/test/java/org/eclipse/jkube/gradle/plugin/tests/HelmComplexValuesIT.java new file mode 100644 index 0000000000..8b5192b334 --- /dev/null +++ b/gradle-plugin/it/src/test/java/org/eclipse/jkube/gradle/plugin/tests/HelmComplexValuesIT.java @@ -0,0 +1,71 @@ +/* + * 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 org.eclipse.jkube.kit.common.ResourceVerify; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; + +import java.nio.file.Files; + +import static org.assertj.core.api.Assertions.assertThat; + +class HelmComplexValuesIT { + + @RegisterExtension + public final ITGradleRunnerExtension gradleRunner = new ITGradleRunnerExtension(); + + @BeforeEach + void setUp() { + gradleRunner.withITProject("helm-complex-values"); + } + @Test + void outerLoop() throws Exception { + // When + gradleRunner.withArguments("clean", "k8sResource", "k8sHelm").build(); + // Then + ResourceVerify.verifyResourceDescriptors( + gradleRunner.resolveFile("build", "jkube", "helm", "helm-complex-values", "kubernetes", "values.yaml"), + gradleRunner.resolveFile("expected", "values.yaml")); + assertThat(ResourceVerify.readFile(gradleRunner.resolveFile( + "build", "jkube", "helm", "helm-complex-values", "kubernetes", "templates", "helm-complex-values-deployment.yaml"))) + .contains("annotations: {{- toYaml .Values.common.annotations | nindent 4 }}\n" + + " {{- toYaml .Values.deployment.annotations | nindent 4 }}") + .contains("hostAliases: {{- toYaml .Values.deployment.hostAliases | nindent 8 }}") + .contains("replicas: {{ .Values.replicaCount }}"); + assertThat(ResourceVerify.readFile(gradleRunner.resolveFile( + "build", "jkube", "helm", "helm-complex-values", "kubernetes", "templates", "helm-complex-values-service.yaml"))) + .contains("annotations: {{- toYaml .Values.common.annotations | nindent 4 }}\n" + + " {{- toYaml .Values.service.annotations | nindent 4 }}"); + } + + @Test + void innerLoop() throws Exception { + try { + // Given + // gradle.properties with properties to resolve placeholders in fragments + Files.copy(gradleRunner.resolveFile("gradle.dev.properties").toPath(), + gradleRunner.resolveFile("gradle.properties").toPath()); + // When + gradleRunner.withArguments("clean", "k8sResource").build(); + // Then + ResourceVerify.verifyResourceDescriptors(gradleRunner.resolveDefaultKubernetesResourceFile(), + gradleRunner.resolveFile("expected", "inner-loop.yaml")); + } finally { + Files.deleteIfExists(gradleRunner.resolveFile("gradle.properties").toPath()); + } + } + +} diff --git a/jkube-kit/common-it/src/main/java/org/eclipse/jkube/kit/common/ResourceVerify.java b/jkube-kit/common-it/src/main/java/org/eclipse/jkube/kit/common/ResourceVerify.java index b46c1f67cd..f943b54416 100644 --- a/jkube-kit/common-it/src/main/java/org/eclipse/jkube/kit/common/ResourceVerify.java +++ b/jkube-kit/common-it/src/main/java/org/eclipse/jkube/kit/common/ResourceVerify.java @@ -87,7 +87,7 @@ public static Object readWithPath(File file, String path) throws IOException { return JsonPath.parse(json, Configuration.builder().options(REQUIRE_PROPERTIES).build()).read(path); } - private static String readFile(File path) throws IOException { + public static String readFile(File path) throws IOException { return new String(FileCopyUtils.copyToByteArray(Files.newInputStream(path.toPath())), Charset.defaultCharset()); } diff --git a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmParameter.java b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmParameter.java index 6124f6f3fe..dbb177a339 100644 --- a/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmParameter.java +++ b/jkube-kit/resource/helm/src/main/java/org/eclipse/jkube/kit/resource/helm/HelmParameter.java @@ -21,6 +21,8 @@ import lombok.ToString; import org.apache.commons.lang3.StringUtils; +import java.util.stream.Stream; + @Builder(toBuilder = true) @AllArgsConstructor @NoArgsConstructor @@ -40,7 +42,9 @@ boolean isString() { } boolean isGolangExpression() { - return isString() && ((String) value).trim().matches(GOLANG_EXPRESSION_REGEX); + return isString() && Stream.of(value.toString().split("\r?\n")) + .filter(StringUtils::isNotBlank) + .allMatch(s -> s.trim().matches(GOLANG_EXPRESSION_REGEX)); } String toExpression() { diff --git a/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmParameterTest.java b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmParameterTest.java new file mode 100644 index 0000000000..e498dd1b3f --- /dev/null +++ b/jkube-kit/resource/helm/src/test/java/org/eclipse/jkube/kit/resource/helm/HelmParameterTest.java @@ -0,0 +1,55 @@ +/* + * 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.kit.resource.helm; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +import static org.assertj.core.api.Assertions.assertThat; + +class HelmParameterTest { + + @ParameterizedTest + @ValueSource(strings = { + "{{ .Values.foo }}", + "{{ .Values.foo }} {{ .Values.bar }}", + " {{ .Values.spaces }} ", + " {{ .Values.spaces.and.line }} \n \n ", + "{{ .Values.foo }} \n {{ .Values.bar }} \n" + }) + void isGolangExpressionWithGolangExpressionReturnsTrue(String expression) { + assertThat(HelmParameter.builder().value(expression).build().isGolangExpression()).isTrue(); + } + + @ParameterizedTest + @ValueSource(strings = { + "1", + "annotation \n {{ .Values.unsupported.Expression }}" + }) + void isGolangExpressionWithStringValueReturnsFalse(String value) { + assertThat(HelmParameter.builder().value(value).build().isGolangExpression()).isFalse(); + } + + @ParameterizedTest + @ValueSource(ints = {1, Integer.MAX_VALUE, Integer.MIN_VALUE}) + void isGolangExpressionWithIntValueReturnsFalse(int value) { + assertThat(HelmParameter.builder().value(value).build().isGolangExpression()).isFalse(); + } + + @ParameterizedTest + @ValueSource(booleans = {true, false}) + void isGolangExpressionWithBooleanValueReturnsFalse(boolean value) { + assertThat(HelmParameter.builder().value(value).build().isGolangExpression()).isFalse(); + } +} diff --git a/quickstarts/maven/spring-boot-helm/pom.xml b/quickstarts/maven/spring-boot-helm/pom.xml index 31955714cf..d0be343eee 100644 --- a/quickstarts/maven/spring-boot-helm/pom.xml +++ b/quickstarts/maven/spring-boot-helm/pom.xml @@ -21,12 +21,12 @@ org.springframework.boot spring-boot-starter-parent - 2.2.7.RELEASE + 2.5.3 org.eclipse.jkube.quickstarts.maven spring-boot-helm - 1.14.0 + 1.15-SNAPSHOT Eclipse JKube :: Quickstarts :: Maven :: Spring Boot - Helm jar @@ -39,8 +39,20 @@ ${project.version} - + + + sonatype-nexus-snapshots + Sonatype Nexus Snapshots + https://oss.sonatype.org/content/repositories/snapshots/ + + + sonatype-nexus-staging + Nexus Release Repository + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + + org.springframework.boot @@ -51,17 +63,66 @@ org.springframework.boot spring-boot-starter-actuator - - org.springframework.boot spring-boot-maven-plugin - + + org.eclipse.jkube + kubernetes-maven-plugin + ${jkube.version} + + + + + spring-boot-with-yaml-label-for-all + + + + + + + + deployment.replicas + {{ .Values.deployment.replicas }} + + + deployment.annotations + + {{- toYaml .Values.common.annotations | nindent 4 }} + {{- toYaml .Values.deployment.annotations | nindent 4 }} + + + + service.annotations + + {{- toYaml .Values.common.annotations | nindent 4 }} + {{- toYaml .Values.service.annotations | nindent 4 }} + + + + helm_namespace + {{ .Release.Namespace }} + + + + + + + + package + + resource + build + helm + + + + @@ -72,113 +133,12 @@ default n/a development n/a development - 1 - - - - - - kubernetes - - - - org.eclipse.jkube - kubernetes-maven-plugin - ${jkube.version} - - - - - - spring-boot-with-yaml-label-for-all - - - - - - - always - - - - - - - - - - - - - - - - - - - - - - - - - - - - package - - resource - build - helm - - - - - - - - - openshift - - true + 1 + jkube.helm.sh/environment: dev jkube.helm.sh/other: value + + + api.service.kubernetes.io/path: /dev - - - - org.eclipse.jkube - openshift-maven-plugin - ${jkube.version} - - - - - - spring-boot-with-yaml-label-for-all - - - - - - - always - Open Shift Maven Plugin - - - - - - - package - - resource - build - helm - - - - - - diff --git a/quickstarts/maven/spring-boot-helm/src/main/jkube/complete-pod-template.yaml b/quickstarts/maven/spring-boot-helm/src/main/jkube/complete-pod-template.yaml deleted file mode 100644 index 6e79598663..0000000000 --- a/quickstarts/maven/spring-boot-helm/src/main/jkube/complete-pod-template.yaml +++ /dev/null @@ -1,37 +0,0 @@ -# -# 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 -# - -kind: Template -metadata: - name: complete-template-for-pod -objects: -- apiVersion: v1 - kind: Pod - metadata: - name: pod-to-showcase-template - spec: - containers: - - env: - - name: SAMPLE_ENV_VAR - value: ${SAMPLE_ENV_VAR} - image: containous/whoami - name: master - ports: - - name: whoami - containerPort: 80 - protocol: TCP -parameters: - - description: Parameter to replace environment variable value - name: SAMPLE_ENV_VAR - value: This is a sample \ No newline at end of file diff --git a/quickstarts/maven/spring-boot-helm/src/main/jkube/deployment.yml b/quickstarts/maven/spring-boot-helm/src/main/jkube/deployment.yml index ef816c4651..1b81dcf736 100644 --- a/quickstarts/maven/spring-boot-helm/src/main/jkube/deployment.yml +++ b/quickstarts/maven/spring-boot-helm/src/main/jkube/deployment.yml @@ -20,13 +20,15 @@ metadata: hystrix.cluster: default version: ${project.version} annotations: - jkube.helm.sh/expression-example: ${golang_expression} - jkube.helm.sh/expression-example-scalar: ${golang_expression_scalar} + ${deployment.annotations} spec: - replicas: ${replicas} + replicas: ${deployment.replicas} template: metadata: namespace: ${helm_namespace} + annotations: + jkube.helm.sh/expression-example: ${golang_expression} + jkube.helm.sh/expression-example-scalar: ${golang_expression_scalar} labels: project: ${project.artifactId} hystrix.enabled: true @@ -36,6 +38,6 @@ spec: containers: - resources: limits: - memory: ${limits_memory} + memory: ${deployment.resources.limits_memory} requests: - memory: ${requests_memory} + memory: ${deployment.resources.requests_memory} diff --git a/quickstarts/maven/spring-boot-helm/src/main/jkube/raw/password-secret.yml b/quickstarts/maven/spring-boot-helm/src/main/jkube/raw/spring-boot-helm-password-secret.yml similarity index 100% rename from quickstarts/maven/spring-boot-helm/src/main/jkube/raw/password-secret.yml rename to quickstarts/maven/spring-boot-helm/src/main/jkube/raw/spring-boot-helm-password-secret.yml diff --git a/quickstarts/maven/spring-boot-helm/src/main/jkube/service.yml b/quickstarts/maven/spring-boot-helm/src/main/jkube/service.yml index 07d1439b27..14dcc6cea9 100644 --- a/quickstarts/maven/spring-boot-helm/src/main/jkube/service.yml +++ b/quickstarts/maven/spring-boot-helm/src/main/jkube/service.yml @@ -14,6 +14,6 @@ metadata: annotations: - api.service.kubernetes.io/path: /hello + ${service.annotations} spec: - type: NodePort \ No newline at end of file + type: NodePort diff --git a/quickstarts/maven/spring-boot-helm/src/main/jkube/template.yaml b/quickstarts/maven/spring-boot-helm/src/main/jkube/template.yaml index 6c754dc89d..2593b8facb 100644 --- a/quickstarts/maven/spring-boot-helm/src/main/jkube/template.yaml +++ b/quickstarts/maven/spring-boot-helm/src/main/jkube/template.yaml @@ -14,14 +14,10 @@ kind: Template parameters: - - name: limits_memory + - name: deployment.resources.limits_memory value: "512Mi" - - name: requests_memory + - name: deployment.resources.requests_memory value: "256Mi" - - name: replicas - - name: helm_namespace - value: | - {{ .Release.Namespace }} - name: i_should_be_quoted value: I need quotes - name: golang_expression diff --git a/quickstarts/maven/spring-boot-helm/src/main/jkube/values.helm.yaml b/quickstarts/maven/spring-boot-helm/src/main/jkube/values.helm.yaml new file mode 100644 index 0000000000..5ca4e677a2 --- /dev/null +++ b/quickstarts/maven/spring-boot-helm/src/main/jkube/values.helm.yaml @@ -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 +# + +common: + annotations: + jkube.helm.sh/common: annotation +deployment: + replicas: 1 + annotations: + jkube.helm.sh/annotation-1: value-1 + jkube.helm.sh/annotation-2: value-2 +service: + annotations: + api.service.kubernetes.io/path: /prod