Micro Learning (ENT CLI): Working With Multiple Environments

This micro learning series will help you get familiar with Entando CLI (ENT) which simplifies building and deploying applications for Kubernetes.

Edward Shin - Thursday, September 9, 2021
Tags: Engineering

Micro Learning Series: ENT CLI

  1. Enhancing Developer Productivity
  2. Quickstart Environment
  3. Packaging and Deployment
  4. Working With Multiple Environments → This lesson
  5. Component Repository
  6. Utilities & Diagnostics

What You’ll Learn

In this lesson, we’ll learn how ENT CLI makes it easy to work with multiple Entando applications across one or more Kubernetes clusters.

This is useful when working with multiple clusters for development and when developing multiple Entando applications for different clients or stakeholders.

ENT Profiles

Today, we’ll explore the ent profile command.

Syntax:
 - ent profile {command} ...

Commands:
  - use                  selects the profile that ent should use
  - print-first-use-readme   prints the first-use readme
  - new                  create a new profile
  - set                  set the EntandoApp and namespace
  - delete               delete the given profile
  - list                 prints a list of the available profiles
  - link                 links the current profile to a kube context

Profiles allow you to switch between Kubernetes clusters, namespaces, contexts (i.e., cluster, user, namespace), kubeconfig files, and Entando applications with a single command.

ent profile use my_profile

You can use profiles to quickly change between environments to deploy updates to one or more clusters, namespaces or applications.

# Deploy frontend components
ent prj fe-build
ent prj fe-push

# Deploy backend components
ent prj be-build
ent prj be-push

List Profiles

We can use the list command to look at our current profiles. If you’ve installed the quickstart environment, you’ll see that ENT CLI automatically created a profile (“qs-entando”).

$ ent profile list
qs-entando

Entando stores these profiles in your .entando folder:

$HOME/.entando/profiles/qs-entando/w/.cfg

ENTANDO_APPNAME=quickstart
THIS_PROFILE=qs-entando
DESIGNATED_KUBECONFIG=/Users/ed/.entando/ent/quickstart/cli/v6.3.2/w/.kubeconf
DESIGNATED_VM=entando
DESIGNATED_VM_NAMESPACE=entando
ENTANDO_NAMESPACE=entando
LATEST_URL_SCHEME=http

ENT CLI uses the configurations in your profile to designate the:

  1. Cluster (DESIGNATED_KUBECONFIG)
  2. Namespace (ENTANDO_NAMESPACE)
  3. Entando application (ENTANDO_APPNAME)

The cluster is defined in the kubeconfig file:

$HOME/.entando/ent/quickstart/cli/v6.3.2/w/.kubeconf

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: ...
    server: https://192.168.64.40:6443
  name: default
contexts:
- context:
    cluster: default
    user: default
  name: default
current-context: default
kind: Config
preferences: {}
users:
- name: default
  user:
    client-certificate-data: ...
    client-key-data: ...

And we can use the attach- and detach- commands to configure kubeconfig files, kubernetes contexts, and Linux VMs when setting up a local Kubernetes cluster for development.

# Attach current profile to a kubeconfig file
ent attach-kubeconfig {file}
ent detach-kubeconfig

# Attach current profile to a local Kubernetes cluster running in a VM
ent attach-vm {vm-name}
ent detach-vm

Create New Profiles

New profiles can be created manually.

$ ent pro new
Please provide the profile name: test
Please provide the EntandoApp name (test): TestEntandoApp
Please provide the default namespace (test): test
➤ [I] | 2021-09-02 22-55-11 | Application profile "test" created
➤ [I] | 2021-09-02 22-55-12 | Application profile "test" activated

And we can use the list command to see the available profiles.

$ ent profile list
qs-entando
test

We can use the “set” command to configure the Entando application and namespace for a given profile.

$ ent profile set
Please provide the EntandoApp name: EntandoApp2
Please provide the default namespace: namespace2

ENT Config

Configurations go hand-in-hand with profiles. Profiles are a set of configurations.

Let’s take a look at the ent config command.

$ ent config --help

> Arguments:
    --default             selects the default ent configuration
    --print               print the configuration (default)
    --edit                edits the configuration
    --set                 sets a specific configuration parameter
    --get                 gets a specific configuration parameter

If we print the configurations for our quickstart environment profile (qs-entando), ENT CLI will display all of the configurations for that profile.

$ ent config --print
➤ [I] | 2021-09-03 08-51-01 | Configuration of the profile "qs-entando"
ENTANDO_APPNAME=quickstart
DESIGNATED_KUBECONFIG=/Users/ed/.entando/ent/quickstart/cli/v6.3.2/w/.kubeconf
DESIGNATED_VM=entando
DESIGNATED_VM_NAMESPACE=entando
ENTANDO_NAMESPACE=entando
LATEST_URL_SCHEME=http
THIS_PROFILE=qs-entando

Profiles automatically save your configurations so you only have to specify the cluster, namespace, and other configurations a single time when working with ENT profiles.

Current Terminal Session

If you want to use a specific profile for the current terminal session, ENT CLI also includes a “source” command.

ent profile use my-profile	⬅ globally

source ent profile use my-profile	⬅ only for the current tty

. ent profile use my-profile	⬅ shorthand for source

What’s Next?

In this lesson, we learned how ENT profiles make it easy to work on multiple Entando applications across different environments using a single command.

In the next lesson, we’ll cover how ENT helps you to manage your components in the Entando Component Repository.

The Entando Component Repository is how we deploy self-contained frontend and backend components to our application, make updates to our application, and share reusable components across development teams.

Additional Resources

https://www.entando.com/

https://dev.entando.org/
 

White_Paper_cover.png

Learn How To Create Better Apps, Portals, & Websites--Faster.

This white paper outlines how your organization can accelerate UX innovation by developing with micro frontends on Kubernetes, as well as how a micro frontend platform can help you execute this methodology more effectively.