8. Local (Golang)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
fmt.Fprintf(w, "hello devfest 2020 tw")
})
port := os.Getenv("PORT")
if port == "" {
port = "8080"
log.Printf("Defaulting to port %s", port)
}
log.Printf("Listening on port %s", port)
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%s", port), nil))
}
9. Local (Python)
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return 'hello devfest 2020 tw'
if __name__ == '__main__':
app.debug = True
app.run()
11. Containers allow you
to package your
application and its
dependencies together
into one succinct
manifest
What are Containers and their benefits | Google Cloud - https://cloud.google.com/containers
13. Dockerfile (Golang)
FROM golang:1.15 AS builder
WORKDIR /workspace
# Install dependencies in go.mod and go.sum
COPY go.mod go.sum ./
RUN go mod download
# Copy rest of the application source code
COPY . ./
# Compile the application to /app.
RUN go build -o /exe -v ./
FROM gcr.io/distroless/base:latest
COPY --from=builder /exe .
ENTRYPOINT ["/exe"]
14. Dockerfile (Golang debug)
FROM golang:1.15
# Download the dlv (delve) debugger for go
RUN go get -u -v github.com/go-delve/delve/cmd/dlv
WORKDIR /workspace
# Install dependencies in go.mod and go.sum
COPY go.mod go.sum ./
RUN go mod download
# Copy rest of the application source code
COPY . ./
RUN go build -o /exe -v ./
ENTRYPOINT ["dlv", "exec", "/app", "--continue", "--accept-multiclient", "--api-version=2",
"--headless", "--listen=:3000", "--log"]
15. container with known vulnerabilities
Source: The state of open source security report 2019 by snyt
44%
Google Cloud Next ’20 OnAir - https://cloud.withgoogle.com/next/sf/onair?session=SVR227#application-modernization
16. 1. CNCF sandbox projects
2. suggest builders
a. Google
b. Heroku
c. Paketo Buildpacks
Buildpacks
17. Buildpacks Go Cloud Native | Heroku - https://blog.heroku.com/buildpacks-go-cloud-native
18. 1. Open source.
2. Creates secure
container images.
3. Designed for
running on Cloud
Run, GKE, Anthos.
Buildpacks
GoogleCloudPlatform/buildpacks - https://github.com/GoogleCloudPlatform/buildpacks
19. ● Google Cloud maintains a set of open source
buildpacks for building containers to run on
GKE, Anthos, & Cloud Run
● Cloud Build native support for buildpacks
● Cloud Run direct source deployments w/
buildpacks
● Cloud Shell has pack pre-installed. App Engine
builds via buildpacks
● Cloud Functions builds via buildpacks
● Cloud Code deploy to Cloud Run with Buildpacks
● Skaffold native support for buildpacks
Buildpacks on Google Cloud
20. pack build aa --builder gcr.io/buildpacks/builder:v1
24. Microservices refers to an
architectural style for
developing applications.
Microservices allow a large
application to be decomposed
into independent constituent
parts, with each part having
its own realm of
responsibility
26. Service Language Description
frontend Go
Exposes an HTTP server to serve the website. Does
not require signup/login and generates session
IDs for all users automatically.
cartservice C#
Stores the items in the user's shopping cart in
Redis and retrieves it.
productcatalogservice Go
Provides the list of products from a JSON file and
ability to search products and get individual
products.
currencyservice Node.js
Converts one money amount to another currency.
Uses real values fetched from European Central
Bank. It's the highest QPS service.
paymentservice Node.js
Charges the given credit card info (mock) with
the given amount and returns a transaction ID.
shippingservice Go
Gives shipping cost estimates based on the
shopping cart. Ships items to the given address
(mock)
emailservice Python Sends users an order confirmation email (mock).
checkoutservice Go
Retrieves user cart, prepares order and
orchestrates the payment, shipping and the email
notification.
recommendationservice Python
Recommends other products based on what's given
in the cart.
adservice Java Provides text ads based on given context words.
loadgenerator Python/Locust
Continuously sends requests imitating realistic
user shopping flows to the frontend.
GoogleCloudPlatform/microservices-demo - https://github.com/GoogleCloudPlatform/microservices-demo
28. Kubernetes is a portable,
extensible, open-source
platform for managing
containerized workloads and
services, that facilitates
both declarative configuration
and automation. It has a
large, rapidly growing
ecosystem. Kubernetes
services, support, and tools
are widely available.