Allow webserver to read pod logs directly (#12598)
* Allow webserver to read pod logs directly For users who are testing the KubernetesExecutor, allows users to read pod logs via the Kubernetes API. Worth noting that these logs will only be accessible while the worker is running. * fix tests
This commit is contained in:
Родитель
6caf2607e0
Коммит
9f28e416db
|
@ -0,0 +1,56 @@
|
|||
# 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.
|
||||
|
||||
################################
|
||||
## Airflow Pod Reader Role
|
||||
#################################
|
||||
{{- if and .Values.rbacEnabled .Values.webserver.allowPodLogReading }}
|
||||
{{- if .Values.multiNamespaceMode }}
|
||||
kind: ClusterRole
|
||||
{{- else }}
|
||||
kind: Role
|
||||
{{- end }}
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
name: {{ .Release.Name }}-pod-log-reader-role
|
||||
{{- if not .Values.multiNamespaceMode }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
{{- end }}
|
||||
labels:
|
||||
tier: airflow
|
||||
release: {{ .Release.Name }}
|
||||
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
|
||||
heritage: {{ .Release.Service }}
|
||||
{{- with .Values.labels }}
|
||||
{{ toYaml . | indent 4 }}
|
||||
{{- end }}
|
||||
rules:
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- "pods"
|
||||
verbs:
|
||||
- "list"
|
||||
- "get"
|
||||
- "watch"
|
||||
- apiGroups:
|
||||
- ""
|
||||
resources:
|
||||
- "pods/log"
|
||||
verbs:
|
||||
- "get"
|
||||
{{- end }}
|
|
@ -0,0 +1,53 @@
|
|||
# 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.
|
||||
|
||||
################################
|
||||
## Airflow Pod Reader Role Binding
|
||||
#################################
|
||||
{{- if and .Values.rbacEnabled .Values.webserver.allowPodLogReading }}
|
||||
{{- if .Values.multiNamespaceMode }}
|
||||
kind: ClusterRoleBinding
|
||||
{{- else }}
|
||||
kind: RoleBinding
|
||||
{{- end }}
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
metadata:
|
||||
{{- if not .Values.multiNamespaceMode }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
{{- end }}
|
||||
name: {{ .Release.Name }}-pod-log-reader-rolebinding
|
||||
labels:
|
||||
tier: airflow
|
||||
release: {{ .Release.Name }}
|
||||
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
|
||||
heritage: {{ .Release.Service }}
|
||||
{{- with .Values.labels }}
|
||||
{{ toYaml . | indent 4 }}
|
||||
{{- end }}
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
{{- if .Values.multiNamespaceMode }}
|
||||
kind: ClusterRole
|
||||
{{- else }}
|
||||
kind: Role
|
||||
{{- end }}
|
||||
name: {{ .Release.Name }}-pod-log-reader-role
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: {{ .Release.Name }}-webserver
|
||||
namespace: {{ .Release.Namespace }}
|
||||
{{- end }}
|
|
@ -22,7 +22,7 @@ import jmespath
|
|||
|
||||
from tests.helm_template_generator import render_chart
|
||||
|
||||
OBJECT_COUNT_IN_BASIC_DEPLOYMENT = 22
|
||||
OBJECT_COUNT_IN_BASIC_DEPLOYMENT = 24
|
||||
|
||||
|
||||
class TestBaseChartTest(unittest.TestCase):
|
||||
|
@ -50,7 +50,9 @@ class TestBaseChartTest(unittest.TestCase):
|
|||
('Secret', 'TEST-BASIC-airflow-result-backend'),
|
||||
('ConfigMap', 'TEST-BASIC-airflow-config'),
|
||||
('Role', 'TEST-BASIC-pod-launcher-role'),
|
||||
('Role', 'TEST-BASIC-pod-log-reader-role'),
|
||||
('RoleBinding', 'TEST-BASIC-pod-launcher-rolebinding'),
|
||||
('RoleBinding', 'TEST-BASIC-pod-log-reader-rolebinding'),
|
||||
('Service', 'TEST-BASIC-postgresql-headless'),
|
||||
('Service', 'TEST-BASIC-postgresql'),
|
||||
('Service', 'TEST-BASIC-statsd'),
|
||||
|
|
|
@ -688,6 +688,10 @@
|
|||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"allowPodLogReading": {
|
||||
"description": "Allow webserver to read k8s pod logs. Useful when you don't have an external log store.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"livenessProbe": {
|
||||
"description": "Liveness probe configuration.",
|
||||
"type": "object",
|
||||
|
|
|
@ -387,6 +387,7 @@ scheduler:
|
|||
|
||||
# Airflow webserver settings
|
||||
webserver:
|
||||
allowPodLogReading: true
|
||||
livenessProbe:
|
||||
initialDelaySeconds: 15
|
||||
timeoutSeconds: 30
|
||||
|
|
Загрузка…
Ссылка в новой задаче