What's the best approach to deploy a static website to K8s cluster from a CI pipeline? - eviltoast

I have a small VPS that hosts some services I use daily and I’d like to migrate that to a K8s cluster. One of the services being hosted is my personal website, built with Hugo and served by Caddy.

Right now, I have the code for my website on Codeberg and I have a CI pipeline that builds the website and uploads it to my VPS via rsync.

I want to move the website to the k8s cluster, but I have no idea how to do it “securely”. What I have right now is a separate user on my VPS called deploy and it rsyncs the files to the data directory Caddy is using to serve my files.

I thought I could do the same on the k8s cluster server, but it’s usually not a good idea to mount host paths with k8s unless absolutely necessary, because container escaping is an actual problem.

So far the only alternative I could think of is to change the CI pipeline to publish my website on another branch and signal it to my K8s cluster so the files should be updated, but I’d like to know what better options exist and how easy they are to setup.

  • xinayder@infosec.pubOP
    link
    fedilink
    English
    arrow-up
    4
    ·
    1 year ago

    I’m not using k8s just to host my website, I have other services on it as well.

    I know it’s overkill for small stuff, but I’m running k3s and not k8s (so it’s a lightweight engine). The reason I’m doing this is for learning purposes, I want to learn more about k8s and thought I could do an experiment with it on a VPS.

    I plan on renting another VPS and adding another node to the cluster, as it’s pretty cheap (Hetzner ARM server costs around 3.8 EUR without VAT with 2 vCPUs and 4GB RAM). For example, it’s much more cheaper than the VPS I have on Vultr that has 1GB RAM and 1 vCPU.

    • Starbuck@lemmy.world
      link
      fedilink
      English
      arrow-up
      2
      ·
      1 year ago

      If you want to build a new container on top of nginx, that will serve a static site like a champ