Salut!
Aujourd’hui nous allons voir ensemble comment déployer OpenFaaS dans AKS. Avant de rentrer dans le vif du sujet, je vais commencer par vous présenter OpenFaaS.
OpenFaaS est un framework permettant de construire des fonctions serverless dans Docker et Kubernetes.
Dans cet article nous partons du principe que nous avons un cluster AKS avec Helm installé.
Si ce n’est pas le cas je vous invite à consulter les articles suivants :
Sources du déploiement OpenFaaS:
maxime@Azure:~$ git clone https://github.com/openfaas/faas-netes Cloning into 'faas-netes'... remote: Counting objects: 3216, done. remote: Total 3216 (delta 0), reused 0 (delta 0), pack-reused 3216 Receiving objects: 100% (3216/3216), 4.15 MiB | 0 bytes/s, done. Resolving deltas: 100% (1607/1607), done. Checking connectivity... done. maxime@Azure:~$ cd faas-netes
Création de deux namespaces:
maxime@Azure:~$ kubectl create ns openfaas namespace "openfaas" created maxime@Azure:~$ kubectl create ns openfaas-fn namespace "openfaas-fn" created
Déploiement d’OpenFaaS avec Helm:
maxime@Azure:~/faas-netes$ helm upgrade --install --namespace openfaas --set functionNamespace=openfaas-fn --set async=true --set rbac=false --set serviceType=LoadBalancer openfaas chart/openfaas Release "openfaas" does not exist. Installing it now. NAME: openfaas LAST DEPLOYED: Tue Feb 27 17:42:38 2018 NAMESPACE: openfaas STATUS: DEPLOYED RESOURCES: ==> v1/Service NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE alertmanager ClusterIP 10.0.190.129 <none> 9093/TCP 2s nats-external ClusterIP 10.0.151.160 <none> 4222/TCP 1s faas-netesd-external ClusterIP 10.0.129.239 <none> 8080/TCP 1s gateway-external LoadBalancer 10.0.253.8 <pending> 8080:30126/TCP 1s prometheus-external LoadBalancer 10.0.225.72 <pending> 9090:30107/TCP 1s alertmanager-external ClusterIP 10.0.159.185 <none> 9093/TCP 1s faas-netesd ClusterIP 10.0.143.224 <none> 8080/TCP 1s gateway ClusterIP 10.0.182.166 <none> 8080/TCP 1s nats ClusterIP 10.0.140.189 <none> 4222/TCP 1s prometheus ClusterIP 10.0.179.79 <none> 9090/TCP 1s ==> v1beta1/Deployment NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE alertmanager 1 1 1 0 1s faas-netesd 1 1 1 0 1s gateway 1 1 1 0 1s nats 1 1 1 0 1s prometheus 1 1 1 0 1s queue-worker 1 0 0 0 1s ==> v1/Pod(related) NAME READY STATUS RESTARTS AGE alertmanager-3921060454-2tt43 0/1 ContainerCreating 0 1s faas-netesd-3370362036-1pjlc 0/1 ContainerCreating 0 1s gateway-1758360918-2tkjj 0/1 ContainerCreating 0 1s nats-4109760169-ml6vr 0/1 ContainerCreating 0 1s prometheus-1066188602-b47s6 0/1 ContainerCreating 0 1s queue-worker-3116745235-p61kt 0/1 ContainerCreating 0 1s ==> v1/ConfigMap NAME DATA AGE prometheus-config 2 2s alertmanager-config 1 2s ==> v1/ServiceAccount NAME SECRETS AGE faas-controller 1 2s faas-controller 1 2s NOTES: To verify that openfaas has started, run: kubectl --namespace=openfaas get deployments -l "release=openfaas, app=openfaas"
maxime@Azure:~/faas-netes$ kubectl --namespace=openfaas get deployments -l "release=openfaas, app=openfaas" NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE alertmanager 1 1 1 1 1m faas-netesd 1 1 1 1 1m gateway 1 1 1 1 1m nats 1 1 1 1 1m prometheus 1 1 1 1 1m queue-worker 1 1 1 1 1m
Configuration de l’authentification à OpenFaaS:
maxime@Azure:~/faas-netes$ kubectl -n openfaas create secret generic basic-auth \ > --from-literal=user=maxime \ > --from-literal=password=openfaaspwd secret "basic-auth" created
maxime@Azure:~/faas-netes$ kubectl apply -f https://raw.githubusercontent.com/zigmax/openfaas-auth/master/openfaas-auth.yaml configmap "caddy-config" created deployment "caddy" created service "caddy-lb" created
maxime@Azure:~/faas-netes$ kubectl -n openfaas describe service caddy-lb | grep Ingress | awk '{ print $NF }' 52.179.101.109