Automated Deployment using Github Actions
You can use Github actions to deploy to Subkube directly from Github.
Prerequisites
- A Namespace in a Subkube Project
- A Github 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 Github repository.
Now we can initialize the local git repository, and set up Github as it's origin
:
1 2 3 4 5 6 |
|
Setup Kubeconfig in Github
In order to deploy to Subkube using kubectl from Github Actions, we need to store a copy of our kubeconfig inside a Github secret.
In your Github repository, under the settings tab, navigate to the
Secrets page, and click the Create Repository Secret button. The kubectl
Action we'll be using a base64 encoded version of our kubeconfig
, which we can
get using the following command:
1 |
|
Now create the secret using the encoded config:
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 12 13 14 |
|
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: