Experimenting with k8s for scalable GatewayD deployment
The following resources were used to create this project:
-
Install MicroK8s on your machine. See here for instructions. The last command in the instructions will print the token you need to access the Kubernetes dashboard. The IP address and port number for the dashboard can be found in the
kubernetes-dashboard
service.sudo snap install microk8s --classic sudo apt update && apt install -y ufw sudo ufw allow in on cni0 && sudo ufw allow out on cni0 sudo ufw default allow routed
-
Add your user to the
microk8s
group.sudo usermod -a -G microk8s $USER sudo chown -f -R $USER ~/.kube newgrp microk8s
-
Enable the following MicroK8s addons:
- dns
- dashboard
- storage
microk8s enable dns dashboard storage
-
See the status of the MicroK8s cluster and optionally get the token for the Kubernetes dashboard.
microk8s kubectl get all --all-namespaces token=$(microk8s kubectl -n kube-system get secret | grep default-token | cut -d " " -f1) microk8s kubectl -n kube-system describe secret $token
-
Follow the instructions in the how to deploy Postgres on kubernetes article to deploy a Postgres instance. You can use the files starting with
postgres-
in this repo as a starting point.microk8s kubectl apply -f postgres-config.yaml microk8s kubectl apply -f postgres-pvc-pv.yaml microk8s kubectl apply -f postgres-deployment.yaml microk8s kubectl apply -f postgres-service.yaml
-
Install GatewayD on your machine.
microk8s kubectl apply -f gatewayd-config.yaml microk8s kubectl apply -f gatewayd-deployment.yaml microk8s kubectl apply -f gatewayd-service.yaml
-
Scale GatewayD to any number of replicas you want.
microk8s kubectl scale deployment gatewayd --replicas=3
-
Use the following command to find the exposed port for the GatewayD service.
microk8s kubectl get all
-
Use the following command to test the GatewayD service. Replace the port number with the one you found in the previous step.
psql postgres://postgres:postgres@localhost:31221/postgres