add example for js client. plus general cosmetic improvements
## Creating Your Own `khcheck`
+#### Creating your own `khcheck` client is simple! :)
+
### Using Go
-Creating your own `khcheck` is very easy. If you are using Go, we have an easy to use client package at [github.com/Comcast/kuberhealthy/v2/pkg/checks/external/checkclient](https://godoc.org/github.com/Comcast/kuberhealthy/v2/pkg/checks/external/checkclient).
+If you are using Go, we have an easy to use client package: [found here](https://godoc.org/github.com/Comcast/kuberhealthy/v2/pkg/checks/external/checkclient).
+
+example code:
+
+```go
+package main
+
+import (
+ "github.com/Comcast/kuberhealthy/v2/pkg/checks/external/checkclient"
+)
-<img src="../images/example check.png">
+func main() {
+ ok := doCheckStuff()
+ if !ok {
+ checkclient.ReportFailure([]string{"Test has failed!"})
+ return
+ }
+ checkclient.ReportSuccess()
+}
+
+```
An example check with working Dockerfile is available to use as an example [here](../cmd/test-external-check/main.go).
@@ -20,9 +40,27 @@ Please see the [example check](../clients/js/example) under the same folder with
The kuberhealthy [NPM package](https://www.npmjs.com/package/kuberhealthy) is conformant with the reference sample syntax but also supports async/await as well as arbitrary host and port.
-- read the docs: [kuberhealthy-client](https://github.com/gWOLF3/kuberhealthy-client)
+- more info: [kuberhealthy-client](https://github.com/gWOLF3/kuberhealthy-client)
- get started: `npm i --save kuberhealthy`
+
+example code:
+```javascript
+const kh = require('kuberhealthy')
+
+const report = async () => {
+ let ok = await doCheckStuff()
+ if (ok) {
+ await kh.ReportSuccess()
+ } else {
+ await kh.ReportFailure()
+ }
+
+report()
+```
+> _NOTE: KH_REPORTING_URL must be set in your env. This is usually done automatically if running as 'khcheck' on kubernetes._
+
+
### Using Another Language
Your check only needs to do a few things:
@@ -41,7 +79,7 @@ Your check only needs to do a few things:
}
```
-Never send `"OK": true` if `Errors` has values or you will be given a `400` return code.
+> Never send `"OK": true` if `Errors` has values or you will be given a `400` return code.
Simply build your program into a container, `docker push` it to somewhere your cluster has access and craft a `khcheck` resource to enable it in your cluster where Kuberhealthy is installed.
