I was wondering what kind of template functions, i...
# flyte-deployment
r
I was wondering what kind of template functions, if any, are available in the namespace templates: The reason I'm asking is because I would want to make sure that the service account name doesn't exceed the character limit of GCP. This example works:
Copy code
002_serviceaccount.yaml: |
      apiVersion: v1
      kind: ServiceAccount
      metadata:
        name: extra
        namespace: '{{ namespace }}'
        annotations:
          iam.gke.io/gcp-service-account: '{{ project }}-{{ domain }}@gcp-project.iam.gserviceaccount.com'
But if I'm trying to use some go template functions (and I might be using them wrong since my go knowledge is not great) it doesn't seem to work
Copy code
002_serviceaccount.yaml: |
      apiVersion: v1
      kind: ServiceAccount
      metadata:
        name: extra
        namespace: '{{ namespace }}'
        annotations:
          iam.gke.io/gcp-service-account: '{{printf "%q" "output"}}-{{ printf "%.9s" project }}-{{ domain }}@gcp-project.iam.gserviceaccount.com'
a
@ripe-smartphone-56353 I'm not proficient enough in Go templating either but, judging by the way it's used in some areas of the code (example) I'd say that something like this?
Copy code
annotations:
          iam.gke.io/gcp-service-account: '{{ project | trunc 9 }}-{{ domain }}@gcp-project.iam.gserviceaccount.com'
r
Thanks. Unfortunately that doesn't seem to work. I tried with several variants but it doesn't seem to run this through regular templating...
Copy code
002_serviceaccount.yaml: |
      apiVersion: v1
      kind: ServiceAccount
      metadata:
        name: extra
        namespace: '{{ namespace }}'
        annotations:
                   iam.gke.io/gcp-service-account: '{{- .project | trunc 9 }}-{{ .project | trunc 9 }}-{{ $project | trunc 9 }}-{{- printf "%s-%s" .Release.Name $name | trunc 9 }}-{{ domain }}@prod.iam.gserviceaccount.com'
which results in
Copy code
kubectl describe serviceaccounts extra -n flytesnacks-live
Name:                extra
Namespace:           flytesnacks-live
Labels:              <none>
Annotations:         iam.gke.io/gcp-service-account: {{- .project | trunc 9 }}-{{ .project | trunc 9 }}-{{ $project | trunc 9 }}-{{- printf "%s-%s" .Release.Name $name | trunc 9 }}-live@prod.iam.gserviceaccount.com
Image pull secrets:  <none>
Mountable secrets:   <none>
Tokens:              <none>
Events:              <none>