Step 1: Helm Fetch

This is where we go and fetch the chart that holds all the templates we will be using and storing it locally, the next templating command needs the chart locally.

helm fetch \

— untar \

— untardir charts \

stable/nginx-ingress

Step 2: Helm Template

Template out the yaml into a file, this is the step where you add the values to the chart and also set the namespace (more on this later). This step is generally handled by the tiller component (or in Helm 3 the Helm client)

helm template \

— name ingress-controller \

— output-dir base \

— namespace ingress \

— values values.yaml \

charts/nginx-ingress

This should give you a folder with a whole bunch of Kubernetes resources:

tree base/nginx-ingress/templates/

base/nginx-ingress/templates/

├── clusterrole.yaml

├── clusterrolebinding.yaml

├── controller-deployment.yaml

├── controller-hpa.yaml

├── controller-role.yaml

├── controller-rolebinding.yaml

├── controller-service.yaml

├── controller-serviceaccount.yaml

├── default-backend-deployment.yaml

├── default-backend-service.yaml

└── default-backend-serviceaccount.yaml 0 directories, 11 files

Just to neaten things up let’s move these up a dir and delete the template dir:

mv base/nginx-ingress/templates/* base/nginx-ingress && rm -rf base/nginx-ingress/templates

Step 3: Create the Kustomization config

One thing that is not very well known is that helm does not handle namespaces very well when you define --namespace while running helm install tiller does all the namespace work at runtime, it does not specify the namespace on any of the resources, meaning that to be more declarative you will need to create you namespace config manually:

cat <<EOF > base/nginx-ingress/namespace.yaml

apiVersion: v1

kind: Namespace

metadata:

name: ingress

EOF

You will need to create a kustomization.yam that lists all your resources, this is probably the most time-consuming part as this

will require you to go through the resources, but find this an important step as it allows you to go through what is going to be added to your cluster, you can also add some common labels, secret generators and loads more (see link below).

cat <<EOF > base/nginx-ingress/kustomization.yaml

namespace: “ingress”

commonLabels:

roles: routing

resources:

— namespace.yaml

— clusterrole.yaml

— clusterrolebinding.yaml

— controller-deployment.yaml

— controller-hpa.yaml

— controller-role.yaml

— controller-rolebinding.yaml

— controller-service.yaml

— controller-serviceaccount.yaml

— default-backend-deployment.yaml

— default-backend-service.yaml

— default-backend-serviceaccount.yaml

EOF

Step 4: Apply your new base to a cluster

as of Kubectl 1.14, Kustomize is integrated therefore you can simply run: