Skip to content

escomputers/k8s-freepbx

Repository files navigation

k8s-freepbx

Run FreePBX (Asterisk) on Kubernetes.

Just pure open source power.

Requirements

  • FQDN
  • Ability to create type A DNS record for the public IP address allocated by the cloud provider

This PoC is based on Vultr Kubernetes Engine

Database deployment

Freepbx requires MySql or MariaDb

A statefulset of 3 replicas (adjust replicas number according to your needs) with one pod for WRITE operations and the others for READ ops.

  1. Create Namespace and ConfigMap
kubectl apply -f mysql/namespace.yaml
kubectl apply -f mysql/configmap.yaml
  1. Create services
kubectl apply -f mysql/services.yaml
  1. Deploy
kubectl apply -f mysql/statefulset.yaml
  1. Test connection with READ operation
kubectl run mysql-client --image=mysql:5.7 -i -t --rm --restart=Never -- mysql -h mysql-read -e "SHOW DATABASES;"

or

kubectl run mysql-client-loop --image=mysql:5.7 -i -t --rm --restart=Never --\
  bash -ic "while sleep 1; do mysql -h mysql-read -e 'SELECT @@server_id,NOW()'; done"

Freebpx deployment


Exposing services

  1. Deploy nginx-controller (read cloud provider docs to check features, in most cases a public IP address will be automatically allocated to it)

TLS (optional but recommended)

This step uses HTTP-01 challenge with Letsencrypt as ClusterIssuer.

  1. Install cert-manager for managing TLS certificates
kubectl apply -f cert-manager/install-v1.12.0.yaml
  1. Deploy Letsencrypt, before applying, change email field within the yaml
kubectl apply -f letsencrypt/clusterissuer.yaml

KUARD test (optional)

  1. Expose and deploy KUARD to test networking functionality (keep order)
kubectl apply -f kuard/service.yaml
kubectl apply -f kuard/deployment.yaml
  1. Check if web server within the pod is running
# PLAIN HTTP
kubectl run curl-client --image=curlimages/curl:8.1.0 -i -t --rm --restart=Never -- http://<PODIP>:8080
  1. Expose services by creating Ingress. Before applying, change hosts and host field in ingress-tls.yaml if you want TLS or host field in ingress.yaml (no TLS), by inserting your FQDN
# NO TLS
kubectl apply -f kuard/ingress.yaml

# WITH TLS
kubectl apply -f kuard/ingress-tls.yaml
  1. Check from outside
Open http://YOURFQDN or https://YOURFQDN