Working With Multiple Environments

This blog series will help you get familiar with Entando's CLI (ENT) which simplifies building and deploying applications for Kubernetes. ENT CLI is your starting point and guide to all development on the Entando platform.

Edward Shin - Donnerstag, 9. September 2021
Tags: Developer Topics

ENT CLI Series

  1. Simplify App Development on Kubernetes
  2. Quickstart Environment
  3. Packaging and Deployment
  4. Working With Multiple Environments → This lesson
  5. Exporting Components
  6. Utilities & Diagnostics

What You’ll Learn

In this lesson, we’ll learn how ENT CLI creates profiles to make 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.

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.

View Profiles

The list command displays the available profiles.

$ ent profile list
qs-entando

If you’ve installed the quickstart environment, you'll see the profile that ENT automatically created for you (qs-entando).

Profile Configuration

ENT stores the configuration for your profiles in the $HOME/.entando folder:

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

# The name of your Entando application
ENTANDO_APPNAME=quickstart
THIS_PROFILE=qs-entando
# kubeconfig of your Kubernetes cluster
DESIGNATED_KUBECONFIG=/Users/ed/.entando/ent/quickstart/cli/v6.3.2/w/.kubeconf
DESIGNATED_VM=entando
DESIGNATED_VM_NAMESPACE=entando
# Kubernetes namespace where your Entando application is installed
ENTANDO_NAMESPACE=entando
LATEST_URL_SCHEME=http

Here's the contents of the kubeconfig file referenced above.

$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: ...

Configure Profiles

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

ENT also provides convenience commands to attach and detach a kubernetes cluster, kubernetes context or VM.

# 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 Profiles

We can use the new command to create new profiles.

$ 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 the list command to see our newly added profile.

$ ent profile list
qs-entando
test

If we need to change the name of our Entando application or Kubernetes namsepace later on, ENT makes it easy to do that using the profile set command.

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

Switch Profiles

Once you've set up your profiles, you can easily work across different clusters and Entando applications with the use command.

ent profile use my_profile

Simply change profiles, and deploy updates to your cluster as you normally would with the ent prj commands.

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

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

Use Profiles in the Current Terminal Session

If you want to use a specific profile for the current terminal session, ENT 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 the next lesson, we’ll cover how ENT helps you export individual components or even your entire Entando application for migration to other environments.

Additional Resources

https://www.entando.com/

https://dev.entando.org/
 

Was ist eine Application Composition Platform?

Finden Sie heraus, wie eine Application Composition Platform Ihnen helfen kann.

Schnell, anpassbar, einfach skalierbar: Das sind die drei Hauptmerkmale, die Ihre Webanwendung haben muss, wenn sie einen echten Wettbewerbsvorteil für Ihr Unternehmen darstellen soll

herunterladen
Entando_WhitePaper.png