Skip to content

andrleite/relayr-app

Repository files navigation

relayr-app

A cloud native app run in minikube

Go Report Card codecov Build Status

Getting Started

Pre Requisites

Starting minikube and enable addons

minikube start
minikube addons enable ingress
minikube addons enable metrics-server

Creating and deploy ssl certificates

openssl req -x509 -newkey rsa:4096 -sha256 \
            -nodes -keyout hack/certs/tls.key \
            -out hack/certs/tls.crt \
            -subj "/CN=relayr.app" \
            -days 365
  • Now with ssl certificates created, let's deploy it on minikube
  • First of all we'll create namespace.
kubectl create ns relayr
  • Now we can create a secret to store tls certificates
kubectl --namespace relayr create secret tls relayr-tls \
        --cert=hack/certs/tls.crt \
        --key=hack/certs/tls.key

Initializing helm and update dependencies

helm init
helm dep update helm/relayr-app

Deploy the realyr app

helm install -n relayr \
  --namespace relayr helm/relayr-app/
  • setting app domain to etc/hosts
echo "$(minikube ip) relayr.app" | sudo tee -a /etc/hosts

API

/sensors

  • GET : Get all iot sensors
  • POST : Create a new iot sensor

/sensors/:id

  • GET : Get a iot sensor
  • PUT : Update a iot sensor
  • DELETE : Delete a iot sensor

examples:

  • create new sensor
curl  --cacert hack/certs/tls.crt \
      -X POST \
      -H "Content-Type: application/json" \
      -d '{"name": "sensorX", "type": "temperature"}' \
      https://relayr.app/sensors
  • get all sensors
curl  --cacert hack/certs/tls.crt \
      https://relayr.app/sensors | jq .
  • get sensor by id
curl  --cacert hack/certs/tls.crt \
      https://relayr.app/sensors/1 | jq .
  • update sensor
curl  --cacert hack/certs/tls.crt \
      -X PUT \
      -d '{"type": "pressure"}' \
      -H "Content-Type: application/json" \
      https://relayr.app/sensors/1
  • delete sensor
curl  --cacert hack/certs/tls.crt \
      -X DELETE \
      -H "Content-Type: application/json" \
      https://relayr.app/sensors/1

Tear Down

helm del --purge relayr
minikube stop
minikube delete