GCP - Google Cloud Computing - Cloud Run
Google Cloud Computing - Cloud Run
Overall
- serverless
- enables you to deploy stateless containers
- run container using a single command
- that listen for requests or events delivered via HTTP requests.
- builds, deploys, and manages modern stateless workloads.
- can build the applications in any language using whatever frameworks and tools
- deploy them in seconds without manage and maintain the server infrastructure.
- distracts way all the infrastructure management
- such as provisioning, configuring, managing those servers
- only focus on developing applications.
- run request or event driven stateless workloads
- without having to worry bout servers.
- automatically scales up and down from zero
- depending upon traffic almost instantaneously
- no worry about scale configuration.
- pay for only the resources used
- calculated down to the nearest 100 milliseconds.
- no pay for those over provisioned resources.
- gives the choice of running the containers
- with fully managed or in the own GKE cluster.
- deploy the stateless containers with a consistent developer experience to a fully managed environment or to the own GKE cluster.
- This common experiences enabled by Knative
- Cloud Run is built on Knative
- an open source Kubernetes based platform.
- an open API and runtime environment built on top of Kubernetes.
- Cloud Run is built on Knative
- gives the freedom to move the workloads across different environments and platforms,
- either fully managed on GCP, on GKE
- or anywhere a Knative runs.
GKE
= multipleCloudRun
Development in the cloud
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
gcloud auth list
gcloud services enable run.googleapis.com
gcloud config set compute/region europe-west1
LOCATION="europe-west1"
mkdir helloworld && cd helloworld
nano package.json
# Press CTRL+X, then Y, then Enter to save the package.json file.
# {
# "name": "helloworld",
# "description": "Simple hello world sample in Node",
# "version": "1.0.0",
# "main": "index.js",
# "scripts": {
# "start": "node index.js"
# },
# "author": "Google LLC",
# "license": "Apache-2.0",
# "dependencies": {
# "express": "^4.17.1"
# }
# }
nano index.js
# const express = require('express');
# const app = express();
# const port = process.env.PORT || 8080;
# app.get('/', (req, res) => {
# const name = process.env.NAME || 'World';
# res.send(`Hello ${name}!`);
# });
# app.listen(port, () => {
# console.log(`helloworld: listening on port ${port}`);
# });
nano Dockerfile
# Use the official lightweight Node.js 12 image.
# https://hub.docker.com/_/node
FROM node:12-slim
# Create and change to the app directory.
WORKDIR /usr/src/app
# Copy application dependency manifests to the container image.
# A wildcard is used to ensure copying both package.json AND package-lock.json (when available).
# Copying this first prevents re-running npm install on every code change.
COPY package*.json ./
# Install production dependencies.
# If you add a package-lock.json, speed your build by switching to 'npm ci'.
# RUN npm ci --only=production
RUN npm install --only=production
# Copy local code to the container image.
COPY . ./
# Run the web service on container startup.
CMD [ "npm", "start" ]
gcloud builds submit --tag gcr.io/$GOOGLE_CLOUD_PROJECT/helloworld
gcloud container images list
gcloud auth configure-docker
docker run -d -p 8080:8080 gcr.io/$GOOGLE_CLOUD_PROJECT/helloworld
# In the Cloud Shell window, click on Web preview and select Preview on port 8080.
# This should open a browser window showing the "Hello World!" message. You could also simply use curl localhost:8080.
gcloud run deploy --image gcr.io/$GOOGLE_CLOUD_PROJECT/helloworld --allow-unauthenticated --region=$LOCATION
gcloud container images delete gcr.io/$GOOGLE_CLOUD_PROJECT/helloworld
gcloud run services delete helloworld --region=europe-west1
.
This post is licensed under CC BY 4.0 by the author.
Comments powered by Disqus.