Application Hosting: Bare Metal, Nomad or Kubernetes?

Application Deployment Options

  • Bare metal: Nginx with static HTML to deliver the frontend, Docker containers for the backend. Installed with Ansible on each node
  • Consul & Nomad: deployment and management of containers with Nomad, service discovery with Consul, load balancing with Nginx
  • Kubernetes: deployment, management, service discovery and load balancing with Kubernetes components

Bare Metal

Required Steps

  • Install Nginx
  • Install Docker
  • Build and deploy backend as Docker container
  • Configure Nginx upstream servers for backend
  • Configure load balancing for backend
  • TLS: Generate TLS certificate, configure Nginx
  • Frontend: Configure Nginx to deliver static HTML
  • Backend: Build Docker containers, push and deploy on nodes
  • Service Discovery: Configure Nginx upstream server group with static IP and ports
  • Load Balancing: Configure Nginx upstream server

Features

  • ✅ Automatic Installation
  • ❓ Automatic Deployment
  • ✅ TLS Encryption
  • ✅ Service Discovery
  • ❌ Health Check
  • ✅ Load Balancing
  • ❌ Logging/Monitoring
  • ❌ Auto-Scaling
  • ❓ Self-Healing

Consul & Nomad

Required Steps

  • Install Consul on each node
  • Install Nomad on each node
  • Encrypt Consul & Nomad traffic
  • Install Docker on each node
  • Dockerize Frontend app
  • TLS: Generate TLS certificate, configure Nginx
  • Frontend: Define deployment job with Nomad
  • Backend: Define deployment job with Nomad
  • Service Discovery: Add service definition to Nomad job, configure nodes to use Consul DNS server
  • Health Check: Add service definition to Nomad job
  • Load Balancing: Configure Nginx upstream server to use DNS names for the services provided by Consul

Features

  • ✅ Automatic Installation
  • ✅ Automatic Deployment
  • ✅ TLS Encryption
  • ✅ Service Discovery
  • ✅ Health Check
  • ✅ Load Balancing
  • ✅ Logging/Monitoring
  • ❌ Auto-Scaling
  • ✅ Self-Healing

Kubernetes

Required Steps

  • Install Kubernetes on each node
  • Dockerize Frontend app
  • TLS: Install cert manager, define ClusterIssuer resource
  • Frontend: Define Service and Deployment resource
  • Backend: Define Service and Deployment resource
  • Service Discovery: Automatic
  • Health Check: Add checks to Deployment resource
  • Load Balancing: Automatic

Features

  • ✅ Automatic Installation
  • ✅ Automatic Deployment
  • ✅ TLS Encryption
  • ✅ Service Discovery
  • ✅ Health Check
  • ✅ Load Balancing
  • ✅ Logging/Monitoring
  • ✅ Auto-Scaling
  • ✅ Self-Healing

Choice

Deployment with K3S

  • When the cluster runs after you executed a one liner installation script per node
  • Deploy a docker container, expose the service, and access it immediately
  • Deploying, scaling, deleting containers with a powerful CLI
  • Realize that the ingress is Nginx, and that the configuration options you know are all there, represented as annotations
  • Deploy a TLS encrypted private Docker registry
  • Using cert-manager to automatically create lets-encrypt certificates for your live services
  • The power to scale from 1 to 100 containers with a simple kubectl command
apiVersion: apps/v1
kind: Deployment
metadata:
name: lighthouse
spec:
replicas: 6
selector:
matchLabels:
app: lighthouse
template:
metadata:
labels:
app: lighthouse
spec:
containers:
- name: lighthouse
image: docker.admantium.com/lighthouse:0.1.4
imagePullSecrets:
- name: registry-secret

Conclusion

Footnotes

  1. Kubernetes can be installed with various distributions, ranging from enterprise level like OpenShift, Rancher or Canonical, to medium sized applications with MicroK8S and K3S, to local development Docker Desktop or Kubeadm.
  2. There is a trick to define Nginx config files with Consul Templates. Template files will listen on Consul DNS changes, rewrite the files, then reload Nginx. See official documentation.

--

--

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