Helm pre-install yaml for config

12/1/2019

I’ve dependency in priority class inside my k8s yaml configs files and I need to install before any of my yaml inside the template folder the prio class

apiVersion: scheduling.k8s.io/v1beta1
kind: PriorityClass
metadata:
  name: ocritical
value: 1000
globalDefault: false

After reading the helm docs it seems that I can use the pre-install hook

I’ve changed my yaml and add anotiations section with pre-hook, and still it doesnt works, any idea what I miss here?

apiVersion: scheduling.k8s.io/v1beta1
kind: PriorityClass
metadata:
  name: ocritical
  annotations:
    "helm.sh/hook": pre-install
value: 1000
globalDefault: false

The yaml is located inisde the template folder

-- Jon lib
kubernetes
kubernetes-helm

1 Answer

12/2/2019

You put quotation marks for helm.sh/hook annotation which is incorrect - you can only add quotation marks for values of them. You can add description field in your configuration file, remember that this field is an arbitrary string. It is meant to tell users of the cluster when they should use this PriorityClass.

Your PriorityClass should looks like this:

apiVersion: scheduling.k8s.io/v1beta1
kind: PriorityClass
metadata:
  name: ocritical
  annotations:
    helm.sh/hook: pre-install,pre-upgrade
    helm.sh/hook-delete-policy: before-hook-creation
value: 1000
globalDefault: false
description: "This priority class should be used for XYZ service pods only."

More information about proper configuration of PriorityClass you can find here: PriorityClass. More information about installing hooks you can find here: helm-hooks.

I hope it helps.

-- MaggieO
Source: StackOverflow