Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Daniel Mita
Daniel Mita

Posted on

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 modeExit fullscreen mode

This will need to be available to our Caddy container. To do this we'll use the commandkubectl create configmap. TheCaddyfile can be used with thefrom-file flag and we can use theoutput flag to create ourconfigmap.yaml file.

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

-name:caddyimage:caddy:2.9-alpineports:-containerPort:80-containerPort:443volumeMounts:-name:caddyfile-volumemountPath:/etc/caddy/CaddyfilesubPath:Caddyfile-name:caddy-datamountPath:/data
Enter fullscreen modeExit fullscreen mode

Thedata directory needs to be persisted, so aPersistentVolume andPersistentVolumeClaim have been created to handle this.

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

Ourdemo-api image has been added to thedeployment.yaml, and the ports opened up in ourservice.yaml. We have a cluster created on Digital Ocean, so we'll runkubectl apply to provision our resources. We'll obtain our external IP address withkubectl 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 foundhere.

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

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Raku/Perl Developer
  • Joined

Trending onDEV CommunityHot

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp