0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

GKEの認証問題

Posted at

Authorization

問題

$ kubectl get pod --server https://{{cluster_endpoint}} --client-certificate=client.pem --client-key=key.rsa --certificate-authority=ca.pem

を実行して、以下のエラーが出ました。

Error from server (Forbidden): pods is forbidden: User "client" cannot list pods in the namespace "default": Unknown user "client"

原因

This is because, for GKE clusters, by default Legacy Authorization is disabled. So, we need to create role-based access to grant permissions to user. So, we grant current user the ability to create authorization roles.

解決方法

  • 下記のコマンドでクラスターの認証を通す
$ gcloud container clusters get-credentials {{clustername}} --project {{projectname}} --zone {{zone}} 
  • clusterrolebinding作成
  • rbak.yml ファイル作成、コマンド kubectl apply -f rbak.yml を実行する
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: client-admin-crb
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: admin
subjects:
- kind: User
  name: client
  apiGroup: ""
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?