Wednesday, October 26, 2022

Installing LENS // The Kubernetes Platform IDE

Installing LENS // The Kubernetes IDE

  • Download and install the latest version of LENS // The Kubernetes IDE . 
  • Ensure the cluster "kubeconfig" configuration settings have been previously downloaded following the steps from Installing IBM Cloud CLI and Kubectl.
  • All the cluster configurations should be stored in the KUBECONFIG file (e.g., C:\Users\rubens\.kube\config).

Running LENS

  • Prior to running, LENS ensures you have previously configured the "Kube" cluster configurations as LENS will use those configs and the embedded certificates to authenticate itself to the different clusters.
  • If issues with Authorization failed, you may have to update the IBM cloud bluemix certificate files (e.g.,  C:/Users/rubens/.bluemix/plugins/container-service/clusters/...) with the latest tokens.  In order to do that you need to download all the previous cluster configurations again.
  • LENS WILL USE THE KUBECONFIG FILE LOCATED AT THE "KUBECONFIG" ENVIRONMENT VARIABLE FOLDER.  MAKE SURE YOU HAVE THE LATEST/UPDATED KUBECONFIG FILES/TOKENS IN THE KUBECONFIG FOLDER (E.G. C:\Users\rubens\.kube\config).  IF NOT YOU MAY RUN INTO AUTHORIZATION ERRORS.

Lens Authorization Errors

If you run into Authorization Errors when attempting to connect to a cluster within LENS follow these steps:

  1. Ensure all previous steps have been followed and that you are running the latest version of IBM cloud, Kubernetes and IBM cloud Kubernetes service plugins
  2. Ensure you have the KUBECONFIG environment variable correctly configured in your environment.  See previous notes.
  3. Ensure that prior to running LENS you are currently logged in to IBM Cloud.
  4. Ensure you have the latest updated configuration/tokens in your KUBECONFIG file.  You can run the previous steps to download the Cluster Configuration.  If you are on Linux you may consider using a script similar to the one below:

$ cat $HOME/bin/kubetoken.sh
#!/bin/sh -ahu
##
##       author : Rubens Gomes <Rubens.S.Gomes@gmail.com>
##
## written date : October 26, 2022
##
##      purpose : This script is used to update the IBM Cloud Cluster Configuration
##                tokens and settings in the KUBECONFIG ($HOME/.kube/config) file.
##

# local path to IBM Cloud tools
IBMCLOUD="ADD PATH TO IBM CLOUD CLI TOOLS"

# define a clean UNIX binary PATH
PATH=
PATH=${PATH}:/bin
PATH=${PATH}:/sbin
PATH=${PATH}:/usr/bin
PATH=${PATH}:/usr/sbin
PATH=${PATH}:/usr/local/bin
PATH=${PATH}:${IBMCLOUD}/bin
export PATH

# define a clean UNIX LD_LIBRARY_PATH
LD_LIBRARY_PATH=
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/lib
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib
export LD_LIBRARY_PATH

# logging into IBMCloud using Single Sign On
\ibmcloud login --sso

if [ ${?} -ne 0 ]
then
 echo "Failed to login to IBM Cloud" 1>&2
 exit 1
fi

echo "-------------------------------------------------------------------"
echo "Downloading Cluster Configuration..."
\ibmcloud ks cluster config --cluster "<cluster ID>"

if [ ${?} -ne 0 ]
then
 echo "Failed to download IBM Cloud CLUSTER Configuration" 1>&2
 exit 2
fi

echo "Done"
exit 0