Deploy Strapi on Kubernetes with HTTPS

Rajat Badjatya
May 24 · 7 min read
Image for post
Image for post

What is Strapi?

Why Headless CMS?

Setup 🛠

Steps:

Step 1: Setting up the namespace and storage-class

Namespace:

Namespace Yaml
$ kubectl apply -f namespace.yml
namespace/my-es-cluster created
$ kubectl get namespaces
NAME STATUS AGE
default Active 50m
kube-system Active 50m
ns-strapi Active 1m

StorageClass

StorageClass YAML

Step 2: Installing MongoDB for our Strapi project

Mongo YAML
kubectl get pods -n ns-strapi 

NAME READY STATUS RESTARTS AGE

strapi-mongo-0 1/1 Running 0 3m

strapi-mongo-1 1/1 Running 0 3m

strapi-mongo-2 1/1 Running 0 3m
kubectl get svc -n ns-strapiNAME TYPE CLUSTER-IP EXTERNAL-IP PORT
mongo LoadBalancer 10.97.135.233 xxx.xx.xx.xx 30144:30129/TCP

Step 3: Setting up Strapi with MongoDB configuration.

dockerfile
strapi.sh
nginx.conf
sudo docker build -f dockerfile -t YOUR_REGISTRY:5000/strapi-image:v1 .sudo docker push YOUR_REGISTRY:5000/strapi-image:v1

Step 4: Creating and deploying Kubernetes resources for Strapi

kubectl apply -f pvc.yml -n ns-strapi
pvc.yml
strapi.yml
kubectl get pods -n ns-strapi 

NAME READY STATUS RESTARTS AGE

strapi-mongo-0 1/1 Running 0 20m

strapi-mongo-1 1/1 Running 0 20m

strapi-mongo-2 1/1 Running 0 20m
masterstrapi-6c5bs 1/1 Running 0 3mkubectl get svc -n ns-strapiNAME TYPE CLUSTER-IP EXTERNAL-IP PORT
mongo LoadBalancer xx.xx.xx.xx xxx.xx.xx.xx 30144:30129/TCP
strapi LoadBalancer xx.xx.xx.xx xxx.xx.xx.xx 30143:31745/TCP
Image for post
Image for post
Strapi accessible over browser

The Startup

Medium's largest active publication, followed by +704K people. Follow to join our community.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store