Deploy new Applications
Our Rocket Pad Platform uses Argo CD to realize application deployments trough GitOps principles and allow to define application deployments in git with kubernetes manifests and let them automatically update and rollout changes on git push to main branch.
This tutorial guides you through creating a new Argo CD application to deploy a custom docker container image from a private registry to your Rocket Pad Platform instance. We'll cover:
- Setting up secrets for your private registry credentials (Can be skipped if image is public)
- Creating an ImagePullSecret for your cluster (Can be skipped if image is public)
- Defining the application manifest in Git
Prerequisites
- A running Rocket Pad Platform cluster
- A Git repository to store your application manifest (We recommend to keep application deployments separate from the RPP Bootstrap cluster we created in the installation tutorial)
Steps
1. Create Secrets for Private Registry Credentials
If your container image resides in a private registry, you'll need to create a Kubernetes secret to store your access credentials.
Access your Rocket Pad Platform cluster and create a new secret in the argocd
namespace using the following command, replacing <username>
and <password>
with your actual credentials:
kubectl create secret docker-registry registry-credentials-secret -n <your-application-namespace>
--docker-server=<your-registry-server>
--docker-username=<your-name>
--docker-password=<your-password>
--docker-email=<your-email>
We recommend using Sealed Secrets instead of creating secrets with kubectl to allow for version controlled secrets that can be saved directly to git and therefore allow bootstrapping as well as disaster recovery directly from your Git repositories. This further solidifies the GitOps principles baked in to the Rocket Pad Platform.
2. Define the deployment Manifest:
Create a file named deployment.yaml
(or any name you prefer) in your applications Git repository subfolder named /kube (You can name this folder as you like). This file will define the deployment configuration for your application.
Here's an example manifest using a Deployment resource:
apiVersion: apps/v1
kind: Deployment
metadata:
name: <your-application-name>
spec:
replicas: 1
selector:
matchLabels:
app: <your-application-name>
template:
metadata:
labels:
app: <your-application-name>
spec:
containers:
- name: <container-name>
image: <your-private-registry-url>/<image-name>:<image-tag>
imagePullSecrets:
- name: registry-credentials-secret
# Add any additional container configuration (ports, environment variables, etc.)
Replace the placeholders with your specific information:
-
<your-application-name>
: The name for your application deployment -
<container-name>
: The name of the container within your image -
<your-private-registry-url>
: The URL of your private registry -
<image-name>
: The name of your container image -
<image-tag>
: The specific tag for your image -
<your-imagepullsecret-name>
: The name of the ImagePullSecret you createdThe created deployment describes which container image to pull from what container registry and how to name the application within kubernetes once it is deployed. You can add additional resources like kubernetes services, ingresses, persistent volume claims, configmaps and secrets as you wish into the
/kube
folder.
3. Create Argo Application:
It is possible to just apply the deployment.yaml
file created above by using kubectl apply -f deployment.yaml
and your application will be created within the Rocket Pad Platform cluster. But using Argo CD for setting up a continuous watch job on changes of the repository where your /kube
folder is and apply any changes pushed to files within that folder leverages the advantages of using our GitOps ready Rocket Pad Platform.
Argo CD has the concept of applications, which is also a yaml file defined kubernetes resource. This resource tells Argo CD in which Git repository on what branch in what folder to find kubernetes manifests to apply and then watch for changes and synchronize the application state within the cluster with what is defined in the Git repository.
A Argo CD application can be created as follows:
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: <your-application-name>
namespace: argocd
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
project: default
sources:
- repoURL: <your-git-repository-https-url>
targetRevision: HEAD # With this the git branch can be set that will be used to listen to
path: kube/ # Here the path to the kubernetes manifests within the git repository can be set
destination:
server: 'https://kubernetes.default.svc'
namespace: argocd
syncPolicy:
syncOptions:
- CreateNamespace=true
automated:
prune: true
selfHeal: true
Replace the placeholders with your specific information:
<your-application-name>
: The name for your application deployment<your-git-repository-https-url>
: The url to your application git repository with the/kube
folder created before
Now the application can be created by directly applying it with kubectl apply -f application.yaml
.
We recommend using a dedicated GitOps repository with all the Argo CD Apps inside it and let Argo CD watch for it by using the App of Apps Pattern with a app-of-apps.yaml application file within your Rocket Pad Platform bootstrap repository.