はじめに
OKEの「クラスタへのアクセス」に沿ってkubectlのコンテキストを設定したあとに、以下のエラーが出た時の対処法
% k get node
E0704 07:52:21.515161 11039 memcache.go:265] "Unhandled Error" err="couldn't get current server API group list: the server has asked for the client to provide credentials"
E0704 07:52:22.126459 11039 memcache.go:265] "Unhandled Error" err="couldn't get current server API group list: the server has asked for the client to provide credentials"
E0704 07:52:22.694498 11039 memcache.go:265] "Unhandled Error" err="couldn't get current server API group list: the server has asked for the client to provide credentials"
E0704 07:52:23.268497 11039 memcache.go:265] "Unhandled Error" err="couldn't get current server API group list: the server has asked for the client to provide credentials"
E0704 07:52:23.857705 11039 memcache.go:265] "Unhandled Error" err="couldn't get current server API group list: the server has asked for the client to provide credentials"
error: You must be logged in to the server (the server has asked for the client to provide credentials)
対処法
私の環境は.oci/configファイルに複数のプロファイルが設定されてるので、OKEがあるテナンシーのプロファイルを環境変数に設定する。
% export OCI_CLI_PROFILE=tenancy-oke
% k get node
NAME STATUS ROLES AGE VERSION
10.0.10.200 Ready node 56d v1.31.1
以降は確認してないが、configファイルが.oci/configではないならOCI_CLI_CONFIG_FILEを設定するなど、OCI CLIの環境変数がデフォルトとは違う場合は環境変数を設定する必要がある(と思う。)