How To Deploy a Static Site(Gatsby) to Kubernetes With Cloud Foundry

Shedrack Akintayo
Cloud Foundry Foundation
2 min readJan 14, 2021
Deploy a Static Site Built with Gatsby to Kubernetes With Cloud Foundry

A lot of our application tech stack these days has to have some form of static content being served on the client side of our application, these could be just HTML, CSS and Javascript or it could be some javascript framework (React, Vue) or maybe a static site generator (Gatsby, Hugo, Jekyll). Cloud Foundry caters for this part of our system and we can easily deploy the static content to kubernetes with Cloud Foundry.

Here’s a short video that helps you understand how to deploy a static site to Kubernetes using Cloud Foundry. For the purpose of this tutorial, we will be using Gatsby as the preferred static site framework/generator.

Here’s a quick summary of the steps that you would need to take:

  1. Install cf-for-k8s on any of your preferred infrastructure (local machine, GKE, Digital Ocean)
  2. Clone the application repository (Github, Gitlab etc.)
  3. Navigate to the application folder
  4. Log on to the Cloud Foundry CLI by typing cf login in your terminal and provide the appropriate credentials.
  5. Create a manifest.yml file which will contain various instructions for how Cloud Foundry should deploy your application. For example:
Example of a manifest.yml file

6. Deploy the app using the cf push <app-name> command and remember to specify an app name. In this case, static-site-demo is the name of the app that is being used. Wait until the deployment completes successfully.

7. Copy the route that is generated and open it in a browser. You will be able to access the app live one the browser.

If you’d like to know more about the #cf-for-k8s project or Cloud Foundry in general, please join us on Slack. You can also reach out to us via our Twitter handle @cloudfoundry!

--

--