Skip to content

Instantly share code, notes, and snippets.

@berndtj
Last active February 14, 2018 08:44
Show Gist options
  • Save berndtj/a70aa578e91a7802b6eacea59ac7180e to your computer and use it in GitHub Desktop.
Save berndtj/a70aa578e91a7802b6eacea59ac7180e to your computer and use it in GitHub Desktop.
Instructions for using Ubuntu OVA

Instructions for using Ubuntu OVA

  1. Download OVA: https://s3-us-west-2.amazonaws.com/dispatch-imgs/Ubuntu_16.04.2_server_amd64_dispatch.ova

  2. VMware fusion users:

  • File -> Import OVA
  1. VMware workstation users:
  • File -> Open OVA
  1. Login to console with credentials: vmware/vmware
  • Get IP address ifconfig (look for the 10.x.x.x address)
  1. SSH to the deployed VM with same credentials: ssh vmware@10.x.x.x

  2. Run ./install-minikube.sh

  • Monitor the installation with watch kubectl -n kube-system get pods
  1. Run helm init

  2. Configure and install Dispatch:

Fetch the IP address of minikube as this will be used the host for dispatch services.

export DISPATCH_HOST=$(minikube ip)

Configure the installation (note: you must substitute the IP address where $DISPATCH_HOST is specified in the below config.yaml):

$ cat << EOF > config.yaml
apiGateway:
  host: $DISPATCH_HOST
dispatch:
  host: $DISPATCH_HOST
  debug: true
  skipAuth: true
EOF
$ dispatch install --file config.yaml
...
Config file written to: $HOME/.dispatch/config.json

Note: You can monitory the installation with watch kubectl -n dispatch get pods

Your dispatch config file $HOME/.dispatch/config.json will be generated and have the following:-

cat $HOME/.dispatch/config.json
{
    "host": "<DISPATCH_HOST>",
    "port": <port>,
    "organization": "",
    "cookie": "",
    "insecure": false,
    "skipauth": true,
    "Json": false
}
  1. Edit the $HOME/.dispatch/config.json file and change "insecure": false to "insecure": true

  2. At this point, the environment is up and working. Let's seed the service with some images and functions.

$ cd code/dispatch/examples/
$ dispatch create --file seed.yaml
$ dispatch get images
   NAME   |                    URL                           |  BASEIMAGE   |   STATUS    |         CREATED DATE
------------------------------------------------------------------------------------------------------------------------
  nodejs6 | vmware/dispatch-openfaas-nodejs6-base:0.0.2-dev1 | nodejs6-base | READY       | Wed Dec  6 14:28:30 PST 2017
  python3 | vmware/dispatch-openfaas-python-base:0.0.4-dev1  | python3-base | INITIALIZED | Wed Dec  6 14:28:30 PST 2017

$ dispatch get functions
    NAME   |  IMAGE  | STATUS |         CREATED DATE
------------------------------------------------------------
  hello-js | nodejs6 | READY  | Wed Dec  6 14:29:05 PST 2017
  hello-py | python3 | READY  | Wed Dec  6 14:28:52 PST 2017
  1. Execute a function:
$ dispatch exec hello-py --input '{"name": "Jon", "place": "Winterfell"}' --wait
{
    "blocking": true,
    "executedTime": 1515624222,
    "finishedTime": 1515624222,
    "functionId": "5138d918-e78f-41d6-aece-769addd3eed7",
    "functionName": "hello-py",
    "input": {
        "name": "Jon",
        "place": "Winterfell"
    },
    "logs": null,
    "name": "b5b3c1f5-fa8a-4b38-b7d1-475c44b76114",
    "output": {
        "myField": "Hello, Jon from Winterfell"
    },
    "reason": null,
    "secrets": [],
    "status": "READY"
}
  1. Add an API endpoint:
$ dispatch create api --https-only --method POST --path /hello post-hello hello-py

Find the port for the api-gateway service (we are using the NodePort service type):

$ kubectl -n kong get service api-gateway-kongproxy
NAME                    CLUSTER-IP     EXTERNAL-IP   PORT(S)                      AGE
api-gateway-kongproxy   10.107.109.1   <nodes>       80:31788/TCP,443:32611/TCP   19m

We are looking at the port associated with https/443 => 32611

$ curl -k "https://$DISPATCH_HOST:32611/hello" -H "Content-Type: application/json" -d '{"name": "Jon", "place": "winterfell"}'
{"myField":"Hello, Jon from winterfell"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment