All Projects → developer-guy → admission-webhook-example-with-openfaas

developer-guy / admission-webhook-example-with-openfaas

Licence: Apache-2.0 License
Use OpenFaaS functions as Kubernetes Validating Admission Webhook

Programming Languages

go
31211 projects - #10 most used programming language
shell
77523 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to admission-webhook-example-with-openfaas

Kubectl Trace
Schedule bpftrace programs on your kubernetes cluster using the kubectl
Stars: ✭ 1,194 (+4875%)
Mutual labels:  kubernetes-cluster, kubectl
pigo-openfaas-faceblur
OpenFaaS faceblur function using the Pigo face detector library. (https://github.com/esimov/pigo)
Stars: ✭ 15 (-37.5%)
Mutual labels:  openfaas, openfaas-function
Kubernetes Reflector
Custom Kubernetes controller that can be used to replicate secrets, configmaps and certificates.
Stars: ✭ 129 (+437.5%)
Mutual labels:  kubernetes-cluster, kubectl
K3sup
bootstrap Kubernetes with k3s over SSH < 1 min 🚀
Stars: ✭ 4,012 (+16616.67%)
Mutual labels:  kubernetes-cluster, openfaas
aksctl
An easy to use CLI for AKS cluster
Stars: ✭ 46 (+91.67%)
Mutual labels:  kubernetes-cluster, kubectl
Rak8s
Stand up a Raspberry Pi based Kubernetes cluster with Ansible
Stars: ✭ 354 (+1375%)
Mutual labels:  kubernetes-cluster, kubectl
K8s In 30mins
Learn how to set up the Kubernetes cluster in 30 mins and deploy the application inside the cluster.
Stars: ✭ 172 (+616.67%)
Mutual labels:  kubernetes-cluster, kubectl
Primehub
A toil-free multi-tenancy machine learning platform in your Kubernetes cluster
Stars: ✭ 160 (+566.67%)
Mutual labels:  kubernetes-cluster, kubectl
kubectl-janitor
List Kubernetes objects in a problematic state
Stars: ✭ 48 (+100%)
Mutual labels:  kubernetes-cluster, kubectl
kubeadm-vagrant
Setup Kubernetes Cluster with Kubeadm and Vagrant
Stars: ✭ 49 (+104.17%)
Mutual labels:  kubernetes-cluster, kubectl
kubectl-view-webhook
👀 ‼️ This projects aims to visualize critical parts of the admission webhook configuration resource
Stars: ✭ 96 (+300%)
Mutual labels:  kubectl, admission-webhook
GPU-Kubernetes-Guide
How to setup a production-grade Kubernetes GPU cluster on Paperspace in 10 minutes for $10
Stars: ✭ 34 (+41.67%)
Mutual labels:  kubernetes-cluster, kubectl
Arkade
Open Source Kubernetes Marketplace
Stars: ✭ 2,343 (+9662.5%)
Mutual labels:  openfaas, arkade
Geodesic
🚀 Geodesic is a DevOps Linux Distro. We use it as a cloud automation shell. It's the fastest way to get up and running with a rock solid Open Source toolchain. ★ this repo! https://slack.cloudposse.com/
Stars: ✭ 629 (+2520.83%)
Mutual labels:  kubernetes-cluster, kubectl
kubernetes-starterkit
A launchpad for developers to learn Kubernetes from scratch and deployment of microservices on a kubernetes cluster.
Stars: ✭ 39 (+62.5%)
Mutual labels:  kubernetes-cluster, kubectl
kubehelper
KubeHelper - simplifies many daily Kubernetes cluster tasks through a web interface. Search, analysis, run commands, cron jobs, reports, filters, git synchronization and many more.
Stars: ✭ 200 (+733.33%)
Mutual labels:  kubernetes-cluster, kubectl
rak8s
Stand up a Raspberry Pi based Kubernetes cluster with Ansible
Stars: ✭ 362 (+1408.33%)
Mutual labels:  kubernetes-cluster, kubectl
k8s-istio-demo
Demo showing the capabilities of Istio
Stars: ✭ 22 (-8.33%)
Mutual labels:  kubernetes-cluster
k8s-lemp
LEMP stack in a Kubernetes cluster
Stars: ✭ 74 (+208.33%)
Mutual labels:  kubernetes-cluster
command-line-cheat-sheet
📝 A place to quickly lookup commands (bash, vim, git, AWS, Docker, Terraform, Ansible, kubectl)
Stars: ✭ 30 (+25%)
Mutual labels:  kubectl

Prerequisites

  • A Kubernetes cluster (kind, minikube, etc.)
  • OpenFaaS CLI
  • Arkade
  • Kubectl
  • KinD

2. Setup Tools

  • Arkade
$ curl -sLS https://dl.get-arkade.dev | sudo sh
  • KinD
$ arkade get kind
  • Kubectl
$ arkade get kubectl
  • OpenFaaS CLI
$ arkade get faas-cli

Setup

1. Set Up a Kubernetes Cluster with Kind (Optional)

With Kind, you can run a local Kubernetes cluster using Docker containers as nodes. The steps in this section are optional. Follow them only if you don't have a running Kubernetes cluster.

Create a file named openfaas-cluster.yaml, and copy in the following spec:

kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
$ kind create cluster --config kind-specs/kind-cluster.yaml
  • Deploy OpenFaaS to a Kubernetes Cluster with:
$ arkade install openfaas
  • Verify that the deployments were created
$ kubectl get deployments -n openfaas -l "release=openfaas, app=openfaas"

3. Deploy Validating Admission Webhook

$ cd deployment
$ sh webhook-create-signed-cert.sh
$ export CA_BUNDLE=$(kubectl config view --minify --flatten -o json | jq -r '.clusters[] | select(.name == "'$(kubectl config current-context)'") | .cluster."certificate-authority-data"')
$ sed -e "s|\${CA_BUNDLE}|${CA_BUNDLE}|g" validatingwebhook.yaml | kubectl apply -f -
$ cd ..
$ DOCKER_USER=username ./build
$ cd deployment
$ kubectl apply -f rbac.yaml
$ kubectl apply -f service.yaml
$ kubectl apply -f deployment.yaml # make sure you are using same 'DOCKER_USER' in deployment.yaml. i.e: devopps
# Label the default namespace to enable the webhook
$ kubectl label namespaces default admission-webhook-example=enabled

4. Building OpenFaaS Function

$ cd functions
$ faas-cli up -f requiredlabel.yml # (build-push-deploy) make sure you are using your docker hub username. i.e: devopps
  • Verify the functions that are working in openfaas-fn namespace.

5. Testing the whole workflow

  • K8S API -> WebHook Broker w/TLS -> OpenFaaS Gateway (w/HTTP) --> OpenFaaS Function

  • The purpose of this PoC is that to validate that pods has required labels. Which means you must have that labels:

app.kubernetes.io/name: sleep
app.kubernetes.io/instance: sleep
app.kubernetes.io/version: "0.1"
app.kubernetes.io/component: dummy
app.kubernetes.io/part-of: admission-webhook-example
app.kubernetes.io/managed-by: kubernetes
  • Any Pod who have above labels is valid for us.
`./deployment/sleep.yaml` -> Incorrect, not-valid (We should deny this creation request.)
`./deployment/sleep-no-validation.yaml` -> Skip-validation (Based on `admission-webhook-example.qikqiak.com/validate: "false"` annotation, we skipped validation.)
`./deployment/sleep-with-labels.yaml` -> Correct, valid (We should accept this creation request.)

6. References

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].