patternkubernetesMinor
helm install causes nil pointer
Viewed 0 times
installnilpointerhelmcauses
Problem
I'm really a beginner with kubernetes and really struggle with this simple tutorial from baeldung.com
The only thing I did different (intentionally) was using a google cloud cluster instead of minikube.
Basically this is what I did so far:
And when I now run
I get this error message:
To be honest I'm not even sure the serviceaccount.yaml is here for and I'm grateful for any advise!
The only thing I did different (intentionally) was using a google cloud cluster instead of minikube.
Basically this is what I did so far:
- Installed google cloud sdk.
- Initialized gcloud with my google cloud cluster.
- Installed helm.
- Created helm charts like told in the tutorial.
- Changed service.yaml, values.cyaml and deployment.yaml like told in the tutorial.
And when I now run
helm install hello-world .I get this error message:
Error: template: hello-world/templates/serviceaccount.yaml:1:14: executing "hello-world/templates/serviceaccount.yaml" at : nil pointer evaluating interface {}.createTo be honest I'm not even sure the serviceaccount.yaml is here for and I'm grateful for any advise!
Solution
You can try below options to debug this further.
First verify
Try to deploy your helm chart with create: false and verify if it solves your issue.
Else remove the file
Note I have removed the
set create field as false under
You can fetch your list of serviceaccounts available as below
Once deployed helm list will show the namespace used to deploy your chart and serviceaccount from the name space is used for deploeyemnt
Get chart details and values post deploeyemtn as below
Get deployed resources as below
First verify
values.yaml and check the values for serviceAccount (default value is true ) that means the helm chart when deployed will create a service account for the deployment. When you create a pod, if you do not specify a service account, it is automatically assigned the default service account in the given namespace. serviceAccount:
# Specifies whether a service account should be created
create: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name:Try to deploy your helm chart with create: false and verify if it solves your issue.
Else remove the file
hello-world/templates/serviceaccount.yaml and mark serviceaccount as create: false in value.yaml and pass name as default service account of your deployment try to deploy as belowNote I have removed the
serviceaccount.yaml ~/hello$ tree
.
└── hello-world
├── charts
├── Chart.yaml
├── templates
│ ├── deployment.yaml
│ ├── _helpers.tpl
│ ├── ingress.yaml
│ ├── NOTES.txt
│ ├── service.yaml
│ └── tests
│ └── test-connection.yaml
└── values.yaml
4 directories, 8 filesset create field as false under
values.yaml$ cat hello-world/values.yaml | grep -i serviceaccount -A 10
serviceAccount:
# Specifies whether a service account should be created
create: false
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: defaultYou can fetch your list of serviceaccounts available as below
$ kubectl get serviceaccounts
NAME SECRETS AGE
default 1 2d4hOnce deployed helm list will show the namespace used to deploy your chart and serviceaccount from the name space is used for deploeyemnt
$ helm list
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
hello-world-1580665905 default 1 2020-02-02 17:51:45.631330487 +0000 UTC deployed hello-world-0.1.0 1.16.0Get chart details and values post deploeyemtn as below
$ helm show chart hello-world
apiVersion: v2
appVersion: 1.16.0
description: A Helm chart for Kubernetes
name: hello-world
type: application
version: 0.1.0
$ helm show values hello-world | grep -i serviceaccount -A 10
serviceAccount:
# Specifies whether a service account should be created
create: false
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: default
podSecurityContext: {}
# fsGroup: 2000Get deployed resources as below
$ kubectl get all -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
pod/hello-world-1580665905-84b9d4d469-xv5mx 1/1 Running 0 118s 192.168.58.215 k8s-node02
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
service/hello-world-1580665905 ClusterIP 10.108.73.21 80/TCP 118s app.kubernetes.io/instance=hello-world-1580665905,app.kubernetes.io/name=hello-world
service/kubernetes ClusterIP 10.96.0.1 443/TCP 2d4h
NAME READY UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR
deployment.apps/hello-world-1580665905 1/1 1 1 118s hello-world nginx:1.16.0 app.kubernetes.io/instance=hello-world-1580665905,app.kubernetes.io/name=hello-world
NAME DESIRED CURRENT READY AGE CONTAINERS IMAGES SELECTOR
replicaset.apps/hello-world-1580665905-84b9d4d469 1 1 1 118s hello-world nginx:1.16.0 app.kubernetes.io/instance=hello-world-1580665905,app.kubernetes.io/name=hello-world,pod-template-hash=84b9d4d469Code Snippets
serviceAccount:
# Specifies whether a service account should be created
create: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name:~/hello$ tree
.
└── hello-world
├── charts
├── Chart.yaml
├── templates
│ ├── deployment.yaml
│ ├── _helpers.tpl
│ ├── ingress.yaml
│ ├── NOTES.txt
│ ├── service.yaml
│ └── tests
│ └── test-connection.yaml
└── values.yaml
4 directories, 8 files$ cat hello-world/values.yaml | grep -i serviceaccount -A 10
serviceAccount:
# Specifies whether a service account should be created
create: false
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: default$ kubectl get serviceaccounts
NAME SECRETS AGE
default 1 2d4h$ helm list
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
hello-world-1580665905 default 1 2020-02-02 17:51:45.631330487 +0000 UTC deployed hello-world-0.1.0 1.16.0Context
StackExchange DevOps Q#10639, answer score: 1
Revisions (0)
No revisions yet.