In this blog, we learn to link an OpenShift K8S Context to a local ENT CLI profile.
Sometimes we need to work with different environments for a given project or to switch between a few ones. It could also help a team to separate the responsibilities on different steps of a process such as integration, QE testing, and pre-production. It can also be a game-changer to be able to switch between different versions of a given application. As in such scenarios, separate environments become a requirement. Later, we can link those environments to several ENT profiles and use them accordingly.
To link an OpenShift K8S Context to a local ENT CLI profile, you’ll need the following installed on your computer:
OpenShift CLI (OC) is easy to install as it’s available over Github. For Mac M1 users, in case there’s an issue installing through the zip file. Please install it using homebrew.
(If we have the x86 version of brew installed then we just need to type the command:
brew install openshift-cli
else, we would need to prefix it with
arch -x86_64
To know more, check this Github gist.)
arch -x86_64 brew install openshift-cli
The ENT CLI is an easy installation too. For starters, please navigate to our docs page and install it with the mentioned steps.
To check, if OC was installed correctly, on our terminal, we can type:
oc version
And to check, if ENT CLI is installed, we can type:
ent help
Once we’re set up, we navigate to the OpenShift Web Console for our cluster. It’ll be something like this:
https://<base_url>:<port>/console/project/<project_name>/overview
We log in here, with our username and password. Once it’s done, we’ll be navigated to the dashboard. On the top right corner, we click on our username, and click on “Copy Login Command”.
Next, we open our terminal and paste the command that we just copied. At this point, we have configured our .kube profile with the Kube context. To check that, we run the below command on our terminal:
Open .kube/config
This will open up a configuration file, that’ll contain Cluster, Context, and User information, with their server name, namespace, and other credentials. In this, we’ll find the login command URL that we copied earlier from the Open Shift Web Console.
apiVersion: v1 clusters: - context: cluster: mycluster:8443 namespace: mynamespace user: myuser name: mynamespace/mycluster:8443/myuser current-context: mynamespace/mycluster:8443/myuser kind: Config preferences: {}
We can also try an alternative way, by typing in the below command on our terminal:
ent list-kubectx
And our output would be like
mynamespace/mycluster:8443/myuser%
Pro Tip:
To have a more detailed overview of this command, we can try adding parameters by the end of the command, for example:
ent list-kubectx sales-demo
Through this, only the lines containing the parameter “sales-demo” (only if it exists) would get displayed. It is like a sub-string match!
Now, to link this configuration to an ENT Profile, we’ll need to follow the below steps:
ent pro new [profileName] [EntandoAppName] [namespace]
For exampleent pro new rd-sohini quickstart release-e6-3-2
kubectl get -n entando EntandoApp
ent pro link [contextName]
Through this command, we instruct ent how to connect to the Kube containing the EntandoApp.ent pro list
ent pro use [profileName]
ent pro use rd-sohini ➤ [I] | 2022-01-11 09-46-23 | Current profile info: - PROFILE: rd-sohini - APPNAME: quickstart - APPVER: - NAMESPACE: mynamespace - K8S CONTEXT: mycontext
For the final step, when we have linked our profile to the K8s context, we check if our profile is working right. To do that, we type the below command on our terminal:
ent pod list
This lists all the pods, displaying their status, the number of restarts, and their age. That’s all.
If you’re interested in learning more about composable applications, you can check out this blog.