Logo

dev-resources.site

for different kinds of informations.

Building and Deploying a New API (Part 3)

Published at
1/10/2025
Categories
kubernetes
caddy
dns
ssl
Author
m_dango
Categories
4 categories in total
kubernetes
open
caddy
open
dns
open
ssl
open
Author
7 person written this
m_dango
open
Building and Deploying a New API (Part 3)

Previous Post

Time to get into Kubernetes! I'm going to go through this process manually at first, in order to familiarize myself with some of the details, before I start involving tools such as Terraform and Helm.

I've explored Caddy in the past, and I'm highly fond of its automatic HTTPS and straightforward syntax, so part of this setup is going to be configuring Caddy to be used as a reverse proxy:

demo-api.dango.space, localhost {
        respond / "Hello, World!"
        respond /health-check 204
        reverse_proxy localhost:8080
}
Enter fullscreen mode Exit fullscreen mode

This will need to be available to our Caddy container. To do this we'll use the command kubectl create configmap. The Caddyfile can be used with the from-file flag and we can use the output flag to create our configmap.yaml file.

In our deployment.yaml file, we'll be adding the Caddy container.

- name: caddy
  image: caddy:2.9-alpine
  ports:
    - containerPort: 80
    - containerPort: 443
  volumeMounts:
    - name: caddyfile-volume
      mountPath: /etc/caddy/Caddyfile
      subPath: Caddyfile

    - name: caddy-data
      mountPath: /data
Enter fullscreen mode Exit fullscreen mode

The data directory needs to be persisted, so a PersistentVolume and PersistentVolumeClaim have been created to handle this.

In a later post I'll be taking a look at moving this over to an ingress controller.

Our demo-api image has been added to the deployment.yaml, and the ports opened up in our service.yaml. We have a cluster created on Digital Ocean, so we'll run kubectl apply to provision our resources. We'll obtain our external IP address with kubectl get services, add a new record to our domain, and we should be good to go!

https://demo-api.dango.space/

The state of the repository as of this post can be found here.

A link to the next part will be available once it is written.

caddy Article's
30 articles in total
Favicon
Building and Deploying a New API (Part 3)
Favicon
I Built a CaddyFile Generator Tool in Just 8 Hours – Here’s How It Went
Favicon
Caddy
Favicon
Caddy
Favicon
How to Set Up n8n on DigitalOcean with Docker and Caddy
Favicon
Step-by-Step Guide to Hosting Your Website on a VPS Using Caddy Server and Cloudflare
Favicon
How to manage SSL Certs with Caddy
Favicon
Effortless Web Hosting with Caddy: A Beginner’s Guide
Favicon
Path-Based Reverse Proxying with Caddy
Favicon
Deploy firefox as container
Favicon
Switch from NGINX to Caddy
Favicon
Self Hosting with Tailscale and Caddy
Favicon
How to Dockerize an Angular App for Production
Favicon
Compute Caddy payload using Jinja2 with Ansible
Favicon
Using the same Caddyfile for both development and production
Favicon
Configuring Wildcard Subdomains: A Comparison of Nginx and Caddy
Favicon
No more self signed certificate warnings: HTTPS local development using Caddy 2 on macOS
Favicon
Prevent Caddy's automatic http-to-https redirect
Favicon
Routing multiple paths to a reverse proxy using Caddy
Favicon
Generating SSL certificates for SaaS customers without the hefty price tag
Favicon
Caddy Server - Basic Configuration
Favicon
Using Caddy for automatic SSL certificates with Cloudflare
Favicon
From ALB to Caddy - Our Wandering Path to Supporting Thousands of Domain Names
Favicon
Use hex.docs locally
Favicon
AWS Lightsail Container Services with Reverse Proxy
Favicon
TOP 5 Design-to-Code, Figma-to-Code Tools: FUNCTION12, Anima, and More
Favicon
Install Snipe-IT on Ubuntu 22.04 - HostnExtra
Favicon
Install Caddy on Ubuntu 22.04 - HostnExtra
Favicon
Caddy in Docker with common_log
Favicon
How to deploy Caddy on Tencent Cloud CVM

Featured ones: