Strapi on Kalm
Kalm provides a quick dashboard to simplify your daily work, but sometimes you may still want to set things up with YAML files. Fortunately, it's designed to be mutually inclusive with other ways of applying YAML files.
In this tutorial, we will show you how to install the headless CMS project: Strapi by applying YAML files through kubectl. As you go through this process, you can check the Kalm Dashboard to see how it automatically pulls in your work.
Objectives
- Deploy MongoDB on Kalm as an Component
- Deploy Strapi on Kalm as an Component
Before you begin
- You'll need a Kubernetes cluster with Kalm installed
Deploy MongoDB
Define the DB by using a Component. Use kubectl to apply the YAML file below:
Let's walk through some key points here.
We use image: mongo:4.4.4-bionic
to run our DB instance:
and we initialized the database using these Environment variables:
We exposed the db service at port: 27017
:
We also asked for a 2Gi disk for our database:
note
The storageClassName (gp2) displayed in this demo is for EKS. This name is provided by AWS. For a different platform this name will be different, please update the field accordingly. (For GCP it is pd-ssd)
Deploy Strapi
The YAML for Strapi is quite similar:
note
- update the ENVs if your db configuration is different
- update the storageClassName again if you are on a different cloud platform
Setup HTTPRoute
Finally let's setup the HTTP route for our Strapi service:
note
You will need to update your domain for the field: spec.hosts
.
Some key points:
We route the traffic to the service at strapi.strapi.svc.cluster.local:1337
:
The destination is the strapi component we just defined above.
We set our domain in the spec.hosts
field:
HTTPs is ready for clusters initialized by Kalm, so we enable the HTTPS redirect option:
Try it out
Go into Kalm, and find your application. Check if your Strapi service is up now. If everything works as expected, you should see a green light on the page:
Now visit the domain you just configured (you can also find this on the Routes tab) and you should see the admin page is up and running:
Clean Up
To delete your work here, simply delete the app within the Kalm dashboard. To delete the DB disk, go to the Disks page, and delete the disk there.