Deploying Applications with OCM & GitOps
Introduction
This tutorial will demonstrate how to get started deploying applications using the Open Component Model & Flux.
In this guide, we will leverage Flux and the ocm-controller
to deploy an existing component to a Kubernetes cluster. Specifically, we will deploy the phoban.io/podinfo
component that contains the resources needed to launch the podinfo application.
Here’s a diagram showing what we’ll be building:
As you can see, we’ll add some manifests to a git repository that will be deployed by Flux. These will, in turn, deploy a resource from an OCM repository, in this case, a Deployment
of the podinfo
microservice.
If you’d like to learn how to build a component, then check out our Getting Started guide.
Table of Contents
Requirements
Environment Setup
First of all, let’s create a cluster using kind
:
With the cluster created, we can now bootstrap Flux to automate the deployment of our component. Flux can create a repository and clone it to our local environment by running the following shell command:
This command will create a GitHub repository named podinfo-flux-repo
, configure Flux to use it, and deploy the resources in the ./clusters/kind
directory to our Kubernetes cluster.
Let’s now clone the repository flux has created and put in place the manifests required to deploy components:
We’ll add a Kustomization
to the ./clusters/kind
directory in order to reconcile any resources found in the ./components
directory:
Commit this file, push, and then ensure Flux has reconciled the resource:
Deploy the OCM Controller
We can use the OCM CLI to install the controller:
Deploy the Component
Now that we have flux configured and the ocm-controller
installed, we can started deploying components.
We told flux that our component manifests will live in ./components
, so let’s create that directory:
To make the component accessible within the cluster, create the following ComponentVersion
:
Then create a Resource
to retrieve the deployment
resource from the component:
Finally, create a FluxDeployer
to deploy the Resource
contents using Flux:
At this point we can commit these files, push to the remote repository, and tell flux to reconcile the changes:
Within a few moments we will see the deployment spinning up:
Wrapping Up
That’s it! That’s how easy it is to get started using the Open Component Model and Flux.
If you want to know more about working with OCM and GitOps, check out these guides: