Serverless

SERVERLESS

serverless deployment + notes for microservices/monolith apps

why?

the recent explosion in popularity of container technology (Docker in particular) and in orchestration technology (such as Kubernetes, Mesos, Consul and so on) this pattern has become much more viable to implement from a technical standpoint.

things to know

overview (FaaS) (Functions as a Service)

serverless computing == containerized computing == smaller units == faster, space saving To get started with serverless computing, you only need three ingredients:

2.1 have cluster (with options)

  1. locally (test and dev)
MBP17079:~ li_qun_tang$ helm install stable/mongodb
NAME:   sullen-mole
LAST DEPLOYED: Wed May 16 20:22:32 2018
NAMESPACE: default
STATUS: DEPLOYED

RESOURCES:
==> v1/Secret
NAME                 TYPE    DATA  AGE
sullen-mole-mongodb  Opaque  1     0s

==> v1/PersistentVolumeClaim
NAME                 STATUS  VOLUME                                    CAPACITY  ACCESS MODES  STORAGECLASS  AGE
sullen-mole-mongodb  Bound   pvc-6d259685-58fb-11e8-a566-080027cecb76  8Gi       RWO           standard      0s

==> v1/Service
NAME                 TYPE       CLUSTER-IP    EXTERNAL-IP  PORT(S)    AGE
sullen-mole-mongodb  ClusterIP  10.101.7.183  <none>       27017/TCP  0s

==> v1beta1/Deployment
NAME                 DESIRED  CURRENT  UP-TO-DATE  AVAILABLE  AGE
sullen-mole-mongodb  1        1        1           0          0s

==> v1/Pod(related)
NAME                                  READY  STATUS             RESTARTS  AGE
sullen-mole-mongodb-74f8b689f9-5k2pt  0/1    ContainerCreating  0         0s


NOTES:


** Please be patient while the chart is being deployed **

MongoDB can be accessed via port 27017 on the following DNS name from within your cluster:

    sullen-mole-mongodb.default.svc.cluster.local

To get the root password run:

    export MONGODB_ROOT_PASSWORD=$(kubectl get secret --namespace default sullen-mole-mongodb -o jsonpath="{.data.mongodb-root-password}" | base64 --decode)

To connect to your database run the following command:

    kubectl run sullen-mole-mongodb-client --rm --tty -i --image bitnami/mongodb --command -- mongo --host sullen-mole-mongodb -p $MONGODB_ROOT_PASSWORD

To connect to your database from outside the cluster execute the following commands:

    export POD_NAME=$(kubectl get pods --namespace default -l "app=mongodb" -o jsonpath="{.items[0].metadata.name}")
    kubectl port-forward --namespace default $POD_NAME 27017:27017 &
    mongo --host 127.0.0.1 -p $MONGODB_ROOT_PASSWORD
  1. on google kubernetes engine (GKE) (production)
  1. on packet cloud (production)

2.2 write code