Skip to content
Kubernetes

Kubernetes

The Kubernetes example runs the Docker image as a pod or a CronJob, with its settings in a ConfigMap and a hardened security context.

FileHolds
configmap.yamlThe settings file, as the speedtest-settings ConfigMap
pod.yamlA pod that runs one speed test
cronjob.yamlA CronJob that runs a speed test every six hours

Run it

  1. Create the settings:

    kubectl apply -f https://raw.githubusercontent.com/nicholas-fedor/speedtest-go/master/example/kubernetes/configmap.yaml
  2. Run a speed test once, and read its JSON results once the pod has finished:

    kubectl apply -f https://raw.githubusercontent.com/nicholas-fedor/speedtest-go/master/example/kubernetes/pod.yaml
    kubectl wait --for=jsonpath='{.status.phase}'=Succeeded pod/speedtest --timeout=3m
    kubectl logs speedtest
  3. Or run speed tests on a schedule:

    kubectl apply -f https://raw.githubusercontent.com/nicholas-fedor/speedtest-go/master/example/kubernetes/cronjob.yaml

    To try the CronJob without waiting for its schedule, start a job from it:

    kubectl create job speedtest-now --from=cronjob/speedtest

Settings

ToDo
Change the defaultsEdit the ConfigMap and apply it again. The next run reads the new settings
Override a setting with a flagAdd it to the container’s args, such as args: ["--server", "6691"]
Override a setting with a variableAdd it to the container’s env, such as SPEEDTEST_GO_SERVER with the value 6691,6087

Flags go in args, since the image’s entrypoint is speedtest-go. ICMP pings do not work in the image, so use --ping-mode http or tcp.