Micro Learning (ENT CLI): Packaging and Deployment

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

Ed Shin - Monday, August 9, 2021
Tags: Engineering

Micro Learning Series: ENT CLI

  1. Enhancing Developer Productivity
  2. Quickstart Environment
  3. Packaging and Deployment
    • Bundling Application Updates for Publication → This lesson
    • Publishing a Micro Frontend and Microservice
    • Frontend Development Lifecycle
  4. Backend Development Lifecycle
  5. Working with Multiple Environments
  6. Micro Frontend & Microservice Generation
  7. Component Repository
  8. Utilities & Diagnostics

What You’ll Learn

In this lesson, we’ll learn how to use ENT CLI to package frontend and backend code changes to your application for deployment in Kubernetes.

  1. Initialize Project
  2. Add Component
  3. Configure Publication System
  4. Push to GitHub
  5. Deploy to Kubernetes
  6. Install Component in Your Application
  7. How It Works

Entando Projects

Today, we’ll dive into the ent prj (or project) command. 

We’ll cover how to create a basic Entando component, package it into a bundle, deploy it to Kubernetes, and use it in your application. These steps are some of the building blocks to create any Entando application.

Entando projects are used to manage the code for frontend and backend components as well as the packaging of those components into bundles for deployment in Kubernetes.

Concept Review

Before we begin, let’s review the Entando concepts we’ll be using today.

An Entando application is made up of components. Every part of an Entando application can be defined as code using components.

Components are the different parts that make up an Entando application like widgets, micro frontends, microservices, pages, content, and templates. You can find the full list of components at dev.entando.org.

Components are packaged and deployed to Kubernetes using bundles.

Prerequisites

Development Environment

First, let’s set up our development environment.

ent check-env develop

ENT simplifies environment setup by checking for required dependencies and automatically installing required Entando tools with a single command.

ENT stores the tools it installs in your $HOME/.entando directory.

Initialize Project

Next, let’s create a directory for our project.

mkdir hello-world

From your project directory (hello-world), initialize the project.

cd hello-world
ent prj init

Press enter to accept the default prompt.

This creates the settings for the project:

  • an .ent directory for configuring the project name and version number.
  • a .gitignore file.

Add Component

Entando uses bundles to package frontend and backend components.

Let’s create a bundle to test deployment to Kubernetes.
The code for this component is taken from dev.entando.org.

From your project directory (hello-world), create a bundle directory.

mkdir bundle

From your bundle directory, create a bundle descriptor: descriptor.yaml

cd bundle
touch descriptor.yaml

The bundle descriptor is where we define our components.

Open descriptor.yaml, and enter the details for your bundle.

code: hello-bundle
description: This is an example of an Entando bundle.
components:
  widgets:
    - widgets/hello-widget.yaml

The bundle descriptor is where we define the components in our bundle.

Here, we’re adding a custom HTML widget that will be located in widgets/hello-widget.yaml.

Define Component

Next, let’s add the widget we just defined (widgets/hello-widget.yaml).

From your bundle directory, create the widgets directory.

mkdir widgets

Then, add the component descriptor: hello-widget.yaml

cd widgets
touch hello-widget.yaml

Open hello-widget.yaml, and enter the details for the widget.

code: hello-widget
titles:
   en: Hello Widget
   it: Ciao Widget
group: free
customUi: 

Hello Widget

customUi is the field we use to add the custom HTML that will be displayed by our widget.

Configure Publication System

To push updates to Kubernetes, we’ll use ENT’s publication system.

From your project directory (hello-world), initialize the publication system.

ent prj pbs-init

REPOSITORY 

Create a GitHub repository, and enter the URL.

Please provide the URL of the publication repository:

Example:

https://github.com/es-entando/hello-world.git
  • Create a new GitHub repository using the default options.
  • (Do not check “Add a README file”.)
  • Use HTTPS.
  • (SSH is not supported)
  • If you have “Two-factor authentication” enabled, you’ll need to generate a “Personal Access Token” and apply it.

USERNAME

Enter your git user name.

Please provide the git user name:

EMAIL

Enter your git email.

Please provide the git email:

CREDENTIALS

Enable credentials cache (y).

Should I enable the credentials cache for the publication of the frontend? (y/n/q)

CACHE EXPIRATION 

Enter: 86400

86,400 seconds == 24 hours

Push to GitHub

Publish the project to your GitHub repository.

ent prj pbs-publish

Deploy to Kubernetes

Create a deployment yaml, and apply it to your Kubernetes cluster.

ent prj deploy

Install Component in Your Application

Install your component so that it’s available to be used in your Entando application.

ent prj install --conflict-strategy=OVERRIDE

Note: This is a time saving step that allows developers to install components via the command line instead of the browser.

How It Works

Below is a recap of the key steps, and a behind the scenes look at how Entando handles Kubernetes deployments.

Step 1: Build

Create an Entando project to define the components for your application in a bundle.

ent prj init

Step 2: Publish

Push the project with your bundled components to your Git repository.

ent prj pbs-publish

Step 3: Deploy

Deploy your bundled components to Kubernetes.

ent prj deploy

How Does Deployment Work Behind the Scenes?

First, ENT generates a deployment yaml for your bundle.

ent prj generate-cr

Specifically, it generates a Kubernetes custom resource (EntandoDeBundle) describing your bundle.

apiVersion: entando.org/v1
kind: EntandoDeBundle
metadata:
  name: hello-bundle
  labels:
    widget: 'true'
    bundle-type: standard-bundle
spec:
  details:
    name: hello-bundle
    description: This is an example of an Entando bundle.
    dist-tags:
      latest: v0.0.1
    versions:
      - v0.0.1
  tags:
    - version: v0.0.1
      tarball: 'https://github.com/es-entando/hello-bundle.git'

Next, ENT applies the deployment yaml to your cluster.

ent prj generate-cr | ent kubectl apply -n entando -f -

This creates the EntandoDeBundle custom resource in your cluster.

The Entando Operator listens to events containing Entando custom resources, processes your EntandoDeBundle, downloads it from the specified Git repository, and makes it available to your application from the Entando Component Repository.

Step 4: Install

Install your components to make them available for use in your Entando application.

ent prj install

See It In Action

Let’s see our component in action.

  1. Go to App Builder in your browser.
  2. Publish a page.
  3. Click “Repository” in the left menu to install your bundle.
  4. Drag and drop the component on a page.

If you’re new to the Entando platform, we’ll be releasing a blog post in the coming weeks covering all of the fundamentals new developers will need to get started with Entando.

What’s Next?

In this lesson, we learned how to deploy a basic component for our application with a few, simple commands.

In the next lesson, we’ll cover how ENT simplifies Kubernetes deployments for frontend developers and will cover how to deploy a simple Create React App as a micro frontend.

Additional Resources

https://www.entando.com/
https://dev.entando.org/

Entando is an application composition platform for building enterprise web apps on Kubernetes.

Our platform integrates trusted open source technologies and extends their functionality to give you a cohesive and streamlined developer experience with easy-to-use patterns. From deploying on Kubernetes to creating modular backend and frontend architectures using your current technologies, Entando helps you at every layer of the stack. 

Entando is open source with available enterprise support and services. Begin developing on the platform today, and get a quote to see how our team can help your enterprise build better apps, sites, and portals--faster.

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.