Moving To Cloudflare Pages
06 March, 2023
At the time of writing, my personal website (along with a few other applications) has been running in a bare-metal Kubernetes cluster for about a year, which I am now officially sick of maintaining. Having a cheap Kubernetes cluster for learning purposes is great, but hosting my website there means it needs to be maintained, which I now realise is more time consuming than I would like.
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, but preferrably free
- Little to no maintenance
Cloudflare pages
Regardless of one’s opinion on whether a massive global entity MITM’ing majority of the internet is a good or a bad thing, it’s hard to compete with the plethora of benefits using Cloudflare brings you out of the box.
Not only will they provide DNS management and a TLS certificate, but their edge-network can be leveraged for hosting a static (or dynamic if you include workers) website.
All of this is free of charge.
Cloudflare recently they rolled out Cloudflare pages, a service designed especially for hosting JAMstack websites. You can go read the marketing blurb yourself, but for the purposes of this post you can think of it as a the Cloudflare’s interpetation of Vercel.
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 }}
Conclusions
I can now render my Kubernetes cluster inoperable with all sorts of moronic experiments, but this website will remain available, because it’s served from the fastest edge-network in the world, free of charge.