herald

command
v0.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 1, 2022 License: MIT Imports: 7 Imported by: 0

README

Herald

herald means a messanger.
It is a sample app to test pub/sub of backing emqx message broker
using elio library.

If you run skaffold with assets.k8s/skaffold.yaml,
it is configured as follows in a Kubernetes:

docs/images/herald.helm




Prerequisites

Setting Skaffold on WSL

Setting up elio

Before start, set up elio project.

git clone https://github.com/cppis/elio && cd elio
go mod vendor
export ELIO_ROOT=$(pwd)

$ELIO_ROOT is the project root path.




Running app on Host

Using go run

To run herald service, run the following command:

HERALD_IN_URL="0.0.0.0:7002" go run app/herald

You can change the listening url of service herald by changing
environment variable HERALD_IN_URL.




Running app on Kubernetes

Create a Kind cluster

To create a kind, run the following command:

kind create cluster --config app/herald/assets.k8s/kind.cluster.yaml --name elio

To check if the kind cluster is up and running, run the following command:

kubectl config current-context
  kind-elio
Using the Helm

To deploy using helm, run the following command:

helm upgrade --install herald app/herald/assets.k8s/helm

Using the Kind+Skaffold

To run herald using Skaffold,
run the following command in the Project root directory:

skaffold -f app/herald/assets.k8s/skaffold.yaml dev -vdebug

To change detection triggered to manual mode, use option --trigger=manual.

Or, to run herald in debugging mode using Skaffold, run the following command:

skaffold -f app/herald/assets.k8s/skaffold.yaml debug

using Helm
cd $ELIO_ROOT
helm install herald .
helm uninstall herald

using Docker
docker build --no-cache -t localhost:5001/skaffold-herald:latest -f app/herald/assets.k8s/Dockerfile .
docker push localhost:5001/skaffold-herald:latest




Testing app

You can test echo easily by using telnet.

app protocol is custom t2p like http.
procotol header is separated by newline(\n or \r\n).
And packet delimiter is double newline(\n\n or \r\n\r\n).

connect: connect to echo using telnet
telnet localhost 7002
echo: echo message
echo<newline>
{message}<newline><newline>
sub: subcribe to topic
sub<newline>
{topic}<newline><newline>
unsub: unsubcribe from topic
unsub<newline>
{topic}<newline><newline>
pub: publish message to topic
pub<newline>
{topic}<newline>
{message}<newline><newline>




Debugging Tips

  • Running telnet in Kubernetes:
kubectl run -it --rm --restart=Never busybox --image=gcr.io/google-containers/busybox -- sh
  • Port forwarding a pod in Kubernetes:
kubectl port-forward $(kubectl get pods --selector=app=herald --output=jsonpath={.items..metadata.name}) 7002:7002







Ending app

Kubernetes resource cleanup

After running skaffold run or skaffold deploy and deploying your app to a cluster, running skaffold delete will remove all the resources you deployed. Cleanup is enabled by default, it can be turned off by --cleanup=false

Ctrl + C

When running skaffold dev or skaffold debug, pressing Ctrl+C (SIGINT signal) will kick off the cleanup process which will mimic the behavior of skaffold delete. If for some reason the Skaffold process was unable to catch the SIGINT signal, skaffold delete can always be run later to clean up the deployed Kubernetes resources.

To enable image pruning, you can run Skaffold with both --no-prune=false and --cache-artifacts=false:

skaffold dev --no-prune=false --cache-artifacts=false
Delete a Kind cluster

To delete a kind, run the following command:

kind delete cluster --name elio




Reference




TO-DO

  • Run emqx as stateful cluster in kubernetes

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL