FaaS is a serverless framework that allows you to deploy and manage functions as a service on Kubernetes. It provides a simple and efficient way to run your code in response to events, without the need to manage the underlying infrastructure.
For the C-4 model of this project please go to C4 Model
git clone https://github.com/jairinthecloud1/FaaS.git
cd FaaSThe following dependencies are required to run and develop with FaaS:
| Dependency | Description | Installation Link |
|---|---|---|
| Docker | Containerization platform | Get Docker |
| Kubernetes | Container orchestration system | Kubernetes Tools |
| kubectl | Kubernetes command-line tool | kubectl |
| Helm | Kubernetes package manager | Helm Install |
| Kind | Local Kubernetes clusters using Docker containers | Kind Quick Start |
| Knative | Kubernetes-based platform to deploy and manage serverless workloads | Knative Install |
| Auth0 | Authentication and authorization as a service (with GitHub connection) | Auth0 Quickstart |
To enable authentication, you need to set up an Auth0 application with a GitHub connection:
- Go to Auth0 Dashboard.
- Create a new Application (Regular Web Application).
- In the application settings, set the callback URLs and allowed logout URLs as needed for your environment.
- Go to Authentication > Social and enable the GitHub connection. Follow the prompts to configure your GitHub OAuth app if you haven't already.
- In your Auth0 application, enable the GitHub connection under the Connections tab.
- Copy the following values from your Auth0 dashboard:
- AUTH0_CLIENT_ID
- AUTH0_DOMAIN
- AUTH0_CLIENT_SECRET
- AUTH0_CALLBACK_URL
- Base64 encode each value and use them as described in the Patch Auth0 secrets section below.
kn quickstart kind --name faaskubectl apply -f kservice.yml
kubectl get ksvchelm repo add kubernetes-dashboard https://kubernetes.github.io/dashboard/
helm repo update
helm install kubernetes-dashboard kubernetes-dashboard/kubernetes-dashboard --create-namespace -n kubernetes-dashboardkubectl port-forward svc/kubernetes-dashboard-kong-proxy 8443:443 -n kubernetes-dashboardThese include the service account, role and role binding for the dashboard
kubectl apply -f infra.ymlkubectl create token -n kubernetes-dashboard kubernetes-dashboardhelm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
helm install nginx-ingress ingress-nginx/ingress-nginxPort forward the ingress controller to access the services
kubectl port-forward svc/nginx-ingress-ingress-nginx-controller 8888:80you will have to set the port in your requests during testing
Replace base64== with the base64 encoded username and password for Docker Hub.
kubectl patch secret faas-api-secret -p '{"data":{"DOCKER_USERNAME":"base64==","DOCKER_PASSWORD":"base64="}}'Replace base64== with the base64 encoded values for each Auth0 variable from your .env file:
kubectl patch secret faas-api-secret -p '{"data":{"AUTH0_CLIENT_ID":"base64==","AUTH0_DOMAIN":"base64==","AUTH0_CLIENT_SECRET":"base64==","AUTH0_CALLBACK_URL":"base64=="}}'kubectl patch secret faas-api-secret -p '{"data":{"COOKIE_SECRET":"base64=="}}'kubectl rollout restart deployment/faas-apiFor now as a placeholder there is a middleware function that checks the headers.Authorization
per request for a value Bearer valid-token, this will be replaced with the actual implementation of
proper authN|Z
set <www.faas.test> in your /etc/hosts file and run the following command
curl --location 'www.faas.test:8888/api/health'curl --location 'www.faas.test:8888'