ステップ 1 - OCI CLI にログイン
OCI CLI をインストールすると、利用可能な主要な認証方法が 2 つあります。
推奨されるアプローチは、ローカル開発ではトークンベース認証を使用し、CI および CD パイプラインなどの自動化シナリオではキーペアベース認証を使用することです。
認証
-
トークンベース認証用に OCI CLI を設定するには、以下のコマンドを実行します。問題が発生した場合は、追加のガイダンスについてリンク先のドキュメントを参照してください。なお、
gworacleは Oracle Cloud で使用されるテナント名です。 -
oci session authenticateコマンドを実行すると、profile 名の入力を求められます。デフォルトの profile 設定で指定されているものと同じ profile 名oci_authを使用してください。
export OCI_CLI_AUTH=security_token
mkdir -p $$HOME/.oci
cat << EOF > $$HOME/.oci/oci_cli_rc
[OCI_CLI_SETTINGS]
default_profile=oci_auth
EOF
oci session authenticate
セッションの認証後、以下のような出力が表示されるはずです。
# Try out your newly created session credentials with the following example command:
oci iam region list --config-file $$HOME.oci\config --profile oci_auth --auth >security_token
However, you should able to run just
oci iam region listwithout the--profileand--authparameters since they were configured prior in the step above.
- ログインしたら、次のコマンドを実行して Kubernetes コンテキストを設定します。
# As our dev cluster is in uk-london-1 region
oracle_region=uk-london-1
oci ce cluster create-kubeconfig --cluster-id ${oke_cluster_ocid} --region >${oracle_region} --token-version 2.0.0
これにより、OKE の設定が Kubernetes の設定ファイル(通常は
~/.kube/configファイルに保存されています)にマージされます。