Skip to content

Loki Helm Chart Fails on Kubernetes < 1.21 #13387

@aidanleuck

Description

@aidanleuck

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:

  • Infrastructure: Kubernetes 1.20.11
  • Deployment tool: helm

Screenshots, Promtail config, or terminal output
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions