5

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:

  1. Installed google cloud sdk.
  2. Initialized gcloud with my google cloud cluster.
  3. Installed helm.
  4. Created helm charts like told in the tutorial.
  5. 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 <.Values.serviceAccount.create>: nil pointer evaluating interface {}.create

To be honest I'm not even sure the serviceaccount.yaml is here for and I'm grateful for any advise!

1
  • try "helm install --name hello-world -f values.yaml ." in the root directory. Commented Jan 30, 2020 at 21:45

2 Answers 2

1

You can try below options to debug this further.

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 below

Note 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 files

set 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: default

You can fetch your list of serviceaccounts available as below

$ kubectl get serviceaccounts
NAME      SECRETS   AGE
default   1         2d4h

Once 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.0

Get 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: 2000

Get 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   <none>           <none>

NAME                             TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)   AGE    SELECTOR
service/hello-world-1580665905   ClusterIP   10.108.73.21   <none>        80/TCP    118s   app.kubernetes.io/instance=hello-world-1580665905,app.kubernetes.io/name=hello-world
service/kubernetes               ClusterIP   10.96.0.1      <none>        443/TCP   2d4h   <none>

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=84b9d4d469
1
  • Thanks for your thoughtful answer. The issue was in the value.yaml.
    – Martin
    Commented Feb 3, 2020 at 11:59
0

Be aware that there you can have also this message with some charts when using helm 3 < 3.7.0

Reference: https://github.com/nextcloud/helm/issues/163

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.