From 907a55f60deb330e30ca7c55d7a5eae39ba62f47 Mon Sep 17 00:00:00 2001 From: Alex Ellis <alexellis2@gmail.com> Date: Wed, 23 Aug 2017 09:06:36 +0100 Subject: [PATCH] Create deployment_k8s.md --- guide/deployment_k8s.md | 72 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 guide/deployment_k8s.md diff --git a/guide/deployment_k8s.md b/guide/deployment_k8s.md new file mode 100644 index 00000000..71fb93d5 --- /dev/null +++ b/guide/deployment_k8s.md @@ -0,0 +1,72 @@ +# Deployment guide for Kubernetes + +> Note: The best place to start is the README file in the faas or faas-netes repo. + +## Kubernetes + +### Build a cluster + +You can start evaluating FaaS and building functions on your laptop or on a VM (cloud or on-prem). + +* [10 minute guides for minikube / kubeadm](https://blog.alexellis.io/tag/k8s/) + +### Deploy OpenFaaS + +* Clone the code + +``` +$ git clone https://github.com/alexellis/faas-netes +``` + +* Deploy the services + +``` +$ cd faas-netes +$ kubectl apply -f ./faas.yml,monitoring.yml,rbac.yml +``` + +That's it. You now have OpenFaaS deployed. + +For simplicity the default configuration uses NodePorts rather than an IngressController (which is more complicated to setup). + +| Service | TCP port | +--------------------|----------| +| API Gateway / UI | 31112 | +| Prometheus | 31119 | + +> If you're an advanced Kubernetes user, you can add an IngressController to your stack and remove the NodePort assignments. + +* Deploy a sample function + +There are currently no sample functions built into this stack, but we can deploy them quickly via the UI or FaaS-CLI. + +**Use the CLI** + +Follow the tutorial below, but change your gateway URL from localhost:8080 to kubernetes-node-ip:31112 + +i.e. + +``` +provider: + name: faas + gateway: http://192.168.4.95:31112 +``` + +[Your first serverless Python function with OpenFaaS](https://blog.alexellis.io/first-faas-python-function/) + +You can also deploy the samples from the [FaaS-cli](https://github.com/alexellis/faas-cli), but change the gateway address as above. + +**Use the UI** + +Click "New Function" and fill it out with the following: + +| Field | Value | +-------------|------------------------------| +| Service | nodeinfo | +| Image | functions/nodeinfo:latest | +| fProcess | node main.js | +| Network | default | + +* Test the function + +Your function will appear after a few seconds and you can click "Invoke" -- GitLab