go-data

go-data is a very simple Go REST API that talks to a device service in the cluster to check if a device exists. It never actually returns device data and simply says: Oh and, no data for you?

curl http://exacerbated-ragdoll.baeke.info/data/device1
Device active:  false
Oh and, no data for you!

When the device service is not deployed or the device that you specify does not exist, you get Device active: false.

The go-data service can be found here: https://github.com/gbaeke/go-data. I only pulled main.go to a new folder and created an empty glide.yaml (touch glide.yaml).

Then use the following draft commands:

draft create
draft up

Although the service gets deployed properly, the curl command did not return the expected result. The reason is pretty simple. If you check charts/templates/deployment.yaml, you will notice that a livenessProbe and readinessProbe are part of the spec. To check if the service is up, / is checked. In the source code of main.go, you will notice that nothing listens on that path.

This can be solved in two ways:

  • modify the source code to also listen on /
  • modify the deployment.yaml: change path under livenessProbe & readinessProbe to /data/device

If draft is watching the folder, an upgrade should start. After the upgrade, check with curl if it works. You can run the following command to check:

kubectl get deployment

The result:

NAME                                      DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
enervated-sloth-enervated-sloth           2         2         2            2           2h
exacerbated-ragdoll-exacerbated-ragdoll   2         2         2            2           33m

When you see 2 under AVAILABLE, it should be fine (if the probes fail, this will be 0)

results matching ""

    No results matching ""