Tutorial: How To Deploy A Go Web App to Kubernetes Using Cloud Foundry

Ram Iyengar
Cloud Foundry Foundation
2 min readJan 25, 2021
How to Deploy a Go Web App to K8s Using Cloud Foundry

In this tutorial, you will learn how to deploy a Go web application to Kubernetes by making use of Cloud Foundry as a PaaS tool. We will also learn how to scale applications that are deployed.

Just a few notes about setting the right context:

  1. Our target remote instance is a Kubernetes cluster running on Google Cloud.
  2. Cloud Foundry — specifically the cf-for-k8s project, is installed on this cluster.
  3. CF-for-k8s provides a PaaS abstraction over the Kubernetes cluster.
  4. Make sure that the CF cli is connected to the remote target.

Steps to follow for deployment:

  1. Check out a repo (Go Sample App) available publicly on GitHub.
  2. CD into the top-level directory of the app.
  3. Use the cf push command to deploy the application.

The source that is checked out has a manifest.yml file which supplies certain parameters for deployment. Please note that this YAML file is optional. It is a great way for platform operators to specify certain parameters for deployment.

---                       
applications:
- name: test-app
memory: 256M
instances: 1
random-route: true

The second part of the same tutorial covers how to scale applications. This is done by using a single command:

cf scale test-app -i 3

The main advantage of this approach is an abstraction of complexity and automation of several moving parts. The use of horizontal pod autoscalers and replica sets are obfuscated from the purview of both developers and platform operators. Assigning load balancers, configuring them, and routing requests happen automatically. This ends up providing a great developer experience for users of Cloud Foundry, especially when using it over Kubernetes.

Learn more about the CF-for-k8s project, or join in on the conversation over at our Slack community.

--

--

Ram Iyengar
Cloud Foundry Foundation

culture vulture. (d)evangelist. help tech find people, and vice versa.