Deploying a Bosh Release

Kieran Robinson
4 min readJun 8, 2019

This is a short post about deploying a bosh release and walking through some errors which we will face once deploying. In our example we are going to deploy the ha-proxy bosh release however feel free to experiment with others.

I think this will be beneficial as even though there is a lot of material out there around Bosh and how to get up and running pretty quickly, when things fail (which they do) I think there could be more tutorials to discuss how to resolve those issues.

In order to follow along with the demo I am assuming you already have a bosh director up and running. If your new to bosh I would highly recommend looking at https://ultimateguidetobosh.com/ which is written by Dr Nic.

All bosh releases can be found at https://bosh.io/releases

As already mentioned we will be using https://github.com/cloudfoundry-incubator/haproxy-boshrelease

Lets get started!!

git clone https://github.com/cloudfoundry-incubator/haproxy-boshreleasecd haproxy-boshrelease

Login to your bosh director

bosh -e <director env name> login

Lets just try and deploy the haproxy bosh release without changing anything to see what bosh throws back at us.

bosh -e <director env name> -d haproxy deploy manifests/haproxy.yml

When we run this we get the following error returned. Error: Instance group ‘haproxy’ references an unknown vm type ‘default’

This is telling us that we either need to add a default vm type to the cloud config or we can create an ops-file to override the vm type which is set in the base manifest. Just to be clear the base manifest is manifests/haproxy.yml

We are going to create an ops-file to replace the default value of the vm type. The path for this is at the following location.

path: /instance_groups/name=haproxy/vm_type

We will create an ops-file like the below and call it vm_type.yml. In my example I am storing all the ops-file in a different directory called haproxy_demo_deployment.

Just to be clear also as we are setting the vm_type to small, we already have that set in the cloud config.

---
- type: replace
path: /instance_groups/name=haproxy/vm_type
value: small

Lets run the below command and see what happens.

bosh -e <director env name> -d haproxy deploy manifests/haproxy.yml -o ../haproxy_demo_deployment/vm_type.yml

When we run this we get the following error. Error: Instance group ‘haproxy’ references an unknown network ‘default’

Cool!! We have resolved the first issue. Now lets look at whats wrong now. Bosh is telling us just like before “hey you told me to deploy haproxy to a network called default but I don’t know what that is!”

Just like before lets create another ops-file to replace the default network to something we have already configured in the cloud config. We will call this networks.yml

---
- type: replace
path: /instance_groups/name=haproxy/networks/0
value:
name: haproxy-test

Now run the following

bosh -e <director env name> -d haproxy deploy manifests/haproxy.yml -o ../haproxy_demo_deployment/vm_type.yml -o ../haproxy_demo_deployment/networks.yml

Bosh gives us the following error:

  • Unable to render templates for job ‘haproxy’. Errors are:
    Failed to fetch variable ‘/env/haproxy/haproxy-backend-servers’ from config server: Director is not configured with a config server

This is telling us that bosh expected a variable called haproxy-backend-servers to be passed in with the deployment. We can either pass these in with the -v parameter or we can create a vars file. For the purpose of this demo lets create a vars file like the below. This will just be called vars-file.yml

haproxy-backend-port: 80
haproxy-backend-servers:
- 10.10.10.10
- 10.10.10.11

Lets now run the below command

bosh -e <director env name> -d haproxy deploy manifests/haproxy.yml -o ../haproxy_demo_deployment/vm_type.yml -o ../haproxy_demo_deployment/networks.yml --vars-file=../haproxy_demo_deployment/vars-file.yml

If everything has went to plan you should now have a haproxy bosh release deployed 🙌

Running the below should show that we have one haproxy vm running

bosh -e <director env name> -d haproxy vms

Cool! So we have now successfully deployed the haproxy bosh release. But lets scale it to two instances.

As you may have guessed we are going to do this by using another ops file. This time called scale-vms.yml

---
- type: replace
path: /instance_groups/name=haproxy/instances
value: 2

Now run the following

bosh -e <director env name> -d haproxy deploy manifests/haproxy.yml -o ../haproxy_demo_deployment/vm_type.yml -o ../haproxy_demo_deployment/networks.yml -o ../haproxy_demo_deployment/scale-vms.yml --vars-file=../haproxy_demo_deployment/vars-file.yml

You should see the following

Release 'haproxy/9.6.0' already exists.instance_groups:
- name: haproxy
- instances: 1
+ instances: 2

This is bosh telling us that the only change to the deployment will be that of adding an extra VM. Apply that change!! 😎

Running the bosh vms command as previous will now show that we have two running VM’s.

There are times when you might want to use a specific version of a release versus for example using the latest.

The ops file we are going to create next is just to say instead of using the latest version of BPM lets use version 1.0.3.

Just to be clear this is just an example to show how to change the version of a release, you may always want to use the latest version!

---
- type: replace
path: /releases/name=bpm/version
value: 1.0.3

Now run the following

bosh -e <director env name> -d haproxy deploy manifests/haproxy.yml -o ../haproxy_demo_deployment/vm_type.yml -o ../haproxy_demo_deployment/networks.yml -o ../haproxy_demo_deployment/scale-vms.yml -o ../haproxy_demo_deployment/versions.yml --vars-file=../haproxy_demo_deployment/vars-file.yml

Bosh returns the following to screen

releases:
- name: bpm
- version: 1.0.4
+ version: 1.0.3

This is telling us, I was originally using the latest BPM version but now you have specified to use version 1.0.3. Bosh will now update the two instances to be running BPM version 1.0.3.

I hope you have found this beneficial, thanks for reading!

--

--