Skip to content

Instantly share code, notes, and snippets.

@alexellis
Created December 2, 2018 19:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexellis/4a239cb355c9c289f986ec5a2a957c10 to your computer and use it in GitHub Desktop.
Save alexellis/4a239cb355c9c289f986ec5a2a957c10 to your computer and use it in GitHub Desktop.
Deploy on Swarm / Docker for Mac
alexr:faas alex$ docker swarm init
Swarm initialized: current node (64dzd5vqwfxumbhq38s8kqioc) is now a manager.
To add a worker to this swarm, run the following command:
docker swarm join --token SWMTKN-1-2iyl4qp1r2h9g0hitgfowonyo3sh5e762nc4vsus4mefy2xzq7-2rdd4d151hhhjyzew4oxvndvd 192.168.65.3:2377
To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions.
alexr:faas alex$ git clone https://github.com/openfaas/faas && \
> cd faas && \
> ./deploy_stack.sh
Cloning into 'faas'...
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 17401 (delta 0), reused 0 (delta 0), pack-reused 17397
Receiving objects: 100% (17401/17401), 22.00 MiB | 3.93 MiB/s, done.
Resolving deltas: 100% (7118/7118), done.
Checking out files: 100% (2464/2464), done.
Attempting to create credentials for gateway..
t06tb5yxh54h5ny7kuqf3fl2b
wkclhr4slxz1sordfx41nbfgi
[Credentials]
username: admin
password: a600d4714a432ba1ed8904fc95042b095b3d13b98dfc1ce08279462841e2e5ca
echo -n a600d4714a432ba1ed8904fc95042b095b3d13b98dfc1ce08279462841e2e5ca | faas-cli login --username=admin --password-stdin
Enabling basic authentication for gateway..
Deploying OpenFaaS core services
Creating network func_functions
Creating config func_prometheus_rules
Creating config func_alertmanager_config
Creating config func_prometheus_config
Creating service func_nats
Creating service func_queue-worker
Creating service func_prometheus
Creating service func_alertmanager
Creating service func_gateway
Creating service func_faas-swarm
alexr:faas alex$ echo -n a600d4714a432ba1ed8904fc95042b095b3d13b98dfc1ce08279462841e2e5ca | faas-cli login --username=admin --password-stdin
Calling the OpenFaaS server to validate the credentials...
WARNING! Communication is not secure, please consider using HTTPS. Letsencrypt.org offers free SSL/TLS certificates.
credentials saved for admin http://127.0.0.1:8080
alexr:faas alex$
alexr:faas alex$ faas deploy -f \
> https://raw.githubusercontent.com/openfaas/faas/master/stack.yml
Parsed: https://raw.githubusercontent.com/openfaas/faas/master/stack.yml
Deploying: markdown.
Deployed. 202 Accepted.
URL: http://127.0.0.1:8080/function/markdown
Deploying: hubstats.
Deployed. 202 Accepted.
URL: http://127.0.0.1:8080/function/hubstats
Deploying: nodeinfo.
Deployed. 202 Accepted.
URL: http://127.0.0.1:8080/function/nodeinfo
Deploying: echoit.
Deployed. 202 Accepted.
URL: http://127.0.0.1:8080/function/echoit
Deploying: wordcount.
Deployed. 202 Accepted.
URL: http://127.0.0.1:8080/function/wordcount
Deploying: base64.
Deployed. 202 Accepted.
URL: http://127.0.0.1:8080/function/base64
alexr:faas alex$
@pascalandy
Copy link

Here is my how-to to kick things off

How to

### Deploy FaaS
git clone https://github.com/openfaas/faas && \
  cd faas && \
  ./deploy_stack.sh
  
 !! COPY-PASTE the login provided !!
  
### Restore password (if needed)

docker service create --detach --secret basic-auth-password \
   --restart-condition=none --name=print-password \
   alpine:3.7 cat /run/secrets/basic-auth-password

docker service rm print-password

### FaaS login
  
echo -n b013a4433317f92da504b4e3884f0775f8e61144912f7b6e5c97f97216190723 | faas-cli login --username=admin --password-stdin

### Once log in, deploy the demo stacks

faas deploy -f \
  https://raw.githubusercontent.com/openfaas/faas/master/stack.yml
  
### Try the GUI

http://127.0.0.1:8080

### FaaS CLI install

curl -sL https://cli.openfaas.com | sudo sh;

### Validate if CLI is installed properly

faas-cli --help;

### Setup up CLI

export OPENFAAS_URL=127.0.0.1:31112


# — — — # — — — # — — — # — — — # — — — # — —
#   FINALLY WE CAN TRY OUR FIRST FAAS via the CLI
# — — — # — — — # — — — # — — — # — — — # — —

### Invoke a wordcount function

ENV_COUNT_THIS="
This text is used as a placeholder or a tk note. Words that will follow won't make any sense and this is fine. At the moment, the goal is to build a structure for our site.

Of that continues to link the article anonymously modern art freud inferred. Eventually primitive brothel scene with a distinction. The Enlightenment criticized from the history.

## It started slowly

From understanding of the day worked either through 1912 analytic. And criticised Vasari's cult of a broader term that the date. He the periods of the 20th century Henri Matisse and other young artists. 

Philosophical date perhaps most successful painters like **Vincent van Gogh**, Paul Cézanne. Of that all depiction of The Dance signified a national. Psyche broader term that the direct inspiration for Advanced Study.

Cheers!
Pascal Andy
";

FCT_RESULT=$(curl -d ${ENV_COUNT_THIS} http://127.0.0.1:8080/function/wordcount | awk '{print $2}');

echo ${FCT_RESULT} | tail -1;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment