Automated Deployment using Gitlab CI
You can use Gitlab CI/CD to deploy to Subkube directly from Gitlab.
Prerequisites
- A Namespace in a Subkube Project
- A Gitlab(.com) account
Steps
Prepare Application
For this guide we will be deploying Nextcloud, which we covered in our Kompose guide. The resulting manifests can easily be fetched from our examples repository, as shown below.
1 2 3 4 5 |
|
Prepare Repository
After fetching the resources from our examples repository, you should create a new Gitlab repository.
Now we can initialize the local git repository, and set up Gitlab as it's origin
:
1 2 3 4 5 |
|
Setup (Partial) Gitlab Kubernetes Integration
In order to deploy to Subkube using kubectl from Gitlab CI, we'll need to add Subkube as a Kubernetes environment to Gitlab. You don't need to supply a PEM certificate, as you use the Subkube API proxy to interface with the Kubernetes API.
Add Kubectl action
After we've setup our kubeconfig in Github, we can define an Action using this
config to deploy to subkube. Define the following action inside the .github/workflows/deploy.yaml
file.
1 2 3 4 5 6 7 8 9 10 11 |
|
Commit and Deploy
Now everything is setup, we can push our changes and watch them be applied to your Subkube project.
1 2 3 |
|
Our workflow should now be visible under the actions tab: