Red Hat OpenShift on IBM Cloud: OpenShiftクラスターにコマンド一発でログインする方法
4050 ワード
1. はじめに
Red Hat OpenShift on IBM CloudのOpenShiftクラスターにocコマンドでログインするために、毎回IBM Cloud PortalにログインしてToken情報取得してるわー、Tokenがタイムアウトする度にこの作業するのは面倒だわーっていう人に向けての記事です。APIキーを事前に取得しておけばこういう作業は都度必要なくなります。
2. 事前準備
要はここに記載があります。
APIキーを取得する。このキーは2度と発行されることはないのでメモしておく。
$ ibmcloud iam api-key-create myAPIKey
Creating API key myAPIKey under xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx as [email protected]...
OK
API key myAPIKey was created
Please preserve the API key! It cannot be retrieved after it's created.
ID ApiKey-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Name myAPIKey
Description
Created At 2020-05-02T05:36+0000
API Key <API Key>
Locked false
.bashrcに環境変数に保管し、有効化する
$ vi .bashrc
export APIKEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
alias oclogin="oc login -u apikey -p $APIKEY"
$ . .bashrc
3. はじめてOpenShiftクラスターにログインする際の設定
IBMCloudにAPIKeyを使ってログインし、クラスター構成情報を事前に取得しておく
$ ibmcloud login --apikey $APIKEY
API endpoint: https://cloud.ibm.com
Region: us-south
Authenticating...
OK
Targeted account IBM (yyyyyyyyyyyyyyyyy) <-> zzzzzzz
API endpoint: https://cloud.ibm.com
Region: us-south
User: [email protected]
Account: IBM (yyyyyyyyyyyyyyyyy) <-> zzzzzzz
Resource group: No resource group targeted, use 'ibmcloud target -g RESOURCE_GROUP'
CF API endpoint:
Org:
Space:
$ ibmcloud oc cluster config -c myrokscluster43
OK
The configuration for myrokscluster43 was downloaded successfully.
Added context for myrokscluster43 to the current kubeconfig file.
You can now execute 'kubectl' commands against your cluster. For example, run 'kubectl get nodes'.
4. OpenShiftクラスターへのログイン方法
$ oclogin
Login successful.
You have access to 67 projects, the list has been suppressed. You can list all projects with 'oc projects'
Using project "syasuda".
IBMCloudにAPIKeyを使ってログインし、クラスター構成情報を事前に取得しておく
$ ibmcloud login --apikey $APIKEY
API endpoint: https://cloud.ibm.com
Region: us-south
Authenticating...
OK
Targeted account IBM (yyyyyyyyyyyyyyyyy) <-> zzzzzzz
API endpoint: https://cloud.ibm.com
Region: us-south
User: [email protected]
Account: IBM (yyyyyyyyyyyyyyyyy) <-> zzzzzzz
Resource group: No resource group targeted, use 'ibmcloud target -g RESOURCE_GROUP'
CF API endpoint:
Org:
Space:
$ ibmcloud oc cluster config -c myrokscluster43
OK
The configuration for myrokscluster43 was downloaded successfully.
Added context for myrokscluster43 to the current kubeconfig file.
You can now execute 'kubectl' commands against your cluster. For example, run 'kubectl get nodes'.
$ oclogin
Login successful.
You have access to 67 projects, the list has been suppressed. You can list all projects with 'oc projects'
Using project "syasuda".
Author And Source
この問題について(Red Hat OpenShift on IBM Cloud: OpenShiftクラスターにコマンド一発でログインする方法), 我々は、より多くの情報をここで見つけました https://qiita.com/testnin2/items/78ce4a04728f59da9a02著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .