question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GCE - K8s 1.8 - pods is forbidden - Cannot list pods - Unknown user "system:serviceaccount:default:default"

See original GitHub issue

I used the mongo-k8s-sidecar for somewhilte and everythign worked fine.

today i created a new cluster with 1.8.7-gke.1 and deployed mongo db with the sicdecar. As a result the pods don’t get connected (see below) when i recreate the cluster with k8s 1.7.12-gke.1 everything works fine.

From sidecar log when faliing: message: ‘pods is forbidden: User “system:serviceaccount:default:default” cannot list pods at the cluster scope: Unknown user “system:serviceaccount:default:default”’,

mongo-sidecar | Feb 28, 2018, 11:04:19 AM | status: ‘Failure’, mongo-sidecar | Feb 28, 2018, 11:04:19 AM | metadata: {}, mongo-sidecar | Feb 28, 2018, 11:04:19 AM | apiVersion: ‘v1’, mongo-sidecar | Feb 28, 2018, 11:04:19 AM | { kind: ‘Status’, mongo-sidecar | Feb 28, 2018, 11:04:19 AM | message: mongo-sidecar | Feb 28, 2018, 11:04:19 AM | Error in workloop { [Error: [object Object]] mongo-sidecar | Feb 28, 2018, 11:04:14 AM | statusCode: 403 } mongo-sidecar | Feb 28, 2018, 11:04:14 AM | code: 403 }, mongo-sidecar | Feb 28, 2018, 11:04:14 AM | details: { kind: ‘pods’ }, mongo-sidecar | Feb 28, 2018, 11:04:14 AM | reason: ‘Forbidden’,

any hints what has changed in gce permission system? Something i need to configure?

configuration

---
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: fast
provisioner: kubernetes.io/gce-pd
parameters:
  type: pd-ssd
---
apiVersion: v1
kind: Service
metadata:
  name: mongo-lp
  labels:
    name: mongo
spec:
  ports:
  - port: 27017
    targetPort: 27017
  clusterIP: None
  selector:
    role: mongo-lp
---
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
  name: mongo-lp-statefulset
spec:
  serviceName: "mongo"
  replicas: 3
  template:
    metadata:
      labels:
        role: mongo-lp
        environment: test
    spec:
      terminationGracePeriodSeconds: 10
      containers:
        - name: mongo
          image: mongo:3.4.9
          command:
            - mongod
            - "--replSet"
            - rs0
            - "--smallfiles"
            - "--noprealloc"
          ports:
            - containerPort: 27017
          volumeMounts:
            - name: mongo-persistent-storage-lp
              mountPath: /data/db
        - name: mongo-sidecar
          image: cvallance/mongo-k8s-sidecar
          env:
            - name: MONGO_SIDECAR_POD_LABELS
              value: "role=mongo-lp,environment=test"
  volumeClaimTemplates:
  - metadata:
      name: mongo-persistent-storage-lp
      annotations:
        volume.beta.kubernetes.io/storage-class: "fast"
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 32Gi

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

30reactions
westonpacecommented, Mar 3, 2018

One simple fix is to create the following role binding:

apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: default-view
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: view
subjects:
  - kind: ServiceAccount
    name: default
    namespace: default

This will grant the default service account view permissions. A more secure approach would probably be to create a new service account, grant it the view permissions, and then assign that service account to the sidecar.

0reactions
mauri870commented, Nov 10, 2018

@grohan2002 By now you probably have figured out, but for the sake of completeness then yes, you need to restart the pods for this to take effect.

Read more comments on GitHub >

github_iconTop Results From Across the Web

k8s gce1.8.7 - pods is forbidden - Unknown user system ...
now when i deploy the same konfiguration to 1.8.7-gke.1 resultes in missing permissions to list pods see below. I don't get the point...
Read more >
Error: pods is forbidden: User "system:serviceaccount ... - GitLab
Hi, I came up to this error when trying to deploy my application to my Kubernetes cluster (Amazon EKS). The problem arises by...
Read more >
Troubleshooting | Google Kubernetes Engine (GKE)
PodUnschedulable indicates that your Pod cannot be scheduled because of insufficient resources or some configuration error. If you have configured your GKE ...
Read more >
GKE authentication and authorization between Cloud IAM and ...
Learn how users are created with GKE & how Google Cloud IAM and RBAC work ... pods is forbidden: User "system:serviceaccount:default:mysa" cannot list...
Read more >
GKE - HPA scaling based on custom metrics. - Google Groups
to Kubernetes user discussion and Q&A. I am working on a use case where I have to scale my pods based on custom...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found