Moving To Cloudflare Pages
06 March, 2023
At the time of writing, my personal website (along with a few other applications) is running in a bare-metal Kubernetes cluster, which I am officially sick of maintaining.
Having a cheap Kubernetes cluster for learning purposes is great, but hosting this blog there means it needs to be maintained and kept operational at all times, which I’m now starting to realize is a lot more time-consuming than I thought it would be.
It was time to look for a new hosting solution.
Requirements
My list of demands for the a new hosting solution was short:
- CDN
- Cheap, preferrably free
- Little to no maintenance
Cloudflare pages
Regardless of one’s opinion on whether a massive global entity MITM’ing the majority of the internet is a good or a bad thing, it’s hard to argue against the benefits Cloudflare brings out of the box and free of charge. Not only do they provide DNS management and free TLS certificates, but their edge-network can be used to host a static (or dynamic if you include workers) website.
This fits my list of requirements exactly!
Cloudflare recently rolled out Cloudflare pages, a service designed for hosting (mostly) static websites.
You can go read the marketing blurb yourself, but for the purposes of this post you can think of it as “static web hosting with integrated platform features”.
Deployments
Cloudflare pages includes built-in “GitOps” capabilities, but after watching the automation fail to compile my website, using a framework it claimed to support (Hugo), I surmised it would probably be easier to just upload the static file bundle directly using Wrangler and Github Actions:
jobs:
Build-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Hugo init
uses: peaceiris/actions-hugo@v2
with:
hugo-version: '0.101.0'
extended: true
- name: Compile static bundle
run: hugo --minify -d ${{ env.BUILD_NAME }}
- name: Deploy bundle
uses: cloudflare/[email protected]
with:
accountId: ${{ secrets.CF_ACCOUNT_ID }}
apiToken: ${{ secrets.CF_API_TOKEN }}
command: pages publish ${{ env.BUILD_NAME }} --project-name=${{ env.PROJECT_NAME }}
In Conclusions
I can now render my Kubernetes cluster inoperable with all sorts of moronic experiments, but this blog will remain available, because it’s served from the fastest edge-network in the world, completely free of charge.