Does anyone know if using a <Kubernetes Service Ac...
# troubleshooting
r
Does anyone know if using a Kubernetes Service Account (from GCS) is supported with the Flink Operator? Previously I was using the following approach to include the appropriate service account and explicitly mounting the
GOOGLE_APPLICATION_CREDENTIALS
from an existing secret as follows:
Copy code
podTemplate:
    apiVersion: v1
    kind: Pod
    metadata:
      name: pod-template
    spec:
      containers:
        - name: flink-main-container
          ...
          volumeMounts:
            - mountPath: /flink/gcs-creds/
              name: ...
          env:
          - name: GOOGLE_APPLICATION_CREDENTIALS
            value: /flink/gcs-creds/key.json
          - name: ENABLE_BUILT_IN_PLUGINS
            value: flink-gs-fs-hadoop-1.17.2.jar
      ...
      volumes:
        - name: gcs-key
          secret:
            secretName: {{ $.Values.myGcsSecretHere }}
  serviceAccount: my-service-account
However, in this scenario I’m attempting to see if it’s possible to only use the appropriate service account per the documentation for using service accounts:
Copy code
apiVersion: v1
kind: Pod
metadata:
  name: POD_NAME
  namespace: NAMESPACE_NAME
spec:
  serviceAccountName: KSA_NAME
which according to docs “mounts a static long-lived credential for the service account into the Pod” which I’d imagine would align/set the GOOGLE_APPLICATION_CREDENTIALS environmental variables in lieu of explicitly setting/mounting it now. I was able to set the namespace metadata on the pod-template but obviously serviceAccountName wasn’t explicitly settable in the `FlinkDeployment`:
Copy code
podTemplate:
    apiVersion: v1
    kind: Pod
    metadata:
      name: pod-template
      namespace: my-namespace
Does anyone have any recommendations for this currently?
g
Why did you set the service account on the podTemplate instead of the top level spec? Could that be the issue?
r
Hi @Gyula Fóra, I think it’s just an issue with the sample, it’s set at the top level spec:
Copy code
spec:
  image: {{ $values.flink17Image }}
  flinkVersion: v1_17
  flinkConfiguration:
    ...
  serviceAccount: my-service-account
  podTemplate:
Based on the documentation and looking at the pod, it looks like this gets reflected correctly as
serviceAccountName
. I also have the appropriate nodeSelector set in the deployment as well:
Copy code
spec:
  image: {{ $values.flink17Image }}
  ...
  serviceAccount: my-service-account
    ...
    spec:
      nodeSelectors:
        iam.gke.io/gke-metadata-server-enabled: "true"
As far as I can tell those should mount the appropriate GCS credentials to the pod (such that the gs-related Hadoop libraries can talk to what they need).
I believe that the role also has all of the appropriate roles/permissions that align with this as well:
Copy code
gcloud projects get-iam-policy my-project  \
--flatten="bindings[].members" \
--format='table(bindings.role)' \
--filter="bindings.members:my-service-account"

ROLE
roles/container.admin
roles/iam.serviceAccountAdmin
roles/iam.workloadIdentityUser
roles/storage.admin