grafana / loki

Like Prometheus, but for logs.
https://grafana.com/loki
GNU Affero General Public License v3.0
22.75k stars 3.31k forks source link

Loki Helm Chart Fails on Kubernetes < 1.21 #13387

Open aidanleuck opened 3 days ago

aidanleuck commented 3 days ago

Describe the bug The Loki helm chart fails to deploy on older Kubernetes clusters due to Pod Disruption budget being moved to stable policy/v1beta1 to policy/v1. We are using an old verison of Kubernetes that is still on the policy/v1beta1 endpoint. It appears a template exists in _helpers.tpl that correctly determines which apiVersion to use. However, this template does not appear to be applied in every file. This results in an error message when installing the chart.

_helpers.tpl template

{{- define "loki.pdb.apiVersion" -}}
  {{- if and (.Capabilities.APIVersions.Has "policy/v1") (semverCompare ">=1.21-0" .Capabilities.KubeVersion.Version) -}}
    {{- print "policy/v1" -}}
  {{- else -}}
    {{- print "policy/v1beta1" -}}
  {{- end -}}
{{- end -}}

Affected files: https://github.com/grafana/loki/blob/main/production/helm/loki/templates/read/poddisruptionbudget-read.yaml#L4 https://github.com/grafana/loki/blob/main/production/helm/loki/templates/backend/poddisruptionbudget-backend.yaml https://github.com/grafana/loki/blob/main/production/helm/loki/templates/gateway/poddisruptionbudget-gateway.yaml https://github.com/grafana/loki/blob/main/production/helm/loki/templates/single-binary/pdb.yaml https://github.com/grafana/loki/blob/main/production/helm/loki/templates/write/poddisruptionbudget-write.yaml

To Reproduce Steps to reproduce the behavior:

  1. Run helm install against the latest version of the helm chart on a Kubernetes cluster with version < 1.21
  2. Notice that an error message is printed complaining about missing CRDs

Expected behavior The helm install to succeed without error.

Suggested Solution Use the helpers.tpl template to correctly identify the API version for PodDisruptionBudget.

Environment:

Screenshots, Promtail config, or terminal output image