I explain about how to deploy OpenFaaS on Kubernetes on Azure. However, OpenFaaS supports Swarm as well. What is the most easy way to deploy it? Since the OpenFaaS requires docker ce for 17.05+, we can't use Azure Container Service. Instead, we can use Docker for Azure. It is the most easiest way to deploy 17.06+ swarm mode cluster on Azure, currently.
Let's deploy it.
Deploy Docker for Azure
Go to this site. You can deploy the cluster directly. Just click "Deploy Docker Community Edition for Azure (Stable)"
Then you can see this page. You can edit the template if you like.
Connect to the Docker for Azure
After the deployment, you can find the externalSSHLoadBalancer which have an IP address to access the master nodes.
If you have three master nodes, then the SSH port will be 50000, 50001, and 50002. You can check it out on the externalSSHLoadBalancer > Inbound NAT Rules
You can tunnel it to deploy OpenFaaS. If the loadbalancer's IP is 220.127.116.11, then the command is like this. NOTE: the default user name is docker. not azureuser!
ssh -p 50000 -fNL localhost:2374:/var/run/docker.sock email@example.com export DOCKER_HOST=:2374
Just clone the OpenFaaS and deploy it.
git clone firstname.lastname@example.org:alexellis/faas.git cd faas ./deploy-stack.sh
Finish. Then you can check it out. If the all nodes status is OK and replicas are not 0, then it works.
$ docker node ls ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS 19jwb8riabdtgbrgbhcaohv7v swarm-manager000002 Ready Active Leader 5r4cghmtsiyt96cfmzbeavhb5 * swarm-manager000000 Ready Active Reachable guc9klap92wy9w393d4s29vir swarm-manager000001 Ready Active Reachable ubwo378qzjq4pl45rrixusfa9 swarm-worker000000 Ready Active xm12qzvwqyuspzcy3fs3o2a5f swarm-worker000001 Ready Active $ docker service ls ID NAME MODE REPLICAS IMAGE PORTS 0z3nhuc3322r func_decodebase64 replicated 1/1 functions/alpine:health 5k222fmec6pb func_nodeinfo replicated 1/1 functions/nodeinfo:latest 6dscv6uctk8p func_hubstats replicated 1/1 functions/hubstats:latest ki6r1w1f5cdm func_wordcount replicated 1/1 functions/alpine:health mji9f788qktk func_gateway replicated 1/1 functions/gateway:0.6.3 *:8080->8080/tcp mktgocot0uxq func_echoit replicated 1/1 functions/alpine:health nz764gxdg99k func_prometheus replicated 1/1 functions/prometheus:latest *:9090->9090/tcp u8s2kw7755q2 func_webhookstash replicated 1/1 functions/webhookstash:latest ubbtcade7skw func_markdown replicated 1/1 alexellis2/faas-markdownrender:latest xulsluhy3zvv func_alertmanager replicated 1/1 functions/alertmanager:latest *:9093->9093/tcp yw7s4ut1xt99 func_base64 replicated 1/1 functions/alpine:health
Open the OpenFaaS potal
As you can see, All you need to do is find the externalLoadBalancer on the Resource Group, then access the URL with port 8080. You can refer OpenFaaS on ACS (Kubernetes) for seeing the faas-cli setting.