Simplifying the developer experience has been the mainstay of the Cloud Foundry community’s efforts. In keeping up with the needs of software developers and infrastructure operators, Cloud Foundry has also evolved to help take advantage of the power of Kubernetes, while providing a meaningful abstraction over it.
This tutorial is meant for users who would like to get the Cloud Foundry experience over a Kubernetes cluster hosted on DigitalOcean.
Prerequisites — Please check if you’ve already installed doctl, kubectl, cf cli, bosh cli, ytt, and kapp. Prerequisites part-2: A functional DigitalOcean account, with a 2-node Kubernetes cluster. Note — you can install cf-for-k8s with 2 nodes, but to operate any application at scale, you would need a larger cluster.
Create the cluster and wait for it to be ready before beginning the installation process.
Installation
First, set the context for kubectl on your local machine using the following command:
doctl kubernetes cluster kubeconfig save <cluster-name>
Next, clone the cf-for-k8s repo from GitHub.
Switch into the cf-for-k8s directory.
cd cf-for-k8s
Create a temporary directory used as a swap space for storing some YAML files.
mkdir ~/tempdir
Use the autogen script available in the repo to generate the YAML file for your cf-for-k8s deployment. [1]
./hack/generate-values.sh -d <cf-domain> > ~/tempdir/cf-values.yml
Digital Ocean does not include a metrics server by default when creating a Kubernetes cluster. So, please add this line to the YAML file manually to instruct the cluster to add a metrics server when installing cf-for-k8s.
echo “add_metrics_server_components: true” >> ~/tempdir/cf-values.yml
You will also need to add credentials to a container registry. I’m using my publish Docker hub credentials If you have a private container registry, you can substitute the values to point to your own -
app_registry:
hostname: https://index.docker.io/v1/
repository_prefix: “**********”
username: “**********”
password: “●●●●●●●●●●”
Use the templating tool to generate the final YAML files which will be used for installation.
ytt -f config -f ~/tempdir/cf-values.yml > ~/tempdir/cf-for-k8s-rendered.yml
Install cf-for-k8s by using the kapp command to deploy the artifacts indicated in the YAML file generated in the previous step
kapp deploy -a cf -f ~/tempdir/cf-for-k8s-rendered.yml -y
[1] Please note — you don’t have to use the YAML generator. You can create the file by yourself. This is a convenience. Also, FYI — when using the autogen script, you will receive a warning about it being a temporary/demo script.
Configuring the DNS
In this tutorial, we are using hostnames to point to the Kubernetes cluster running Cloud Foundry. A couple of additional steps are required to make this functional.
1. Add the DigitalOcean nameservers to the DNS management console of your domain registrar. This will render them as a custom nameserver entry.
2. Add the domain name with three nameservers (NS) entries on Digital Ocean. These entries are found under the “Networking” tab of the DigitalOcean console.
3. Add an A name entry to the same table which will enable a wildcard subdomain redirection. This will be of the form “*.domain.ext” and should point to the external IP of the load balancer created during installation. [2]
Once you complete this, an A name entry will be added to the DNS records.
4. One default load balancer behavior on DigitalOcean cloud is the assignment of health checks to a random port. This will render the load balancers’ status as “down”. To change this, point the health check to port 80.
Note — This step should be done only after the cf-for-k8s installation is completed successfully. This completes the whole installation process.
You can check if the Cloud Foundry on Kubernetes is functional by running cf commands.
cf api --skip-ssl-validation api.padarekha.comcf login
(use the default admin credentials Email: admin; Password: <check cf-values.yml>)
Thereafter, you should be able to deploy an application just like you would on any Cloud Foundry installation. Installing cf-for-k8s will allow you to experience the power of Kubernetes with the simplicity of Cloud Foundry.
Source: Medium - Ram Iyengar
The Tech Platform
Comments