Skip to content

Deploying services to Kubernetes

Deploying services to Kubernetes

[under construction]

!! This guide is for deploying your own image, from a separate git repo. If your application is simpler and doesn't require a custom built image, follow instructions on ocf/kubernetes/README !!

Write .transpire.py

To get started, you'll need to create a .transpire.py file for the application, which describes to the CI/CD processes what Kubernetes resources to create. More detailed steps are provided at Writing .transpire.py.

Add your application to Kubernetes Repo

Add a new entry to cluster.toml:

app = { git = "https://github.com/ocf/app" }

This tells Kubernetes where your application is, and is required for transpire-ci to work.

Use transpire-ci

To enable CI through transpire for your application, add the following Action to your main repo:

name: CI

on:
  push:
    branches:
      - main

jobs:
  transpire-ci:
    uses: ocf/transpire-ci/.github/workflows/trigger.yml@master
    with:
      module_name: app
    secrets:
      TRANSPIRE_CI_PAT: ${{ secrets.TRANSPIRE_CI_PAT }}

!! "app" must be the same as specified in cluster.toml !!

How does it work?

\ From the transpire-ci repo, trigger.yml calls trigger.py, which sends an API request to Github with corresponding module name and run_id. It then returns the result of the request.

\ The API request triggers build-module.yml, which pipes all arguments above, along with deployment keys and registry password to the FINAL deployment action found at ocf/transpire

Verifying Generated Objects

After adding your application to the Kubernetes repo and setting up CI, you can check the generated objects with the transpire object print [app] command from inside the Kubernetes repo. This will output the actual Kubernetes objects generated by transpire (in YAML), and can be useful for verifying your .transpire.py.

Deploy to Cluster

Once the above steps have been completed, go to ArgoCD and run a sync. (this is as per ocf/kubernetes. im unsure exactly what to sync, i ran it on bootstrap and that worked but I'm not certain that was specifically correct -sophie). This will sync ArgoCD with the ocf/cluster repo, which will include the objects generated by your .transpire.py. From now on, any changes you make to your app's repo, including .transpire.py should be automatically synced and updated in the cluster after the CI/CD run completes.

\ adenine = kube control plane

https://microk8s.io/