xebialabs / the-new-xebialabs-stack-workshop

Workshop about the new XebiaLabs stack

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Introduction

The goal of this workshop is to show you how XL Deploy and XL Release, as well as the XL CLI, can be used for cloud and container use cases.

The command in this workshop are macOS/Linux commands. If you run Windows, use xlw.bat instead of ./xlw.

Before you start

  • Make sure Docker is running
  • Make sure Kubernetes is running for your Docker platform

For macOS

For Windows

Exercise 1: Run the XL CLI

XL Deploy and XL Release have a user interface and a command line interface. Let's start by experimenting with the XL CLI.

You don't need to install it. This repository contains a wrapper that will automatically download and run it.

Go to the scratch directory in this repository and check which version of the XL CLI binary you're running:

$ cd scratch
$ ./xlw version

The output should look something like this:

CLI version:             9.0.0-alpha.1
Git version:             8.7.0-alpha.9-3-g6da31a0
API version XL Deploy:   xl-deploy/v1
API version XL Release:  xl-release/v1
Git commit:              6da31a072cd5ce6bfc412d99dfe6138e005d2611
Build date:              2019-05-06T11:17:39.090Z
GO version:              go1.11
OS/Arch:                 darwin/amd64

Exercise 2: Start XL Deploy and XL Release

XL Deploy and XL Release are delivered as Docker images. To start them, we'll need a Docker Compose file.

Luckily the XL CLI's "blueprint" functionality can create those for us. Start the blueprint instantiation process.

$ ./xlw blueprint

You should see a list that looks like this:

? Choose a blueprint:  [Use arrows to move, type to filter]
> aws/datalake
  aws/microservice-ecommerce
  aws/monolith
  aws/monolith-terraform
  azure/basic-aks-cluster
  devsecops/security-scanning
  docker/application

Scroll down to xl-devops-platform and press the Enter key to select that blueprint. The blueprint will ask you a number of questions. Accept the defaults by pressing the Enter key another 8 times:

? Choose a blueprint: xl-devops-platform
? Do you want to install XL Deploy? Yes
? Host port for XL Deploy: 4516
? Do you want to install XL Release? Yes
? Host port for XL Release: 5516
? Do you want to use JetPack or XL Enterprise: JetPack
? Select the version of XL you want to use: 8.6.1
? Do you want to be able to deploy to your local Docker instance? Yes
? Confirm to generate blueprint files? Yes

Have a look at the files that were generated by this blueprint:

  • docker/docker-compose.yml is the Docker Compose that we'll want to run
  • docker/data/configure-xl-devops-platform.yaml is the XL YAML file that describes some initial setup for XL Release
  • xebialabs/config.yaml is a configuration file for the XL CLI that makes it refer to the files just generated.
  • and, most importantly, xebialabs/USAGE-docker-compose.md describes how to use these files.

Follow the instructions in the latter file to start XL Deploy and XL Release.

Exercise 3: Check the XL Deploy and XL Release user interfaces

Open a browser and go to the following URL for XL Deploy:

http://localhost:4516

The default username and password combination is admin/admin.

Open another tab and go to the following URL for XL Release:

http://localhost:5516

Again, the default username and password combination is admin/admin.

If you want a different admin password, change it in the docker-compose.yml file before starting it for the first time. Leave it out for a randomly generated password. In that case, you'll have to check the container logs to see what passwords have been selected.

Exercise 4: Define a Kubernetes application

Now that XL Deploy and XL Release are up and running, let's deploy an application. But first, we'll need to define it. Luckily we have a blueprint for that too.

In the scratch directory, run the blueprint command again:

./xlw blueprint

This time select the kubernetes/application blueprint. If you accept the defaults, you'll deploy the sample nginx application from the Kubernetes docs. But you can also specify your own K8s YAML or JSON file. For now, let's stick with the defaults.

? Choose a blueprint: kubernetes/application
? What is the name of the application that you want to deploy? nginx
? What is the version of the application that you want to deploy? latest
? What is the path of the Kubernetes YAML file that you want to deploy? ../kubernetes/nginx.yaml
? Confirm to generate blueprint files? Yes

Have a look at the files that were generated by this blueprint:

  • kubernetes/nginx.yaml is the Kubernetes YAML file for the sample nginx application. If you're familiar with Kubernetes, this shouldn't surprise you.
  • xebialabs/kubernetes-application.yaml is the XL YAML file that defines this application in XL Deploy.
  • And, finally, xebialabs/USAGE-kubernetes-application.md describes how to use these files.

The XL YAML format was introduced in XL Deploy and XL Release 8.5 (late 2018) and allows you to define applications, infrastructure, envirionments, releases and other objects in XL Deploy and XL Release. It also allows you to start deployments and releases. All from the command line. For more information, please read the docs or follow the DevOps as Code workshop.

In this workshop, we'll use DevOps as Code and the XL CLI's blueprint functionality to deploy a Kubernetes application to your local Kubernetes environment and then to spin up an Kubernertes cluster in AKS (Azure Kubernetes Service) or GKE (Google Kubernetes Engine) and deploy that same application there. So, let's get back to that...

Now that the blueprint has been instantied, let's apply the XL YAML file so that its contents get sent to XL Deploy:

$ xl apply -f xebialabs/kubernetes-application.yaml

Go to the XL Deploy GUI, select Explorer in the top menu bar and navigate to Applications/nginx/latest to see the result of applying that XL YAML file.

Exercise 5: Define a Kubernetes environment

Now that we have an application, let's define an environment to which we can deploy that application.

Before we start, let's check whehter your Kubernetes environment has been setup correctly. Execute the following command to see all the pods running in your Kubernetes system:

$ kubectl get --all-namespaces pods

The output should look something like this:

NAMESPACE     NAME                                         READY   STATUS              RESTARTS   AGE
docker        compose-74649b4db6-8nvg9                     0/1     MatchNodeSelector   0          152d
docker        compose-74649b4db6-8rwbc                     0/1     MatchNodeSelector   0          48d
docker        compose-74649b4db6-95cxk                     0/1     MatchNodeSelector   0          118d
docker        compose-74649b4db6-ckd2s                     1/1     Running             0          2d
docker        compose-74649b4db6-ns9qt                     0/1     MatchNodeSelector   0          105d
docker        compose-74649b4db6-s5g2g                     0/1     MatchNodeSelector   0          118d
docker        compose-api-6bdd8b4dbb-4h829                 0/1     MatchNodeSelector   0          105d
docker        compose-api-6bdd8b4dbb-7lr95                 1/1     Running             0          40d
docker        compose-api-6bdd8b4dbb-7m2mj                 0/1     MatchNodeSelector   0          48d
docker        compose-api-6bdd8b4dbb-9dpcq                 0/1     MatchNodeSelector   0          118d
docker        compose-api-6bdd8b4dbb-dclmq                 0/1     MatchNodeSelector   0          152d
docker        compose-api-6bdd8b4dbb-zwcl6                 0/1     MatchNodeSelector   0          118d
kube-system   etcd-docker-for-desktop                      1/1     Running             0          208d
kube-system   kube-apiserver-docker-for-desktop            1/1     Running             0          111d
kube-system   kube-controller-manager-docker-for-desktop   1/1     Running             0          111d
kube-system   kube-dns-86f4d74b45-52n5v                    3/3     Running             0          208d
kube-system   kube-proxy-nk45x                             1/1     Running             0          111d
kube-system   kube-scheduler-docker-for-desktop            1/1     Running             0          111d
kube-system   kubernetes-dashboard-669f9bbd46-nzbpf        1/1     Running             0          89d
kube-system   tiller-deploy-9cb565677-nt57k                1/1     Running             0          47d

In the scratch directory, run the blueprint command one more time:

$ ./xlw blueprint

Now select the kubernetes/environment blueprint. This blueprint will create XL YAML files that define an environment in XL Deploy that matches the current configuration of your '~/.kube/config` file. Accept all defaults and then apply the XL YAML file that has been created:

$ xl apply -f xebialabs/kubernetes-environment.yaml

In the XL Deploy GUI, under the Environments tree in the package explorer, you should now see an entry for your Kubernetes cluster. If you're using the Kubernetes functionality built into Docker Desktop, it will be called docker-for-desktop-cluster.

Exercise 6: Deploy the Kubernetes application to the Kubernetes cluster

Let's first start the deployment from the XL Deploy GUI.

  1. Open the XL Deploy GUI at http://localhost:4516/
  2. Log in with admin/admin
  3. In the tree on the left, navigate to Applications/nginx.
  4. Click on the three dots behind that entry (the context menu).
  5. Select Deploy latest (latest).
  6. In the next screen, select the environment that you created in the previous exercise.
  7. Click the Continue button in the top right.
  8. In the next screen, click the Deploy button in the top right.
  9. Wait for the spinner to finish spinning and then watch the deployment execute.
  10. When the deployment has finished, press the Finish button.

Let's verify that the application has been deployed correctly. In the command prompt, enter the following command:

$ kubectl get deployment

The output should look something like this:

NAME               DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
nginx-deployment   2         2         2            2           24s

Now, let's undeploy the application:

  1. Navigate to Environments/docker-for-desktop-cluster/nginx
  2. Select Undeploy from the context menu.
  3. In the next screen, click the Undeploy button.
  4. When the undeployment has finished, press the Finish button.

Exercise 7: Provision a Kubernetes cluster in the cloud

Now that we've seen how an application and a target environment are defined in XL Deploy and how a deployment is executed, let's provision an Kubernetes cluster in the cloud and our application there.

There are currently two blueprints that provide that functionality:

A third blueprint that spins up an AWS EKS cluster with CloudFormation is currently being developed.

Pick one of the two available blueprints and follow the instructions to run them.

About

Workshop about the new XebiaLabs stack


Languages

Language:Shell 57.4%Language:Batchfile 42.6%