Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix webserver ingress annotations #12619

Merged
merged 1 commit into from
Jan 5, 2021
Merged
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
2 changes: 1 addition & 1 deletion chart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ cluster using the [Helm](https://helm.sh) package manager.

## Prerequisites

- Kubernetes 1.12+ cluster
- Kubernetes 1.14+ cluster
- Helm 2.11+ or Helm 3.0+
- PV provisioner support in the underlying infrastructure

Expand Down
16 changes: 11 additions & 5 deletions chart/templates/webserver/webserver-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ metadata:
release: {{ .Release.Name }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
heritage: {{ .Release.Service }}
{{- with .Values.ingress.web.annotations }}
{{- if .Values.ingress.web.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
{{- with .Values.ingress.web.annotations }}
{{ toYaml . | indent 4 }}
{{- end }}
{{- end}}
spec:
{{- if .Values.ingress.web.tls.enabled }}
tls:
Expand All @@ -49,15 +51,19 @@ spec:
serviceName: {{ .serviceName }}
servicePort: {{ .servicePort }}
{{- end }}
- path: {{ .Values.ingress.web.path }}
backend:
- backend:
serviceName: {{ .Release.Name }}-webserver
servicePort: airflow-ui
{{- if .Values.ingress.web.path }}
path: {{ .Values.ingress.web.path }}
{{- end }}
{{- range .Values.ingress.web.succeedingPaths }}
- path: {{ .path }}
backend:
serviceName: {{ .serviceName }}
servicePort: {{ .servicePort }}
{{- end }}
{{- if .Values.ingress.web.host }}
host: {{ .Values.ingress.web.host }}
{{- end }}
{{- end }}
2 changes: 1 addition & 1 deletion chart/tests/helm_template_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

api_client = ApiClient()

BASE_URL_SPEC = "https://raw.githubusercontent.com/instrumenta/kubernetes-json-schema/master/v1.12.9"
ecerulm marked this conversation as resolved.
Show resolved Hide resolved
BASE_URL_SPEC = "https://raw.githubusercontent.com/instrumenta/kubernetes-json-schema/master/v1.14.0"


@lru_cache(maxsize=None)
Expand Down
37 changes: 37 additions & 0 deletions chart/tests/test_ingress_web.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

import unittest

import jmespath

from tests.helm_template_generator import render_chart


class IngressWebTest(unittest.TestCase):
def test_should_pass_validation_with_just_ingress_enabled(self):
render_chart(
values={"ingress": {"enabled": True}},
show_only=["templates/webserver/webserver-ingress.yaml"],
) # checks that no validation exception is raised

def test_should_allow_more_than_one_annotation(self):
docs = render_chart(
values={"ingress": {"enabled": True, "web": {"annotations": {"aa": "bb", "cc": "dd"}}}},
show_only=["templates/webserver/webserver-ingress.yaml"],
)
self.assertEqual({"aa": "bb", "cc": "dd"}, jmespath.search("metadata.annotations", docs[0]))