Packaging and Deployment

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.

Ed Shin - lundi 9 août 2021
Tags: Technical

ENT CLI Series

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

What You’ll Learn

In this blog, we’ll learn how to use ENT CLI to package frontend and backend updates to your application for deployment to Kubernetes.

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 the source directory where you manage your code for frontend and backend "components". Components are packaged into "bundles" for deployment to Kubernetes.

Concepts

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 as "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.

Create Bundle

Entando deploys updates to Kubernetes using "bundles".

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

mkdir bundle

From your bundle directory, create a bundle descriptor.

cd bundle

touch descriptor.yaml

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.

Add Component

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

From your bundle directory, create the widgets directory.

mkdir widgets

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.

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.

Recap

Let's review the key steps on how Entando packages application updates for deployment to Kubernetes.

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

What’s Next?

In the next lesson, we’ll cover how ENT simplifies working with multiple Entando applications across one or more Kubernetes clusters.

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

CIO Alert - There is an Application Composition Platform in your Future

By Massimo Pezzini, Independent IT Advisor

Téléchargez

White-Paper-Pattern_mockup 3.png