メイン コンテンツにスキップ

ステップ 1 - OCI CLI にログイン

OCI CLI をインストールすると、利用可能な主要な認証方法が 2 つあります。

  • キーペアベース認証

    • CI および CD パイプラインなどの自動化シナリオに推奨
    • ドキュメント
  • トークンベース認証

推奨されるアプローチは、ローカル開発ではトークンベース認証を使用し、CI および CD パイプラインなどの自動化シナリオではキーペアベース認証を使用することです。

認証

  1. トークンベース認証用に OCI CLI を設定するには、以下のコマンドを実行します。問題が発生した場合は、追加のガイダンスについてリンク先のドキュメントを参照してください。なお、gworacle は Oracle Cloud で使用されるテナント名です。

  2. 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 list without the --profile and --auth parameters since they were configured prior in the step above.

  1. ログインしたら、次のコマンドを実行して 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 ファイルに保存されています)にマージされます。