Skip to content

kbatch service account permissions #37

@iameskild

Description

@iameskild

After applying the helm chart for the kbatch-proxy, I ran into an issue where the kbatch service account was Forbidden from making the desired Kubernetes API calls.

Version info:

  • kbatch - 0.3.1
  • kbatch-proxy - 0.3.1 helm-chart

Logs from the kbatch-proxy pod after kbatch job list -o table:

HTTP response body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"serviceaccounts is forbidden: User \"system:serviceaccount:dev:kbatch-kbatch-proxy\" cannot list resource \"serviceaccounts\" in API group \"\" in the namespace \"eskild\"","reason":"Forbidden","details":{"kind":"serviceaccounts"},"code":403}

I was able to get around this by creating a ClusterRole and ClusterRoleBinding for the aforementioned service account.

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: kbatch-clusterrole
rules:
- apiGroups: ["batch", ""]
  resources: ["*"]
  verbs: ["get", "watch", "list", "patch", "create"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: kbatch-clusterrolebinding
  namespace: dev
subjects:
- kind: ServiceAccount
  name: kbatch-kbatch-proxy
  namespace: dev
  apiGroup: ""
roleRef:
  kind: ClusterRole
  name: kbatch-clusterrole
  apiGroup: rbac.authorization.k8s.io

These permissions will likely need to be tightened or modified but that said, with these permissions I was able to submit and list kbatch jobs.

I guess I have two remaining questions:

  • Is it possible that I missed something in the kbatch/kbatch-proxy setup that might have led me to this issue?
  • If we believe this is indeed an issue, I'd be happy to submit a PR to the helm-chart repo to add the ClusterRole and ClusterRoleBinding. Is this something you are amenable to?

Thanks a lot for all your great work :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions