Getting Started Tutorial
This tutorial covers the setup and features of the reference implementation. It assumes some familiarity with Tekton and ArgoCD.
The instructions use web UIs. There is different README with instructions for getting started quickly and repeatably with the CLI.
You will need an OpenShift cluster for this tutorial. It must be able to install the GitOps and Pipelines Operators from the Red Hat Marketplace. See the local development environment instructions if you want to set that up on your local machine.
Important Constructs - Day 0, 1, 2
The Day 0, 1, and 2 concepts are critical to understanding the operations of any software system. Within the context of Ploigos, the following is how we define Day 1, 2, and 3. We used a [DZone Day-2 Operations Article][/dzone.com/articles/defining-day-2-operations] as inspiration:
- Day 0 - The first phase of any software system consists of requirements engineering, design, and architecture.
- Ploigos provides a Day 0 opinion provides 100% design solution for getting started.
- This opinion provides a pre-designed & architected solution with extension points.
- This Day 0 can be found one the Ploigos Workflows.
- This design distills the most common concepts for differing integration and deployment approach.
- Day 1 - Installation, setup, and configuration of the system
- The installation, setup, and configuration of the tooling is handled via the Argo CD Apps.
- We use an App of Apps approach where we delcare all required applications for a given workflow, then use Argo to manage the installation and confiugration.
- This is a true GitOps approach to managing a software delivery platform.
- Day 2 - Continuous Operations of the system. Such as peroidc tasks (houlry, daily, weekly, monthly, etc..), maintenance, and optimization
- Onboarding new applications
- Adding pipelines for new application archetypes
Forking Requirements
You will have to fork the following repositories to complete this tutorial. If you have a lot of existing repositories, it may be easiers to temporarily create a new GitHub Organization to store the forks.
NOTE - March 14, 2022
We are amid porting logic from the Ploigos Step Runner into this new Tekton-native implementation. This port is removing the dependency upon the step runner. This new Tekton native implementation does not have the following workflow steps completed:
- Setup
- Setup Workflow Step Runner
- Setup Encrypted Configuration Decryption
- Continuous Integration
- Generate Metadata
Day 0 - Requirements, Design, and Architecture
Overview
The Day 0 design is povided via the Ploigos Workflows and the Ploigos Workflow Tools.
This tutorial will implement the Minimal Workflow.
Day 1 - Installation, Setup, and Configuration
Overview
We follow a GitOps approach. That means using ArgoCD to deploy all required tools and services (including Tekton). Then we use those tools and services to build new software, which we also deploy using ArgoCD.
To accomplish all Day 1 tasks, you need to complete the following high-level tasks:
- Bootstrap OpenShift GitOps
- Install the platform
Terminology
The follow terms will be used interchangable:
- OpenShift GitOps & ArgoCD
- OpenShift Pipelines & Tekton
Boostrap OpenShift GitOps
The only component we bootstrap manually is OpenShift GitOps. OpenShift GitOps is the Red Hat supported version of ArgoCD.
Install the platform
The platform consist of all the integration and deployment tooling & services required. For this tutorial, we will use ArgoCD to install the following components:
- OpenShift Pipelines (Tekton)
First, Install the OpenShift GitOps Operator (ArgoCD Bootstrapping)
- Open the OpenShift Admin Console and login as a cluster with administrative priviliges.
- Install the GitOps operator.
- Operators -> Operator Hub -> Search “gitops” -> Choose “Red Hat OpenShift GitOps” -> Install
- Use the default options
- Select “Install”
- View the installed Operator
- Operators (left navigation) -> Installed Operators
- Create RBAC objects for ArgoCD
- Click the (+) icon at the top of the Admin Console to create a resource.
- Copy and paste the contents of openshift-gitops-clusterroles.yml.
- Select “Create”
- This grants the ArgoCD service account additional permissions in order to install the OpenShift Pipelines Operator.
- Open the ArgoCD web UI
- Click the grid icon at the top of the Admin UI and select the link for the ArgoCD console.
- If the UI does not show up yet, wait for a few minutes and refresh your browser.
- Select “LOGIN VIA OpenShift”.
- Use the same credentials you used to log in to the OpenShift Admin Console.
- If prompted with a screen that says “Authorize Access”, select “Allow Selected permissions”.
Second, Create the app-of-apps ArgoCD Application
Overview
The App of Apps approach allows ArgoCD to install and manage differing tools, services, and resouces. The tools, services, and resouces being installed for this tutorial are:
- Services
- OpenShift Pipelines (Tekton)
- Pipelines as a Service
- Easy Mode
Each of these components consists of many differing kubernets resourecs. They include, but are not limied to:
- Tekton triggers, tasks, and pipelines
Actions to Take
- Open the OpenShift Admin Console.
- Create the ArgoCD Application CR.
- Click the (+) icon at the top of the OpenShift Admin Console to create a resource.
- Copy and paste the contents of minimal.yml.
- Open the “Installed Operators” view in the OpenShift Admin Console to verify that OpenShift Pipelines Operator was installed.
- Open the ArgoCD console to verify that the app-of-apps application and dependent applications were created.
- Note: Depending on your cluster configuration, it may take 10 minutes or longer for ArgoCD to create and sync all of the Application CRDs. When the installation is done, all applications will say “Synced”. The pipelines-minimal application will still also say “Progressing” or “Degraded” until the pipeline has been started for the first time. That is normal.
Day 2 - Daily Operations
Overview
This tutorial focuses on providing an x-as-a-service model for software delivery. This is achieved by providing a REST endpoint for each application archetype. This endpoint is consumed as a webook via a GitRepo and triggered via a push to some branch. It does not matter if the output artifact is a runtime (Quarkus) or a simple shared library.
The following are possible application archetypes:
- Java Maven - A Java-based application that uses the Maven build, test, and package tool.
- Java Gradle - A Java-based application uses the Gradle build, test, and package tool.
- JavaScript NPM - A JavaScript application that uses the Node Package Manager (NPM) as the interface for the build, test, and package tool(s).
What is an Application Archetype?
An Application Archetype refers to the programming language and building a mechanism for a given software project.
Examining the Easy Mode Pipeline as a Service
ArgoCD created many Tekton objects when we installed the App of Apps. That includes a Pipeline, EventListener, and Route named “easymode”. Together these resources implement a Pipeline as a Service.
- View the easy-mode Tekton pipeline in the UI.
- Pipelines -> Pipelines -> Select the “pipelines-easymode” project.
- Start the pipeline manually to build and deploy an example application.
- Actions -> Start
- Change the dropdown option under Workspaces for shared-workspace from “Empty Directory” to “VolumeClaimTemplate”.
- Select Start
Onboarding A New Application
Onboarding a new application for a given pipeline service archetype requires two steps:
- Create a Git repo.
- Register the pipeline service trigger as a webhook for the git repo.
We assume you know how to crate a new repo. Our examples will be using GitHub. Once the repo is created, you can register the webhook.
GitHub - Tekton WebHook Registration
In our source code repo, go to Settings -> Webhooks -> Add Webhook.
Payload URL
- Enter the Tekton EventListener webhook URL for your cluster.
- This is NOT the ArgoCD webhook URL. You can get the correct hostname with
oc get route -n pipelines-easymode -o wide
. - The URL should look like https://[EventListner Route].[your.cluster.com]/
Content Type
- Select application/json
SSL verification
- If your OpenShift cluster is using TLS certificates that GitHub does not trust, you will have to select SSL verification -> Disable.
- To avoid this when using github.com, you have to configure OpenShift with TLS certs signed by a well known certificate authority.