- An Azure Subscription (you can also create a free account)
- A Linux machine (or the great Linux Subsystem on Windows 10)
- A working installation of Kubectl (tutorial here)
You can choose to deploy the ACS Kubernetes cluster using Azure CLI or acs-engine. In this readme you can find a quick guide for the both.
-
Install the official latest version of Azure CLI
-
Login to your subscription
az login
Optional: If you have multiple subscriptions linked to your account, remember to select the one on which you want to work. (az account set -s subscription-id)
-
Create the resource group in which you want to deploy the cluster (in the example k8sRG is the name of the Resource Group and westeurope is the chosen location)
az group create -l westeurope -n k8sRG
-
Finally create your cluster. This will create a default cluster with one master and three agents (each VM is sized, by default, as a Standard_D2_v2 with 2vCPUs and 7GiB of RAM)
az acs create --orchestrator-type Kubernetes -g k8sRG -n k8sCluster -l westeurope --generate-ssh-keys
Optional: you can specify the agent-count, the agent-vm-size and a dns-prefix for your cluster --agent-count 2 --agent-vm-size Standard_A1_v2 --dns-prefix k8sdanigian
-
Get your cluster credentials ready for kubectl
az acs kubernetes get-credentials -n k8sCluster -g k8sRG
-
Download acs-engine
-
Download and eventually modify the cluster definition file (can find an example here)
-
Using the just downloaded cluster definition file ("kubernetes.json" in the example), execute acs-engine as below, in order to deploy your cluster on Azure Container Service:
./acs-engine deploy --subscription-id your-subscription-id-here
--dns-prefix friendly-dns-prefix --location westeurope
--auto-suffix --api-model ./kubernetes.json -
After a successful deployment, acs-engine will output ssh keys and a list of kubeconfig files in the "_output" directory. Please choose the json file corresponding to your region and use that to replace your kubeconfig file (you can usually find it in ${HOME}/.kube/config)
You may now use kubectl and go on with the deployment of OpenFaaS to your cluster.
-
Check if the kubectl configuration is ok and if your cluster is up-and-running
kubectl cluster-info
-
Clone the faas-netes repository
-
Deploy faas-netes to ACS
kubectl apply -f ./faas.yml,monitoring.yml
-
Optional: you may choose to expose the gateway to the internet. This could be useful to invoke functions from the internet.
kubectl edit svc/gateway
When the editor pops up, change the spec/type to LoadBalancer then save and close the file (NodePort is the default spec/type for the gateway).
Congratulations! You now have OpenFaaS deployed to your Azure Container Service!
If you already know what to do now, go ahead and do it!
Otherwise, you can try to deploy an "Hello World" .NET Core 2.0 function to OpenFaaS!
In order to do that you will need a fully functioning Docker installation on your machine and an account on Docker Hub.
-
Install the OpenFaaS CLI
curl -sSL https://cli.openfaas.com | sudo sh
-
Get the domain and port of your externally esposed gateway
kubectl get svc/gateway
-
Create a new C# Function
faas-cli new --name your-function-name --lang csharp --gateway=http://domain:port
-
Eventually modify the code of your "Hello World" function
-
Build, push and deploy your newly created function.
faas-cli build -f your-function-name.yml [--no-cache]
faas-cli push -f your-function-name.yml
faas-cli deploy -f your-function-name.yml
The --no-cache option is optional but very useful when updating the code of your function
- Test your function with CURL or Postman by just invoking it with a POST request to: http://domain:port/function/your-function-name