What's new in "serverless" on Google Cloud Platform

What's new in "serverless" on Google Cloud Platform

Présentation donnée au DevFest du Bout du Monde, à Brest :

Des millions de personnes échangent des selfies sur Snapchat ou jouent à Super Mario Run tous les jours. Savez-vous où ces applications tournent ? C'est le vénérable Google App Engine et l'infrastructure de Google Cloud qui permettent aux développeurs de se focaliser sur leur code et de laisser le soin de scaler l'application à Google.

Que vous déployiez des applications avec App Engine, ou des fonctions avec Cloud Functions, vous ne vous souciez plus de serveurs ou de clusters à provisionner et vous payez proportionnellement à l'utilisation, sans coûts fixes.

Dans cette session, découvrons ensemble ce qu'il y a sous le capot, et surtout les nouveautés "serverless" de Google au delà d'App Engine et Cloud Functions.

137d3908243acfc30e126615d59d4e6d?s=128

Guillaume Laforge

February 22, 2019
Tweet

Transcript

  1. 5.

    @glaforge Machine Learning Cloud ML Platform Vision API Video Intelligence

    API Speech API Translate API NLP API Compute Compute Engine App Engine Kubernetes Engine Container Registry Cloud Functions Networking Cloud Virtual Network Cloud Load Balancing Cloud CDN Cloud Interconnect Cloud DNS Storage & Databases Cloud Storage Cloud Bigtable Cloud Datastore Cloud SQL Cloud Spanner Big Data BigQuery Cloud Dataflow Cloud Dataproc Cloud Dataprep Cloud Datalab Cloud Pub/Sub Genomics Management Stackdriver Overview Monitoring Logging Error Reporting Debugger Deployment Manager Developer Cloud SDK Deployment Manager Cloud Source Repositories Cloud Endpoints Cloud Tools for Android Studio Cloud Tools for IntelliJ Google Plugin for Eclipse Cloud Test Lab Cloud Container Builder Identity & Security Cloud IAM Cloud IAP Cloud KMS Cloud Resource Manager Cloud Security Scanner Cloud Platform Security Overview Panorama
  2. 7.

    @glaforge Serverless model(s) Operational model Fully managed security Pay only

    for usage No servers Event-driven Open Service-based Programming model
  3. 9.

    @glaforge Serverless operational spectrum Managed by your cloud Container orchestration

    (k8s) Not serverless for programming or ops Container focused Infra managed by you Hosted FaaS/compute Easiest dev experience Code focused Limited runtime options Managed by your team Serverless anywhere Knative / GKE serverless addon On prem or multi-cloud Code or containers Custom hardware (GPU, TPU, IoT, etc) Offline You manage infra Serverless containers Custom languages & runtimes Infra still cloud-managed
  4. 10.

    @glaforge Serverless “compute” on Cloud Platform App Engine Standard Highly

    scalable, serverless web applications. Deploy and scale Applications that react to Requests Cloud Functions Event-driven serverless compute platform. Deploy and scale Functions that react to Events
  5. 13.

    @glaforge Demo: Sharing pictures Event-driven logic Data storage User facing

    Frontend Web + API Admin app Picture files Picture metadata & most frequent tags Vision API annotations: Labels, color, filtering Via Pub/sub Compute most popular tags pic-a-daily.appspot.com
  6. 15.

    @glaforge New idiomatic App Engine runtimes ◦ Node.js 8 (10

    in beta) ◦ Python 3.7 ◦ PHP 7.2 (beta) ◦ Go 1.11 (beta) ◦ Java 8 (11 in alpha)
  7. 17.

    @glaforge ◦ General Availability with SLA ◦ Go, Node &

    Python ◦ Security & scaling controls ◦ Environment Variables Cloud Functions
  8. 19.

    @glaforge Go 1.11, vendor & module friendly package hello import

    ( "fmt" "net/http" ) func HelloWorld(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Hello, World!") } $ gcloud beta functions deploy hello --entry-point HelloWorld --runtime go111 --trigger-http
  9. 20.

    @glaforge Node 8 with async / await const PubSub =

    require('@google-cloud/pubsub'); exports.helloPubSub = async (data, context) => { let ps = new PubSub(); try { const topicName = context.resource.name; const topic = ps.topic(topicName); const data = await topic.getMetadata(); const metadata = data[0]; console.log(`Metadata: ${JSON.stringify(metadata)}`); } catch(err) { console.error(err); } };
  10. 21.

    @glaforge Environment variables $ gcloud beta functions deploy fnNAme --set-env-vars

    FOO=bar $ gcloud beta functions deploy fnNAme --env-vars-file .env.yaml --update-env-vars FOO=baz --remove-env-vars FOO --clear-env-vars
  11. 22.

    @glaforge Function scaling control Limit scaling on a per-function basis

    Prevents DoSing resources with different scalability $ gcloud functions deploy --max-instances=100
  12. 23.

    @glaforge Security controls Control access to function invocation using IAM

    • Developers • Other functions or GCP services • End-users using Google Sign-In Set IAM policies on individual functions Private by default
  13. 24.

    @glaforge Security controls $ gcloud functions add-iam-policy-binding fnOne \ --member='allUsers'

    \ --role='roles/cloudfunctions.invoker' $ gcloud functions add-iam-policy-binding fnTwo \ --member='fnOne@projectid.iam.gserviceaccount.com' \ --role='roles/cloudfunctions.invoker'
  14. 25.

    @glaforge Per function identities By default, all functions share the

    same identity Identity can be set on a per-function basis to provide least privilege access
  15. 26.

    @glaforge Per function identities $ gcloud iam service-accounts create fnOne

    $ gcloud iam service-accounts add-iam-policy-binding \ fnOne@projectid.gserviceaccount.com \ --member='serviceAccount:fnOne@projectid.gserviceaccount.com' \ --role='roles/cloudfunctions.invoker' $ gcloud functions deploy fnOne \ --service-account fnOne@projectid.gserviceaccount.com
  16. 27.

    @glaforge Per function identities $ gcloud iam service-accounts create fnTwo

    $ gcloud iam service-accounts add-iam-policy-binding \ fnTwo@projectid.gserviceaccount.com \ --member='serviceAccount:fnTwo@projectid.gserviceaccount.com' \ --role='roles/cloudsql.client' $ gcloud functions deploy fnTwo \ --service-account fnTwo@projectid.gserviceaccount.com
  17. 29.

    @glaforge Cloud Tasks • Manage distributed task queues • Decouple

    and scale microservices • Manage resource consumption • Handle releases gracefully Sign up: http://bit.ly/tasks-signup New!
  18. 30.

    @glaforge Cloud Scheduler • Enterprise grade cron job scheduler •

    Schedule batch, big data jobs, cloud infra ops... ◦ Invoke Cloud Functions over HTTPS or Pub/Sub ◦ Invoke App Engine on a relative url handler • Manage all your jobs from one place Sign up: http://bit.ly/sched-signup New!
  19. 32.

    @glaforge Everything at Google runs in containers: Gmail, Web Search,

    Maps, ... MapReduce, batch, ... GFS, Colossus, ... Even GCE itself: VMs in containers Google launches 4 billion containers per week.
  20. 33.

    @glaforge Serverless operational spectrum Managed by your cloud Container orchestration

    (k8s) Not serverless for programming or ops Container focused Infra managed by you Hosted FaaS/compute Easiest dev experience Code focused Limited runtime options Managed by your team Serverless anywhere Knative / GKE serverless addon On prem or multi-cloud Code or containers Custom hardware (GPU, TPU, IoT, etc) Offline You manage infra Serverless containers Custom languages & runtimes Infra still cloud-managed New!
  21. 34.

    @glaforge New: serverless containers on GCF (EAP) Serverless containers on

    Cloud Functions Provide arbitrary container images and run them "serverlessly" • Takes a pre-built Docker image • Use arbitrary system libraries • Use arbitrary language runtime • Same serverless execution environment ◦ Stateless, event-driven, auto-scaling ◦ No servers ◦ Pay only while code runs
  22. 35.

    @glaforge Serverless containers Fully managed BYO workloads Pay for use

    & stateless New: serverless containers on GCF (EAP) Sign up: g.co/serverlesscontainers
  23. 38.

    @glaforge Serverless operational spectrum Managed by your cloud Container orchestration

    (k8s) Not serverless for programming or ops Container focused Infra managed by you Hosted FaaS/compute Easiest dev experience Code focused Limited runtime options Managed by your team Serverless containers Custom languages & runtimes Infra still cloud-managed Serverless anywhere Knative / GKE serverless addon On prem or multi-cloud Code or containers Custom hardware (GPU, TPU, IoT, etc) Offline You manage infra New!
  24. 39.
  25. 41.

    @glaforge Knative isn't... • An open source FaaS developer-facing product

    • A product, It's primitives • The right solution for everyone ◦ The audience is more the ops building & running their own serverless platform for the developers
  26. 42.

    @glaforge GKE serverless add-on — Knative on GKE GKE serverless

    add-on Request early access today at g.co/serverlessaddon
  27. 44.

    @glaforge Q & A cloud.google.com/serverless App Engine Java 11 alpha

    goo.gl/b8N7L2 Knative github.com/knative GKE serverless add-on (sign-up) g.co/serverlessaddon Containers on Cloud Functions (sign-up) g.co/serverlesscontainers
  28. 45.

    @glaforge Thank you! cloud.google.com/serverless App Engine Java 11 alpha goo.gl/b8N7L2

    Knative github.com/knative GKE serverless add-on (sign-up) g.co/serverlessaddon Containers on Cloud Functions (sign-up) g.co/serverlesscontainers