diff --git a/.github/workflows/lint-test.yaml b/.github/workflows/lint-test.yaml index 8e8dff04..fa38c122 100644 --- a/.github/workflows/lint-test.yaml +++ b/.github/workflows/lint-test.yaml @@ -2,6 +2,7 @@ name: Lint and Test Charts on: pull_request + jobs: lint-test: runs-on: ubuntu-latest @@ -35,14 +36,13 @@ jobs: run: ct lint - name: Create kind cluster - uses: helm/kind-action@v1.2.0 + uses: helm/kind-action@v1.8.0 if: steps.list-changed.outputs.changed == 'true' - + - name: Install LoadBalancer run: |- kubectl config use-context kind-chart-testing - kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.12.1/manifests/namespace.yaml - kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.12.1/manifests/metallb.yaml + kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.13.10/config/manifests/metallb-native.yaml kubectl apply -f .github/metallb-configmap.yaml - name: Run chart-testing (install) diff --git a/charts/minecraft-bedrock/templates/_helpers.tpl b/charts/minecraft-bedrock/templates/_helpers.tpl index 406d4234..6358923f 100644 --- a/charts/minecraft-bedrock/templates/_helpers.tpl +++ b/charts/minecraft-bedrock/templates/_helpers.tpl @@ -14,3 +14,16 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this {{- $name := default .Chart.Name .Values.nameOverride -}} {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} {{- end -}} + +{{- define "extraDeploy.render" -}} +{{- $value := typeIs "string" .value | ternary .value (.value | toYaml) }} +{{- if contains "{{" (toJson .value) }} + {{- if .scope }} + {{- tpl (cat "{{- with $.RelativeScope -}}" $value "{{- end }}") (merge (dict "RelativeScope" .scope) .context) }} + {{- else }} + {{- tpl $value .context }} + {{- end }} +{{- else }} + {{- $value }} +{{- end }} +{{- end -}} diff --git a/charts/minecraft-bedrock/templates/extra-list.yaml b/charts/minecraft-bedrock/templates/extra-list.yaml new file mode 100644 index 00000000..1bf92ded --- /dev/null +++ b/charts/minecraft-bedrock/templates/extra-list.yaml @@ -0,0 +1,4 @@ +{{- range .Values.extraDeploy }} +--- +{{ include "extraDeploy.render" (dict "value" . "context" $) }} +{{- end }} diff --git a/charts/minecraft-bedrock/values.yaml b/charts/minecraft-bedrock/values.yaml index 25b2cf2f..afa7a3b9 100644 --- a/charts/minecraft-bedrock/values.yaml +++ b/charts/minecraft-bedrock/values.yaml @@ -78,6 +78,21 @@ initContainers: [] # - vers=4 extraVolumes: [] +## Array of extra objects to deploy with the release +## +# extraDeploy: +# - | +# apiVersion: v1 +# kind: ConfigMap +# metadata: +# name: {{ template "minecraft.fullname" . }}-extra-cm +# data: +# key: |- +# { +# "key": "value" +# } +extraDeploy: [] + minecraftServer: # This must be overridden, since we can't accept this for the user. eula: "FALSE" diff --git a/charts/minecraft/templates/_helpers.tpl b/charts/minecraft/templates/_helpers.tpl index dcee9887..e0ec1ca5 100644 --- a/charts/minecraft/templates/_helpers.tpl +++ b/charts/minecraft/templates/_helpers.tpl @@ -37,4 +37,17 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this - name: {{ index . 0 }} value: {{ index . 1 | quote }} {{- end }} -{{- end }} \ No newline at end of file +{{- end }} + +{{- define "extraDeploy.render" -}} +{{- $value := typeIs "string" .value | ternary .value (.value | toYaml) }} +{{- if contains "{{" (toJson .value) }} + {{- if .scope }} + {{- tpl (cat "{{- with $.RelativeScope -}}" $value "{{- end }}") (merge (dict "RelativeScope" .scope) .context) }} + {{- else }} + {{- tpl $value .context }} + {{- end }} +{{- else }} + {{- $value }} +{{- end }} +{{- end -}} diff --git a/charts/minecraft/templates/deployment.yaml b/charts/minecraft/templates/deployment.yaml index 73c87a79..c12f9752 100644 --- a/charts/minecraft/templates/deployment.yaml +++ b/charts/minecraft/templates/deployment.yaml @@ -166,7 +166,7 @@ spec: {{- if .Values.lifecycle.preStop }} preStop: exec: - command: {{- range .Values.lifecycle.postStart }} + command: {{- range .Values.lifecycle.preStop }} - {{ . }} {{- end }} {{- end }} diff --git a/charts/minecraft/templates/extra-list.yaml b/charts/minecraft/templates/extra-list.yaml new file mode 100644 index 00000000..1bf92ded --- /dev/null +++ b/charts/minecraft/templates/extra-list.yaml @@ -0,0 +1,4 @@ +{{- range .Values.extraDeploy }} +--- +{{ include "extraDeploy.render" (dict "value" . "context" $) }} +{{- end }} diff --git a/charts/minecraft/templates/extraports-ing.yaml b/charts/minecraft/templates/extraports-ing.yaml index bcab18e5..c8d81ecc 100644 --- a/charts/minecraft/templates/extraports-ing.yaml +++ b/charts/minecraft/templates/extraports-ing.yaml @@ -16,9 +16,9 @@ metadata: chart: "{{ $.Chart.Name }}-{{ $.Chart.Version }}" release: "{{ $.Release.Name }}" heritage: "{{ $.Release.Service }}" - app.kubernetes.io/name: "{{ .Chart.Name }}" + app.kubernetes.io/name: "{{ $.Chart.Name }}" app.kubernetes.io/instance: {{ $minecraftFullname }} - app.kubernetes.io/version: "{{ .Chart.Version }}" + app.kubernetes.io/version: "{{ $.Chart.Version }}" spec: {{- if .ingress.ingressClassName }} ingressClassName: {{ .ingress.ingressClassName }} diff --git a/charts/minecraft/templates/extraports-svc.yaml b/charts/minecraft/templates/extraports-svc.yaml index 8c26d785..07ba443a 100644 --- a/charts/minecraft/templates/extraports-svc.yaml +++ b/charts/minecraft/templates/extraports-svc.yaml @@ -13,9 +13,9 @@ metadata: chart: "{{ $.Chart.Name }}-{{ $.Chart.Version }}" release: "{{ $.Release.Name }}" heritage: "{{ $.Release.Service }}" - app.kubernetes.io/name: "{{ .Chart.Name }}" + app.kubernetes.io/name: "{{ $.Chart.Name }}" app.kubernetes.io/instance: {{ $minecraftFullname }} - app.kubernetes.io/version: "{{ .Chart.Version }}" + app.kubernetes.io/version: "{{ $.Chart.Version }}" spec: {{- if (or (eq .service.type "ClusterIP") (empty .service.type)) }} type: ClusterIP diff --git a/charts/minecraft/templates/minecraft-svc.yaml b/charts/minecraft/templates/minecraft-svc.yaml index 18b6b458..361498f6 100644 --- a/charts/minecraft/templates/minecraft-svc.yaml +++ b/charts/minecraft/templates/minecraft-svc.yaml @@ -71,3 +71,6 @@ spec: {{- end }} {{- end }} {{- end }} +{{- if .Values.minecraftServer.extraServiceSpec }} +{{ toYaml .Values.minecraftServer.extraServiceSpec | indent 2 }} +{{- end }} diff --git a/charts/minecraft/values.yaml b/charts/minecraft/values.yaml index 47915f8d..f45edef1 100644 --- a/charts/minecraft/values.yaml +++ b/charts/minecraft/values.yaml @@ -115,6 +115,22 @@ sidecarContainers: [] # - vers=4 extraVolumes: [] + +## Array of extra objects to deploy with the release +## +# extraDeploy: +# - | +# apiVersion: v1 +# kind: ConfigMap +# metadata: +# name: {{ template "minecraft.fullname" . }}-extra-cm +# data: +# key: |- +# { +# "key": "value" +# } +extraDeploy: [] + minecraftServer: # This must be overridden, since we can't accept this for the user. eula: "FALSE" @@ -247,6 +263,9 @@ minecraftServer: # A list of Spigot resources/plugins IDs to download. spigetResources: [] + # Additional service specs to be defined + extraServiceSpec: {} + # A list of Modrinth project slugs with optional version after colon modrinth: projects: []