Preparing to run component or management API commands
Before you run component API commands, retrieve the authentication token and download the CA certificate for your cluster.
- Install the Kubernetes command line (kubectl). See Accessing your cluster from the kubectl CLI.
- (Optional) Install the IBM Cloud Private command line interface (CLI) and log in to your cluster. See Installing the IBM Cloud Private CLI.
-
Retrieve the authentication tokens. You can use the IBM Cloud Private CLI or run curl commands.
-
To use the IBM Cloud Private CLI, run the following command:
cloudctl tokensThe access token and ID token display:
Access token: Bearer jHVcaGjSuWEXGUPeH8WVnoqUyex5kJDlCl4DnZMQN2WseErIoVWDW5cY1Ikvoqdhxkou4bvHYJM77U2FZf2aKbo3h2FeH1OJpaEwj8rpGiDLusaXc54rJbnefbjAv4OECvk2tg9gIeJAx6DZlmlknDXB6zM0bkGtqayP94L8gSXtzPoW6miuoR8dFD5Du63OjVBVZljw5ajOWBtvYzR1ttamH4SRMflEVWC3AxcBhtkadMCAsdWFi1KRGUoVM5k0TkuPFP7AAX8vryEpakeVqBQfbR2m0OlRBTRbkNJoacPp7AesyGLBjPVElQs01FCz3xhMNHkQJAFT0T0xhbhDj3DgenAjJd5eSNWxdTLSfhOaQClfx6BLq5Z0e8S0Uhp2NSWqNVkU49fHuTHW2UwxG84nvwpz4ZxYJaP3m6DZv5lTwKcbQkB3w9cLr8pgUaC94IZ9gJhYvprMR1NKz4etFgNPmhA4T1NS8NVVgMHBYOptv1qAdKSNzZ2l6V23h2BquFpVQ2MqE6Lcx0N0j1ZoRVuYo1qTrIkOpEBNbn94b3PHNJMVO2v1NqV85G6uNgPdvv85eneHItsIfUc5yXMeYLXZ017trlhxj43lLVsEyUaM7S5dfykayqVgsaJ9faHYz6F14oRKJCbwhg7y4ybxxxR5KtCKihXgf5QJJXYmsrimudD8KXMVsQKEyHFETzVR7eNMRZvcohFKBPwZdIntkcpLygMmZK4Gaz6pD3t4PTkVXKAWQsPTepJ57FfP9kNkPU6BDxf9X7skBrsRFD3ldCdFUMi0lxOmkBakmXHLODRmmZl73bKuIKFT7lZAXY0Rn3d5NzXcyzVODRNXnMyRW9c2NLvhYQe0ltdR8dIDtRbsh1AQEC5P1eI9XGhBLcAqhU0oBe7k5rMzQXL44TtYMo9NccsgMjNsfToyCqezocgfmLYjqZOUnRbBG7ymn5FJECzOd8X1KagaXqzlSmDtD7cRzZms3iA8FE85cWaK ID token: eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdF9oYXNoIjoiN2p2MmFjeGtucHVpcXo1MXRna2giLCJyZWFsbU5hbWUiOiJjdXN0b21SZWFsbSIsInVuaXF1ZVNlY3VyaXR5TmFtZSI6ImFkbWluIiwiaXNzIjoiaHR0cHM6Ly9teWNsdXN0ZXIuaWNwOjk0NDMvb2lkYy9lbmRwb2ludC9PUCIsImF1ZCI6ImY4YjVjZGE1YTgzZjg4NjZhOTIxMTQ2MGU5YTk4YzQ4IiwiZXhwIjoxNTA4MjYwODc4LCJpYXQiOjE1MDgyNjA4NzgsInN1YiI6ImFkbWluIn0.IrLm1R9a4GBiTG0wYR1JhGqT4HSArN3gPHhPPTC4ZuS46LulRQCBksxh9I59uT4pYcqhd0qJ_xp9Ys1H8xLsq1zKSI0W2KAzuFkIbXQiK9Q6_Z3oQOHE8XMG7Xfb0R8B4TgbTjQ3XWkEkXsyeliXk0l7mqlVIgTFbXx8nqcoFbXhmH7ZQukj73lMQ0AyKKPpJktWtPCLpugtiTA0nkKUodncvHdSw43bmVQuGsQ_kRhhr8Ka8y_olYcBtYUSAKqdwiGPu6O0Qk-57FCiUmX4W9pjLRAR9EmILY9RqJAsH5kE11kYHPTO2fu-B6omzw2eKxhjZYHMIPmxUciiBRB9PwThese tokens are stored in the
/<user_folder>/.bluemix/plugins/icp/config.jsonfile while you are logged in to the CLI, where<user_folder>is the path to your user directory, such as/Users/my_usernameon macOS. -
To use curl, run the following command, where
<cluster_lb_address>is the IP address that you need to access your IBM Cloud Private management console:curl -k -H "Content-Type: application/x-www-form-urlencoded;charset=UTF-8" -d "grant_type=password&username=admin&password=admin&scope=openid" https://<cluster_lb_address>:8443/idprovider/v1/auth/identitytokenThe command returns an
access_token,refresh_token, andid_token, as shown in the following example:"refresh_token":"kxr337rAXlA0dm8Gx3e7DjJYOXOfrunKM4znvSGhQGjWNvvh05", "id_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdF9oYXNoIjoiZm9ldTgxZzJrOTVyaXNiajJrcHoiLCJyZWFsbU5hbWUiOiJjdXN0b21SZWFsbSIsInVuaXF1ZVNlY3VyaXR5TmFtZSI6ImFkbWluIiwiaXNzIjoiaHR0cHM6Ly9teWNsdXN0ZXIuaWNwOjk0NDMvb2lkYy9lbmRwb2ludC9PUCIsImF1ZCI6ImE2OWVlNjM5MjZlMDA0MmYzZWVlNGYyOTE4MDViNjMyIiwiZXhwIjoxNTA3OTgzODIxLCJpYXQiOjE1MDc5ODM4MjEsInN1YiI6ImFkbWluIn0.ZvE0eApr6SiAYbx7zSicEjdtWsUL8dq4UdttZsQpoB7eWFFioIC1R52ub2jlrwQqjITfHDtc7eUyK0QXOHIalXheX61DoAseTVxi2fELZqG_weKPe4LOeo4LENsoRx8P_Jfv8iQh5zmsrKxBeZCn5gWre5LPOE34CF8F-b0RJO2axEY2m0KOiXOQGD4ltYGNzMdzp5LeaGENTOUM2ayrvpHFBhLxAtF0RpK5NuyNvlKO3t33DPGSWOUy_q19fasM9ZN6Z2R73fRHtuC9lMDooQKJdAtqwcJ4Y2T7RyzJEp9pvarcGUDr5X3YJ0dI-XJlT-fJJ6rHxddHQRvtCAGUvw"}
-
-
Store the authentication token in a variable. You can access IBM Cloud Private APIs, including Kubernetes and Heapster, by specifying an authentication token in the request header. Run the following command, where
<ID token>is the displayed ID token:export ID_TOKEN=<ID token> -
Store the access token in a variable. You can access IBM Cloud Private user management APIs by specifying the access token in the request header. Run the following command, where
<Access token>is the following displayed access token:export ACCESS_TOKEN=<Access token> -
Obtain a copy of the CA certificate for your cluster.
-
If you can access the boot node, the CA certificate file is
/<installation_directory>/cluster/etc/docker/certs.d/mycluster.icp:8500/ca.crt -
To use the IBM Cloud Private CLI:
- Ensure that you have logged in with cloudctl as required. This places the cluster's certificates into the cloudctl configuration directory.
-
Confirm that the authentication certificate is available. Run the following command, where
<user_folder>is the path to your user home directory, such as/Users/my_usernameon macOS, and<cluster>is your cluster name. This file path is the<certificate_path>variable that you use in a later step:ls <user_folder>/.cloudctl/clusters/<cluster_name>The
ca.crtfile displays, as it is in the following output:ca.pem cert.pem key.pem kube-config kube-config.bat
-