Kubernetes tutorial
This tutorial will teach you how to use Stitch capability of Digital.ai Deploy, when deploying to a Kubernetes cluster. For more information about Stitch, please see Introduction to Stitch.
Prerequisites
-
Install Digital.ai Deploy 22.1 or later. Refer to the installation guide.
Note: For the purpose of this tutorial, it is advised not to run Deploy in a container, since it will be harder to deploy to the same host if Docker Desktop Kubernetes is used.
-
Install XL CLI version 22.1 or later. Refer to the installation guide.
-
Ensure that your K8s context points to your Kubernetes cluster (
kubectl cluster-info
).
Configuration
- Configure Deploy with Infrastructure CIs to point to your Kubernetes cluster
- Create Kubernetes cluster configuration CI -
Infractructure - New - k8s - Master
- Name it
kubernetes-cluster
- Provide
TLS certificate
,TLS private key
,API server URL
,CA certificate
. You can obtain these from your.kube\config
values ('client-certificate-data', ' client-key-data', 'server', and 'certificate-authority-data' respectively) - Once created, find this CI in the Explorer, and use CI's context menu to create a namespace CI. Name it
default
.
-
Run a connection check on
Infrastructure/kubernetes-cluster
to check the connection to your Kubernetes cluster. -
Configure Deploy with the Environment CI to point to the 'default' namespace of your Kubernetes infractruecture CI
- Create Kubernetes environment CI -
Environments - New - Environment
- Name it
kubernetes-env-prod
- In
Containers
filed find yourInfrastructure/kubernetes-cluster/default
Setup
-
Configure a sample 'PetClinic' application as CI in Deploy.
- Download 'PetClinic' folder from the Stitch tutorial GitHub repository to your local machine.
- Run XL CLI command
xl apply -f xebialabs.yaml
in the 'PetClinic' directory. It will use 'DevOps as Code' to create the Petclinic kubernetes application for you, under theApplications/PetClinic/1.0
CI path. - This is a Kubernetes-packaged application that contains YAML manifest with 'Deployment' and 'Service'.
-
Add a source of Stitch tutorial sample customizations to Deploy:
- In Deploy UI, navigate to 'Stitch' section. Find 'Sources' tab and use 'Add Git source'.
- Name it
stitch-tutorial
. - For
Repository Url
property, add "https://github.com/xebialabs/stitch-tutorial". - Leave other fields as they are.
- Click 'Test' to verify the connection, and click 'Save'.
- Use the 'Refresh' button to monitor the synchronization of customizations from the GitHub repository with Deploy.
- In case of issues, use the 'View log' button to check the logs and troubleshoot.
-
Check available Stitch customizations
In Deploy UI, navigate to the 'Stitch' section. Find 'Rules' tab and click the 'k8s-tutorial' namespace. It should give you a list of customization rules now available in Deploy.
- Build a deployment plan for the 'Petlinic' app
- Go to the 'Explorer' section to find the application under
Applications/PetClinic/1.0
. - Start a Deployment and map this application to your Kubernetes environment
Environments/kubernetes-env-prod
. - Click 'Preview' to investigate the deployment plan created, including applied Stitch customization to application's YAML.
- Navigate to the 'Stitch Preview' tab for details on the effect of each customization
- 'Invocation 1' would be a 'kind:Deployment' manifest.
- Look at the difference between 'Original' and 'Modified' content for the manifest under the 'Stitch invocation output'.
- It shows the effect of all customizations applied to this manifest.
- Click 'Show processing steps' and click on a particular customization step under 'Processor Execution' to observe the effect of change by each step.