SlideShare a Scribd company logo
1 of 80
Download to read offline
Deploying Swift

With Docker and Kubernetes
Swift Cloud Workshop 3

February 23rd, 2018
Chris Bailey

(@Chris__Bailey)
: Key Technologies
: Key Technologies
Container
: Key Technologies
Container Orchestration
: Key Technologies
Container Orchestration
Package and Deploy
: Key Technologies
Container Orchestration
MonitoringPackage and Deploy
: Key Technologies
Container Orchestration
Monitoring Fault TolerancePackage and Deploy
Building Swift
Microservices
func add(_ a: Int,
to b: Int) -> Void
{
print(a + b)
}
let a = ”5”
let b = 3
Sources/*
Sources/Application/Application.swift
Tests/*
Package.swift
README.md
.gitignore
Kitura
func add(_ a: Int,
to b: Int) -> Void
{
print(a + b)
}
let a = ”5”
let b = 3
Sources/*
Sources/Application/Application.swift
Tests/*
Package.swift
README.md
.gitignore
Kitura
import Kitura
import LoggerAPI
import CloudEnvironment
import KituraContracts
import Health
public let projectPath = ConfigurationManager.BasePath.project.path
public let health = Health()
public class App {
let router = Router()
let cloudEnv = CloudEnv()
public init() throws {
}
func postInit() throws {
initializeMetrics(app: self)
initializeHealthRoutes(app: self)
}
public func run() throws {
try postInit()
Kitura.addHTTPServer(onPort: cloudEnv.port, with: router)
Kitura.run()
}
}
func add(_ a: Int,
to b: Int) -> Void
{
print(a + b)
}
let a = ”5”
let b = 3
Sources/*
Sources/Application/Application.swift
Tests/*
Package.swift
README.md
.gitignore
Dockerfile
Dockerfile-tools
.dockerignore
func add(_ a: Int,
to b: Int) -> Void
{
print(a + b)
}
let a = ”5”
let b = 3
Sources/*
Sources/Application/Application.swift
Tests/*
Package.swift
README.md
.gitignore
Dockerfile
Dockerfile-tools
.dockerignore
FROM ibmcom/swift-ubuntu-runtime:4.0
# We can replace this port with what the user wants
EXPOSE 8080
# Install system level packages
# RUN apt-get update && apt-get dist-upgrade -y
# Add utils files
ADD https://raw.githubusercontent.com/IBM-Swift/swift-ubuntu-
docker/master/utils/run-utils.sh /swift-utils/run-utils.sh
ADD https://raw.githubusercontent.com/IBM-Swift/swift-ubuntu-
docker/master/utils/common-utils.sh /swift-utils/common-utils.sh
RUN chmod -R 555 /swift-utils
# Bundle application source & binaries
COPY . /swift-project
# Command to start Swift application
CMD [ "sh", "-c", "cd /swift-project && .build-ubuntu/release/
helium" ]
func add(_ a: Int,
to b: Int) -> Void
{
print(a + b)
}
let a = ”5”
let b = 3
Sources/*
Sources/Application/Application.swift
Tests/*
Package.swift
README.md
.gitignore
Dockerfile
Dockerfile-tools
.dockerignore
Dockerfile
Dockerfile-tools
$ docker build -t <your username>/swift-app .

$ docker build -t <your username>/swift-app .

$ docker run -p 49160:8080 -d <your username>/swift-app
$ docker build -t <your username>/swift-app .

$ docker run -p 49160:8080 -d <your username>/swift-app
$ docker build -t <your username>/swift-app .

$ docker run -p 49160:8080 -d <your username>/swift-app
func add(_ a: Int,
to b: Int) -> Void
{
print(a + b)
}
let a = ”5”
let b = 3
Sources/*
Sources/Application/Application.swift
Tests/*
Package.swift
README.md
.gitignore
Dockerfile
Dockerfile-tools
.dockerignore
chart/swift-app/Chart.yaml
chart/swift-app/templates/deployment.yaml
chart/swift-app/templates/hpa.yaml
chart/swift-app/templates/service.yaml
chart/swift-app/values.yaml
HELM CHARTS
func add(_ a: Int,
to b: Int) -> Void
{
print(a + b)
}
let a = ”5”
let b = 3
Sources/*
Sources/Application/Application.swift
Tests/*
Package.swift
README.md
.gitignore
Dockerfile
Dockerfile-tools
.dockerignore
chart/swift-app/Chart.yaml
chart/swift-app/templates/deployment.yaml
chart/swift-app/templates/hpa.yaml
chart/swift-app/templates/service.yaml
chart/swift-app/values.yaml
HELM CHARTS
apiVersion: v1
description: A Helm chart for Kubernetes
name: swift-app
version: 1.0.0
func add(_ a: Int,
to b: Int) -> Void
{
print(a + b)
}
let a = ”5”
let b = 3
Sources/*
Sources/Application/Application.swift
Tests/*
Package.swift
README.md
.gitignore
Dockerfile
Dockerfile-tools
.dockerignore
chart/swift-app/Chart.yaml
chart/swift-app/templates/deployment.yaml
chart/swift-app/templates/hpa.yaml
chart/swift-app/templates/service.yaml
chart/swift-app/values.yaml
HELM CHARTS
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: “{{ .Chart.Name }}-deployment"
labels:
chart: “{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}’
spec:
replicas: “{{ .Values.replicaCount }}”
revisionHistoryLimit: “{{ .Values.revisionHistoryLimit }}”
template:
metadata:
labels:
app: “{{ .Chart.Name }}-selector"
version: "current"
spec:
containers:
- name: “{{ .Chart.Name }}”
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: Always
livenessProbe:
httpGet:
path: /health
port: {{ .Values.service.servicePort }}
initialDelaySeconds:
{{.Values.livenessProbe.initialDelaySeconds}}
periodSeconds: {{ .Values.livenessProbe.periodSeconds}}
resources:
requests:
cpu: "{{ .Values.image.resources.requests.cpu }}"
memory: "{{ .Values.image.resources.requests.memory }}"
env:
- name: PORT
func add(_ a: Int,
to b: Int) -> Void
{
print(a + b)
}
let a = ”5”
let b = 3
Sources/*
Sources/Application/Application.swift
Tests/*
Package.swift
README.md
.gitignore
Dockerfile
Dockerfile-tools
.dockerignore
chart/swift-app/Chart.yaml
chart/swift-app/templates/deployment.yaml
chart/swift-app/templates/hpa.yaml
chart/swift-app/templates/service.yaml
chart/swift-app/values.yaml
HELM CHARTS
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: "{{ .Chart.Name }}-hpa-policy"
namespace: default
spec:
scaleTargetRef:
apiVersion: apps/v1beta1
kind: Deployment
name: "{{ .Chart.Name }}-deployment"
minReplicas: {{ .Values.hpa.minReplicas }}
maxReplicas: {{ .Values.hpa.maxReplicas }}
metrics:
- type: Resource
resource:
name: cpu
targetAverageUtilization:
{{.Values.hpa.metrics.cpu.targetAverageUtilization}}
- type: Resource
resource:
name: memory
targetAverageUtilization:
{{.Values.hpa.metrics.memory.targetAverageUtilization}}
{{ end }}
func add(_ a: Int,
to b: Int) -> Void
{
print(a + b)
}
let a = ”5”
let b = 3
Sources/*
Sources/Application/Application.swift
Tests/*
Package.swift
README.md
.gitignore
Dockerfile
Dockerfile-tools
.dockerignore
chart/swift-app/Chart.yaml
chart/swift-app/templates/deployment.yaml
chart/swift-app/templates/hpa.yaml
chart/swift-app/templates/service.yaml
chart/swift-app/values.yaml
HELM CHARTS
apiVersion: v1
kind: Service
metadata:
annotations:
prometheus.io/scrape: 'true'
name: "{{ .Chart.Name }}-service"
labels:
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+"
"_" }}"
spec:
type: {{ .Values.service.type }}
ports:
- name: http
port: {{ .Values.service.servicePort }}
selector:
app: "{{ .Chart.Name }}-selector"
func add(_ a: Int,
to b: Int) -> Void
{
print(a + b)
}
let a = ”5”
let b = 3
Sources/*
Sources/Application/Application.swift
Tests/*
Package.swift
README.md
.gitignore
Dockerfile
Dockerfile-tools
.dockerignore
chart/swift-app/Chart.yaml
chart/swift-app/templates/deployment.yaml
chart/swift-app/templates/hpa.yaml
chart/swift-app/templates/service.yaml
chart/swift-app/values.yaml
HELM CHARTS
replicaCount: 1
revisionHistoryLimit: 1
image:
repository: registry.ng.bluemix.net/replace-namespace/swift-app
tag: v1.0.0
pullPolicy: Always
resources:
requests:
cpu: 200m
memory: 300Mi
livenessProbe:
initialDelaySeconds: 3000
periodSeconds: 1000
service:
name: Node
type: NodePort
servicePort: 8080
hpa:
enabled: false
minReplicas: 1
maxReplicas: 2
metrics:
cpu:
targetAverageUtilization: 70
memory:
targetAverageUtilization: 70
services:
base:
enabled: false
replicaCount: 1
image:
tag : v0.9.9
weight: 100
prometheus:
enabled: false
$ helm package ./chart/swift-app
$ helm package ./chart/swift-app
$ helm install ./swift-app-1.0.0.tgz
$ helm package ./chart/swift-app
$ helm install ./swift-app-1.0.0.tgz
$ helm package ./chart/swift-app
$ helm install ./swift-app-1.0.0.tgz
func add(_ a: Int,
to b: Int) -> Void
{
print(a + b)
}
let a = ”5”
let b = 3
Sources/*
Sources/Application/Application.swift
Tests/*
Package.swift
README.md
.gitignore
Dockerfile
Dockerfile-tools
.dockerignore
chart/swift-app/Chart.yaml
chart/swift-app/templates/deployment.yaml
chart/swift-app/templates/hpa.yaml
chart/swift-app/templates/service.yaml
chart/swift-app/values.yaml
Jenkinsfile
func add(_ a: Int,
to b: Int) -> Void
{
print(a + b)
}
let a = ”5”
let b = 3
Sources/*
Sources/Application/Application.swift
Tests/*
Package.swift
README.md
.gitignore
Dockerfile
Dockerfile-tools
.dockerignore
chart/swift-app/Chart.yaml
chart/swift-app/templates/deployment.yaml
chart/swift-app/templates/hpa.yaml
chart/swift-app/templates/service.yaml
chart/swift-app/values.yaml
Jenkinsfile
#!groovy
@Library('MicroserviceBuilder') _
microserviceBuilderPipeline {
image = ‘swift-app’
}
Integrating with

Kubernetes
• Checks status of service
• Requires /health endpoint providing data

• Restarts service if not 200 OK
• Restarts service if no response

Microservice Health: Liveness Probes
func add(_ a: Int,
to b: Int) -> Void
{
print(a + b)
}
let a = ”5”
let b = 3
Sources/*
Sources/Application/Application.swift
Tests/*
Package.swift
README.md
.gitignore
Kitura
func add(_ a: Int,
to b: Int) -> Void
{
print(a + b)
}
let a = ”5”
let b = 3
Sources/*
Sources/Application/Application.swift
Tests/*
Package.swift
README.md
.gitignore
Kitura
import Kitura
import LoggerAPI
import CloudEnvironment
import KituraContracts
import Health
public let projectPath = ConfigurationManager.BasePath.project.path
public let health = Health()
public class App {
let router = Router()
let cloudEnv = CloudEnv()
public init() throws {
}
func postInit() throws {
initializeMetrics(app: self)
initializeHealthRoutes(app: self)
}
public func run() throws {
try postInit()
Kitura.addHTTPServer(onPort: cloudEnv.port, with: router)
Kitura.run()
}
}
func add(_ a: Int,
to b: Int) -> Void
{
print(a + b)
}
let a = ”5”
let b = 3
Sources/*
Sources/Application/Application.swift
Sources/Application/Routes/Health.swift
Tests/*
Package.swift
README.md
.gitignore
Kitura
import LoggerAPI
func initializeHealthRoutes(app: App) {
app.router.get("/health") { request, response, _ in
let result = health.status.toSimpleDictionary()
if health.status.state == .UP {
try response.send(json: result).end()
} else {
try response.status(.serviceUnavailable).send(json:
result).end()
}
}
}
• Provides “fault tolerance” to an application

• Enables handling of failed downstream services
• Prevents repeated calls to failed services
• Provides alternative fallback function

• Integrates with monitoring
Microservice Resilience: Hystrix and CircuitBreaker
• Provides “fault tolerance” to an application

• Enables handling of failed downstream services
• Prevents repeated calls to failed services
• Provides alternative fallback function

• Integrates with monitoring
Microservice Resilience: Hystrix and CircuitBreaker
func add(_ a: Int,
to b: Int) -> Void
{
print(a + b)
}
let a = ”5”
let b = 3
Sources/*
Sources/Application/Application.swift
Sources/Application/Routes/Health.swift

Tests/*
Package.swift
README.md
.gitignore
Kitura
breaker = CircuitBreaker(
name: "breaker",

timeout: 10000,
maxFailures: 3,
rollingWindow: 60000,
command: myCommand,
fallback: myFallback)
func myFallback(err: BreakerError, msg: String) {
Log.verbose("Error: (error)")
Log.verbose("Message: (msg)")
}
func myCommand(invocation: Invocation<(String), String>) {



}
breaker.run(commandArgs: , fallbackArgs:)
CircuitBreaker
func add(_ a: Int,
to b: Int) -> Void
{
print(a + b)
}
let a = ”5”
let b = 3
Sources/*
Sources/Application/Application.swift
Sources/Application/Routes/Health.swift

Tests/*
Package.swift
README.md
.gitignore
Kitura
breaker = CircuitBreaker(
name: "breaker",

timeout: 10000,
maxFailures: 3,
rollingWindow: 60000,
command: myCommand,
fallback: myFallback)
func myFallback(err: BreakerError, msg: String) {
Log.verbose("Error: (error)")
Log.verbose("Message: (msg)")
}
func myCommand(invocation: Invocation<(String), String>) {



}
breaker.run(commandArgs: , fallbackArgs:)
CircuitBreaker
func add(_ a: Int,
to b: Int) -> Void
{
print(a + b)
}
let a = ”5”
let b = 3
Sources/*
Sources/Application/Application.swift
Sources/Application/Routes/Health.swift

Tests/*
Package.swift
README.md
.gitignore
Kitura
breaker = CircuitBreaker(
name: "breaker",

timeout: 10000,
maxFailures: 3,
rollingWindow: 60000,
command: myCommand,
fallback: myFallback)
func myFallback(err: BreakerError, msg: String) {
Log.verbose("Error: (error)")
Log.verbose("Message: (msg)")
}
func myCommand(invocation: Invocation<(String), String>) {



}
breaker.run(commandArgs: , fallbackArgs:)
CircuitBreaker
func add(_ a: Int,
to b: Int) -> Void
{
print(a + b)
}
let a = ”5”
let b = 3
Sources/*
Sources/Application/Application.swift
Sources/Application/Routes/Health.swift

Tests/*
Package.swift
README.md
.gitignore
Kitura
breaker = CircuitBreaker(
name: "breaker",

timeout: 10000,
maxFailures: 3,
rollingWindow: 60000,
command: myCommand,
fallback: myFallback)
func myFallback(err: BreakerError, msg: String) {
Log.verbose("Error: (error)")
Log.verbose("Message: (msg)")
}
func myCommand(invocation: Invocation<(String), String>) {



}
breaker.run(commandArgs: , fallbackArgs:)
CircuitBreaker
func add(_ a: Int,
to b: Int) -> Void
{
print(a + b)
}
let a = ”5”
let b = 3
Sources/*
Sources/Application/Application.swift
Sources/Application/Routes/Health.swift

Tests/*
Package.swift
README.md
.gitignore
Kitura
let circuitParameters = CircuitParameters(
timeout: 2000,
maxFailures: 2,
fallback: myFallback)
let request = RestRequest(method: .get, url: "/hello")
request.circuitParameters = circuitParameters
SwiftyRequest
func add(_ a: Int,
to b: Int) -> Void
{
print(a + b)
}
let a = ”5”
let b = 3
Sources/*
Sources/Application/Application.swift
Sources/Application/Routes/Health.swift

Tests/*
Package.swift
README.md
.gitignore
Kitura
let circuitParameters = CircuitParameters(
timeout: 2000,
maxFailures: 2,
fallback: myFallback)
let request = RestRequest(method: .get, url: "/hello")
request.circuitParameters = circuitParameters
SwiftyRequest
• Collects data from each enabled service

• Requires /metrics endpoint providing data

• Provides storage and correlation capabilities
• Provide customisable dashboard

• Integrates with Graphana, Graphite, etc
Microservice Metrics: Prometheus
func add(_ a: Int,
to b: Int) -> Void
{
print(a + b)
}
let a = ”5”
let b = 3
Sources/*
Sources/Application/Application.swift
Tests/*
Package.swift
README.md
.gitignore
Kitura
func add(_ a: Int,
to b: Int) -> Void
{
print(a + b)
}
let a = ”5”
let b = 3
Sources/*
Sources/Application/Application.swift
Sources/Application/Routes/Health.swift

Tests/*
Package.swift
README.md
.gitignore
Kitura
import Kitura
import LoggerAPI
import CloudEnvironment
import KituraContracts
import Health
public let projectPath = ConfigurationManager.BasePath.project.path
public let health = Health()
public class App {
let router = Router()
let cloudEnv = CloudEnv()
public init() throws {
}
func postInit() throws {
initializeMetrics(app: self)
initializeHealthRoutes(app: self)
}
public func run() throws {
try postInit()
Kitura.addHTTPServer(onPort: cloudEnv.port, with: router)
Kitura.run()
}
}
func add(_ a: Int,
to b: Int) -> Void
{
print(a + b)
}
let a = ”5”
let b = 3
Sources/*
Sources/Application/Application.swift
Sources/Application/Routes/Health.swift
Sources/Applicaton/Metrics.swift
Tests/*
Package.swift
README.md
.gitignore
Kitura
import Kitura
import SwiftMetrics
import SwiftMetricsDash
import SwiftMetricsPrometheus
import LoggerAPI
var swiftMetrics: SwiftMetrics?
var swiftMetricsDash: SwiftMetricsDash?
var swiftMetricsPrometheus: SwiftMetricsPrometheus?
func initializeMetrics(router: Router) {
do {
let metrics = try SwiftMetrics()
let dashboard = try SwiftMetricsDash(swiftMetricsInstance:
metrics, endpoint: router)
let prometheus = try
SwiftMetricsPrometheus(swiftMetricsInstance:
metrics, endpoint: router)
swiftMetrics = metrics
swiftMetricsDash = dashboard
swiftMetricsPrometheus = prometheus
Log.info("Initialized metrics.")
} catch {
Log.warning("Failed to initialize metrics: (error)")
}
}
• ‘SwiftMetricsDash’ provides self-hosted monitoring

• Inbound and Outbound request performance
• Resource monitoring
• ++ Dispatch queue monitoring

• ++ profiling and flame graphs
Deep Analysis: ‘SwiftMetricsDash’
func add(_ a: Int,
to b: Int) -> Void
{
print(a + b)
}
let a = ”5”
let b = 3
Sources/*
Sources/Application/Application.swift
Sources/Application/Routes/Health.swift
Sources/Applicaton/Metrics.swift
Tests/*
Package.swift
README.md
.gitignore
Kitura
import Kitura
import SwiftMetrics
import SwiftMetricsDash
import SwiftMetricsPrometheus
import LoggerAPI
var swiftMetrics: SwiftMetrics?
var swiftMetricsDash: SwiftMetricsDash?
var swiftMetricsPrometheus: SwiftMetricsPrometheus?
func initializeMetrics(router: Router) {
do {
let metrics = try SwiftMetrics()
let dashboard = try SwiftMetricsDash(swiftMetricsInstance:
metrics, endpoint: router)
let prometheus = try
SwiftMetricsPrometheus(swiftMetricsInstance:
metrics, endpoint: router)
swiftMetrics = metrics
swiftMetricsDash = dashboard
swiftMetricsPrometheus = prometheus
Log.info("Initialized metrics.")
} catch {
Log.warning("Failed to initialize metrics: (error)")
}
}
func add(_ a: Int,
to b: Int) -> Void
{
print(a + b)
}
let a = ”5”
let b = 3
Sources/*
Sources/Application/Application.swift
Sources/Application/Routes/Health.swift
Sources/Applicaton/Metrics.swift
Tests/*
Package.swift
README.md
.gitignore
Kitura
import Kitura
import SwiftMetrics
import SwiftMetricsDash
import SwiftMetricsPrometheus
import LoggerAPI
var swiftMetrics: SwiftMetrics?
var swiftMetricsDash: SwiftMetricsDash?
var swiftMetricsPrometheus: SwiftMetricsPrometheus?
func initializeMetrics(router: Router) {
do {
let metrics = try SwiftMetrics()
let dashboard = try SwiftMetricsDash(swiftMetricsInstance:
metrics, endpoint: router)
let prometheus = try
SwiftMetricsPrometheus(swiftMetricsInstance:
metrics, endpoint: router)
swiftMetrics = metrics
swiftMetricsDash = dashboard
swiftMetricsPrometheus = prometheus
Log.info("Initialized metrics.")
} catch {
Log.warning("Failed to initialize metrics: (error)")
}
}
‘SwiftMetricsDash’
$ kitura init$ kitura init
DEMO
Common
Microservices Approach
Config Fault Tolerance Health Check Health Metrics JWT Propagation
externalize configuration
to improve portability
build robust behavior to
cope with unexpected
failures
common format to
determine service
availability
common REST
endpoints for monitoring
service health
interoperable
authentication and role-
based access control
Config Fault Tolerance Health Check Health Metrics JWT Propagation
externalize configuration
to improve portability
build robust behavior to
cope with unexpected
failures
common format to
determine service
availability
common REST
endpoints for monitoring
service health
interoperable
authentication and role-
based access control
CloudEnvironment CircuitBreaker Health SwiftMetricsPrometheus Swift-JWT
Config Fault Tolerance Health Check Health Metrics JWT Propagation
externalize configuration
to improve portability
build robust behavior to
cope with unexpected
failures
common format to
determine service
availability
common REST
endpoints for monitoring
service health
interoperable
authentication and role-
based access control
CloudEnvironment CircuitBreaker Health SwiftMetricsPrometheus Swift-JWT
ibm-cloud-env hystrix-js /health appmetrics-prometheus jsonwebtoken
59
IBM Foundation
Support for Runtimes
generator-nodeserver
appmetrics monitoring
generator-swiftserver
swiftmetrics monitoringjavametrics monitoring
IBM Support for Runtimes
Enterprise Support: Runtimes
60
LoopBack
IBM Foundation
Support for Runtimes
generator-nodeserver
appmetrics monitoring
generator-swiftserver
swiftmetrics monitoringjavametrics monitoring
IBM Support for Runtimes
IBM Advanced
Support for Runtime
Frameworks
Enterprise Support: Frameworks
61
LoopBack
IBM Foundation
Support for Runtimes
IBM Advanced
Support for Runtime
Frameworks
generator-nodeserver
appmetrics monitoring
generator-swiftserver
swiftmetrics monitoringjavametrics monitoring
IBM Support for Runtimes
Enterprise Support: Module Ecosystems
What’s Missing?
PUBLIC NETWORK CLOUD NETWORK
CATALOG
ORDER
INVENTORY
USER
MySQL
MongoDB
SPARK
ELASTICSEARCH
BACKEND FOR

FRONTEND
MICROSERVICES SERVICES
LOAD

BALANCER
PUBLIC NETWORK CLOUD NETWORK
CATALOG
ORDER
INVENTORY
USER
MySQL
MongoDB
SPARK
ELASTICSEARCH
BACKEND FOR

FRONTEND
MICROSERVICES SERVICES
LOAD

BALANCER
PUBLIC NETWORK CLOUD NETWORK
CATALOG
ORDER
INVENTORY
USER
MySQL
MongoDB
SPARK
ELASTICSEARCH
BACKEND FOR

FRONTEND
MICROSERVICES SERVICES
LOAD

BALANCER
PUBLIC NETWORK CLOUD NETWORK
CATALOG
ORDER
INVENTORY
USER
MySQL
MongoDB
SPARK
ELASTICSEARCH
BACKEND FOR

FRONTEND
MICROSERVICES SERVICES
LOAD

BALANCER
PUBLIC NETWORK CLOUD NETWORK
CATALOG
ORDER
INVENTORY
USER
MySQL
MongoDB
SPARK
ELASTICSEARCH
BACKEND FOR

FRONTEND
MICROSERVICES SERVICES
LOAD

BALANCER
PUBLIC NETWORK CLOUD NETWORK
CATALOG
ORDER
INVENTORY
USER
MySQL
MongoDB
SPARK
ELASTICSEARCH
BACKEND FOR

FRONTEND
MICROSERVICES SERVICES
LOAD

BALANCER
PUBLIC NETWORK CLOUD NETWORK
CATALOG
ORDER
INVENTORY
USER
MySQL
MongoDB
SPARK
ELASTICSEARCH
BACKEND FOR

FRONTEND
MICROSERVICES SERVICES
LOAD

BALANCER
BROWSER
TIME
BROWSER
LOAD BALANCER
TIME
BROWSER
LOAD BALANCER
WEB BFF
TIME
BROWSER
LOAD BALANCER
WEB BFF
ORDER SERVICE
TIME
BROWSER
LOAD BALANCER
WEB BFF
ORDER SERVICE
MongoDB
TIME
BROWSER
LOAD BALANCER
WEB BFF
ORDER SERVICE
MongoDB
INVENTORY SERVICE
TIME
MySQL
BROWSER
LOAD BALANCER
WEB BFF
ORDER SERVICE
MongoDB
INVENTORY SERVICE
TIME
MySQL
BROWSER
LOAD BALANCER
WEB BFF
ORDER SERVICE
MongoDB
INVENTORY SERVICE
MongoDB
TIME
• Collects data from each enabled service

• Propagates correlation ID using HTTP headers

• Provides sampling, tracing, and debug capabilities
• Collects microsecond timestamps

• Correlates data in Zipkin server
• Presents data in Zipkin dashboard
Request Tracking: OpenTracing and Zipkin
Questions?

More Related Content

What's hot

Interactive Session on Sparkling Water
Interactive Session on Sparkling WaterInteractive Session on Sparkling Water
Interactive Session on Sparkling WaterSri Ambati
 
Functional Reactive Programming on Android
Functional Reactive Programming on AndroidFunctional Reactive Programming on Android
Functional Reactive Programming on AndroidSam Lee
 
Build microservice with gRPC in golang
Build microservice with gRPC in golangBuild microservice with gRPC in golang
Build microservice with gRPC in golangTing-Li Chou
 
Docker Voting App Orientation
Docker Voting App OrientationDocker Voting App Orientation
Docker Voting App OrientationTony Pujals
 
Job Queue in Golang
Job Queue in GolangJob Queue in Golang
Job Queue in GolangBo-Yi Wu
 
Taking Jenkins Pipeline to the Extreme
Taking Jenkins Pipeline to the ExtremeTaking Jenkins Pipeline to the Extreme
Taking Jenkins Pipeline to the Extremeyinonavraham
 
GraphQL IN Golang
GraphQL IN GolangGraphQL IN Golang
GraphQL IN GolangBo-Yi Wu
 
Transforming Infrastructure into Code - Importing existing cloud resources u...
Transforming Infrastructure into Code  - Importing existing cloud resources u...Transforming Infrastructure into Code  - Importing existing cloud resources u...
Transforming Infrastructure into Code - Importing existing cloud resources u...Shih Oon Liong
 
Terraform modules and best-practices - September 2018
Terraform modules and best-practices - September 2018Terraform modules and best-practices - September 2018
Terraform modules and best-practices - September 2018Anton Babenko
 
KubeCon EU 2016: Getting the Jobs Done With Kubernetes
KubeCon EU 2016: Getting the Jobs Done With KubernetesKubeCon EU 2016: Getting the Jobs Done With Kubernetes
KubeCon EU 2016: Getting the Jobs Done With KubernetesKubeAcademy
 
The Challenges of Container Configuration
The Challenges of Container ConfigurationThe Challenges of Container Configuration
The Challenges of Container ConfigurationGareth Rushgrove
 
PyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web ApplicationsPyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web ApplicationsGraham Dumpleton
 
Building Observable Applications w/ Node.js -- BayNode Meetup, March 2014
Building Observable Applications w/ Node.js -- BayNode Meetup, March 2014Building Observable Applications w/ Node.js -- BayNode Meetup, March 2014
Building Observable Applications w/ Node.js -- BayNode Meetup, March 2014Yunong Xiao
 
Automate Your Automation | DrupalCon Vienna
Automate Your Automation | DrupalCon ViennaAutomate Your Automation | DrupalCon Vienna
Automate Your Automation | DrupalCon ViennaPantheon
 
PyHEP 2018: Tools to bind to Python
PyHEP 2018:  Tools to bind to PythonPyHEP 2018:  Tools to bind to Python
PyHEP 2018: Tools to bind to PythonHenry Schreiner
 

What's hot (20)

Interactive Session on Sparkling Water
Interactive Session on Sparkling WaterInteractive Session on Sparkling Water
Interactive Session on Sparkling Water
 
Functional Reactive Programming on Android
Functional Reactive Programming on AndroidFunctional Reactive Programming on Android
Functional Reactive Programming on Android
 
How to Make Hand Detector on Native Activity with OpenCV
How to Make Hand Detector on Native Activity with OpenCVHow to Make Hand Detector on Native Activity with OpenCV
How to Make Hand Detector on Native Activity with OpenCV
 
Build microservice with gRPC in golang
Build microservice with gRPC in golangBuild microservice with gRPC in golang
Build microservice with gRPC in golang
 
Docker Voting App Orientation
Docker Voting App OrientationDocker Voting App Orientation
Docker Voting App Orientation
 
Job Queue in Golang
Job Queue in GolangJob Queue in Golang
Job Queue in Golang
 
Taking Jenkins Pipeline to the Extreme
Taking Jenkins Pipeline to the ExtremeTaking Jenkins Pipeline to the Extreme
Taking Jenkins Pipeline to the Extreme
 
GraphQL IN Golang
GraphQL IN GolangGraphQL IN Golang
GraphQL IN Golang
 
Transforming Infrastructure into Code - Importing existing cloud resources u...
Transforming Infrastructure into Code  - Importing existing cloud resources u...Transforming Infrastructure into Code  - Importing existing cloud resources u...
Transforming Infrastructure into Code - Importing existing cloud resources u...
 
How to Customize Android Framework&System
How to Customize Android Framework&SystemHow to Customize Android Framework&System
How to Customize Android Framework&System
 
Python to scala
Python to scalaPython to scala
Python to scala
 
Terraform modules and best-practices - September 2018
Terraform modules and best-practices - September 2018Terraform modules and best-practices - September 2018
Terraform modules and best-practices - September 2018
 
KubeCon EU 2016: Getting the Jobs Done With Kubernetes
KubeCon EU 2016: Getting the Jobs Done With KubernetesKubeCon EU 2016: Getting the Jobs Done With Kubernetes
KubeCon EU 2016: Getting the Jobs Done With Kubernetes
 
The Challenges of Container Configuration
The Challenges of Container ConfigurationThe Challenges of Container Configuration
The Challenges of Container Configuration
 
Scalding
ScaldingScalding
Scalding
 
R and C++
R and C++R and C++
R and C++
 
PyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web ApplicationsPyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web Applications
 
Building Observable Applications w/ Node.js -- BayNode Meetup, March 2014
Building Observable Applications w/ Node.js -- BayNode Meetup, March 2014Building Observable Applications w/ Node.js -- BayNode Meetup, March 2014
Building Observable Applications w/ Node.js -- BayNode Meetup, March 2014
 
Automate Your Automation | DrupalCon Vienna
Automate Your Automation | DrupalCon ViennaAutomate Your Automation | DrupalCon Vienna
Automate Your Automation | DrupalCon Vienna
 
PyHEP 2018: Tools to bind to Python
PyHEP 2018:  Tools to bind to PythonPyHEP 2018:  Tools to bind to Python
PyHEP 2018: Tools to bind to Python
 

Similar to Swift Cloud Workshop - Swift Microservices

Istio Playground
Istio PlaygroundIstio Playground
Istio PlaygroundQAware GmbH
 
GE Predix 新手入门 赵锴 物联网_IoT
GE Predix 新手入门 赵锴 物联网_IoTGE Predix 新手入门 赵锴 物联网_IoT
GE Predix 新手入门 赵锴 物联网_IoTKai Zhao
 
Docker Container As A Service - Mix-IT 2016
Docker Container As A Service - Mix-IT 2016Docker Container As A Service - Mix-IT 2016
Docker Container As A Service - Mix-IT 2016Patrick Chanezon
 
Kubernetes walkthrough
Kubernetes walkthroughKubernetes walkthrough
Kubernetes walkthroughSangwon Lee
 
Scaffolding for Serverless: lightning talk for AWS Arlington Meetup
Scaffolding for Serverless: lightning talk for AWS Arlington MeetupScaffolding for Serverless: lightning talk for AWS Arlington Meetup
Scaffolding for Serverless: lightning talk for AWS Arlington MeetupChris Shenton
 
OpenShift Meetup - Tokyo - Service Mesh and Serverless Overview
OpenShift Meetup - Tokyo - Service Mesh and Serverless OverviewOpenShift Meetup - Tokyo - Service Mesh and Serverless Overview
OpenShift Meetup - Tokyo - Service Mesh and Serverless OverviewMaría Angélica Bracho
 
Pemrograman Python untuk Pemula
Pemrograman Python untuk PemulaPemrograman Python untuk Pemula
Pemrograman Python untuk PemulaOon Arfiandwi
 
Ato2019 weave-services-istio
Ato2019 weave-services-istioAto2019 weave-services-istio
Ato2019 weave-services-istioLin Sun
 
Weave Your Microservices with Istio
Weave Your Microservices with IstioWeave Your Microservices with Istio
Weave Your Microservices with IstioAll Things Open
 
All Things Open 2019 weave-services-istio
All Things Open 2019 weave-services-istioAll Things Open 2019 weave-services-istio
All Things Open 2019 weave-services-istioLin Sun
 
Server(less) Swift at SwiftCloudWorkshop 3
Server(less) Swift at SwiftCloudWorkshop 3Server(less) Swift at SwiftCloudWorkshop 3
Server(less) Swift at SwiftCloudWorkshop 3kognate
 
Tasks: you gotta know how to run them
Tasks: you gotta know how to run themTasks: you gotta know how to run them
Tasks: you gotta know how to run themFilipe Ximenes
 
Bluemix hadoop beginners Guide part I
Bluemix hadoop beginners Guide part IBluemix hadoop beginners Guide part I
Bluemix hadoop beginners Guide part IJoseph Chang
 
MicroProfile, Docker, Kubernetes, Istio and Open Shift lab @dev nexus
MicroProfile, Docker, Kubernetes, Istio and Open Shift lab @dev nexusMicroProfile, Docker, Kubernetes, Istio and Open Shift lab @dev nexus
MicroProfile, Docker, Kubernetes, Istio and Open Shift lab @dev nexusEmily Jiang
 
InterConnect2016: WebApp Architectures with Java and Node.js
InterConnect2016: WebApp Architectures with Java and Node.jsInterConnect2016: WebApp Architectures with Java and Node.js
InterConnect2016: WebApp Architectures with Java and Node.jsChris Bailey
 
Cloud nativemicroservices jax-london2020
Cloud nativemicroservices   jax-london2020Cloud nativemicroservices   jax-london2020
Cloud nativemicroservices jax-london2020Emily Jiang
 
Cloud nativemicroservices jax-london2020
Cloud nativemicroservices   jax-london2020Cloud nativemicroservices   jax-london2020
Cloud nativemicroservices jax-london2020Emily Jiang
 
commit => #GitHub => #CircleCI => #Docker => #Kubernetes #AWS cluster
commit => #GitHub => #CircleCI => #Docker => #Kubernetes #AWS clustercommit => #GitHub => #CircleCI => #Docker => #Kubernetes #AWS cluster
commit => #GitHub => #CircleCI => #Docker => #Kubernetes #AWS clusterJakub Kulhan
 
Helm Charts Security 101
Helm Charts Security 101Helm Charts Security 101
Helm Charts Security 101Deep Datta
 
H2O 3 REST API Overview
H2O 3 REST API OverviewH2O 3 REST API Overview
H2O 3 REST API OverviewRaymond Peck
 

Similar to Swift Cloud Workshop - Swift Microservices (20)

Istio Playground
Istio PlaygroundIstio Playground
Istio Playground
 
GE Predix 新手入门 赵锴 物联网_IoT
GE Predix 新手入门 赵锴 物联网_IoTGE Predix 新手入门 赵锴 物联网_IoT
GE Predix 新手入门 赵锴 物联网_IoT
 
Docker Container As A Service - Mix-IT 2016
Docker Container As A Service - Mix-IT 2016Docker Container As A Service - Mix-IT 2016
Docker Container As A Service - Mix-IT 2016
 
Kubernetes walkthrough
Kubernetes walkthroughKubernetes walkthrough
Kubernetes walkthrough
 
Scaffolding for Serverless: lightning talk for AWS Arlington Meetup
Scaffolding for Serverless: lightning talk for AWS Arlington MeetupScaffolding for Serverless: lightning talk for AWS Arlington Meetup
Scaffolding for Serverless: lightning talk for AWS Arlington Meetup
 
OpenShift Meetup - Tokyo - Service Mesh and Serverless Overview
OpenShift Meetup - Tokyo - Service Mesh and Serverless OverviewOpenShift Meetup - Tokyo - Service Mesh and Serverless Overview
OpenShift Meetup - Tokyo - Service Mesh and Serverless Overview
 
Pemrograman Python untuk Pemula
Pemrograman Python untuk PemulaPemrograman Python untuk Pemula
Pemrograman Python untuk Pemula
 
Ato2019 weave-services-istio
Ato2019 weave-services-istioAto2019 weave-services-istio
Ato2019 weave-services-istio
 
Weave Your Microservices with Istio
Weave Your Microservices with IstioWeave Your Microservices with Istio
Weave Your Microservices with Istio
 
All Things Open 2019 weave-services-istio
All Things Open 2019 weave-services-istioAll Things Open 2019 weave-services-istio
All Things Open 2019 weave-services-istio
 
Server(less) Swift at SwiftCloudWorkshop 3
Server(less) Swift at SwiftCloudWorkshop 3Server(less) Swift at SwiftCloudWorkshop 3
Server(less) Swift at SwiftCloudWorkshop 3
 
Tasks: you gotta know how to run them
Tasks: you gotta know how to run themTasks: you gotta know how to run them
Tasks: you gotta know how to run them
 
Bluemix hadoop beginners Guide part I
Bluemix hadoop beginners Guide part IBluemix hadoop beginners Guide part I
Bluemix hadoop beginners Guide part I
 
MicroProfile, Docker, Kubernetes, Istio and Open Shift lab @dev nexus
MicroProfile, Docker, Kubernetes, Istio and Open Shift lab @dev nexusMicroProfile, Docker, Kubernetes, Istio and Open Shift lab @dev nexus
MicroProfile, Docker, Kubernetes, Istio and Open Shift lab @dev nexus
 
InterConnect2016: WebApp Architectures with Java and Node.js
InterConnect2016: WebApp Architectures with Java and Node.jsInterConnect2016: WebApp Architectures with Java and Node.js
InterConnect2016: WebApp Architectures with Java and Node.js
 
Cloud nativemicroservices jax-london2020
Cloud nativemicroservices   jax-london2020Cloud nativemicroservices   jax-london2020
Cloud nativemicroservices jax-london2020
 
Cloud nativemicroservices jax-london2020
Cloud nativemicroservices   jax-london2020Cloud nativemicroservices   jax-london2020
Cloud nativemicroservices jax-london2020
 
commit => #GitHub => #CircleCI => #Docker => #Kubernetes #AWS cluster
commit => #GitHub => #CircleCI => #Docker => #Kubernetes #AWS clustercommit => #GitHub => #CircleCI => #Docker => #Kubernetes #AWS cluster
commit => #GitHub => #CircleCI => #Docker => #Kubernetes #AWS cluster
 
Helm Charts Security 101
Helm Charts Security 101Helm Charts Security 101
Helm Charts Security 101
 
H2O 3 REST API Overview
H2O 3 REST API OverviewH2O 3 REST API Overview
H2O 3 REST API Overview
 

More from Chris Bailey

NodeJS Interactive 2019: FaaS meets Frameworks
NodeJS Interactive 2019:  FaaS meets FrameworksNodeJS Interactive 2019:  FaaS meets Frameworks
NodeJS Interactive 2019: FaaS meets FrameworksChris Bailey
 
Voxxed Micro-services: Serverless JakartaEE - JAX-RS comes to FaaS
Voxxed Micro-services: Serverless JakartaEE - JAX-RS comes to FaaSVoxxed Micro-services: Serverless JakartaEE - JAX-RS comes to FaaS
Voxxed Micro-services: Serverless JakartaEE - JAX-RS comes to FaaSChris Bailey
 
Silicon Valley Code Camp 2019 - Reaching the Cloud Native World
Silicon Valley Code Camp 2019 - Reaching the Cloud Native WorldSilicon Valley Code Camp 2019 - Reaching the Cloud Native World
Silicon Valley Code Camp 2019 - Reaching the Cloud Native WorldChris Bailey
 
FaaS Meets Java EE: Developing Cloud Native Applications at Speed
FaaS Meets Java EE: Developing Cloud Native Applications at SpeedFaaS Meets Java EE: Developing Cloud Native Applications at Speed
FaaS Meets Java EE: Developing Cloud Native Applications at SpeedChris Bailey
 
AltConf 2019: Server-Side Swift State of the Union
AltConf 2019:  Server-Side Swift State of the UnionAltConf 2019:  Server-Side Swift State of the Union
AltConf 2019: Server-Side Swift State of the UnionChris Bailey
 
Server-side Swift with Swagger
Server-side Swift with SwaggerServer-side Swift with Swagger
Server-side Swift with SwaggerChris Bailey
 
Node Summit 2018: Cloud Native Node.js
Node Summit 2018: Cloud Native Node.jsNode Summit 2018: Cloud Native Node.js
Node Summit 2018: Cloud Native Node.jsChris Bailey
 
Index - BFFs vs GraphQL
Index - BFFs vs GraphQLIndex - BFFs vs GraphQL
Index - BFFs vs GraphQLChris Bailey
 
Swift Cloud Workshop - Codable, the key to Fullstack Swift
Swift Cloud Workshop - Codable, the key to Fullstack SwiftSwift Cloud Workshop - Codable, the key to Fullstack Swift
Swift Cloud Workshop - Codable, the key to Fullstack SwiftChris Bailey
 
Try!Swift India 2017: All you need is Swift
Try!Swift India 2017: All you need is SwiftTry!Swift India 2017: All you need is Swift
Try!Swift India 2017: All you need is SwiftChris Bailey
 
Swift Summit 2017: Server Swift State of the Union
Swift Summit 2017: Server Swift State of the UnionSwift Summit 2017: Server Swift State of the Union
Swift Summit 2017: Server Swift State of the UnionChris Bailey
 
IBM Cloud University: Java, Node.js and Swift
IBM Cloud University: Java, Node.js and SwiftIBM Cloud University: Java, Node.js and Swift
IBM Cloud University: Java, Node.js and SwiftChris Bailey
 
FrenchKit 2017: Server(less) Swift
FrenchKit 2017: Server(less) SwiftFrenchKit 2017: Server(less) Swift
FrenchKit 2017: Server(less) SwiftChris Bailey
 
AltConf 2017: Full Stack Swift in 30 Minutes
AltConf 2017: Full Stack Swift in 30 MinutesAltConf 2017: Full Stack Swift in 30 Minutes
AltConf 2017: Full Stack Swift in 30 MinutesChris Bailey
 
InterConnect: Server Side Swift for Java Developers
InterConnect:  Server Side Swift for Java DevelopersInterConnect:  Server Side Swift for Java Developers
InterConnect: Server Side Swift for Java DevelopersChris Bailey
 
Playgrounds: Mobile + Swift = BFF
Playgrounds: Mobile + Swift = BFFPlaygrounds: Mobile + Swift = BFF
Playgrounds: Mobile + Swift = BFFChris Bailey
 
Swift Summit: Pushing the boundaries of Swift to the Server
Swift Summit: Pushing the boundaries of Swift to the ServerSwift Summit: Pushing the boundaries of Swift to the Server
Swift Summit: Pushing the boundaries of Swift to the ServerChris Bailey
 
O'Reilly Software Architecture Conf: Cloud Economics
O'Reilly Software Architecture Conf: Cloud EconomicsO'Reilly Software Architecture Conf: Cloud Economics
O'Reilly Software Architecture Conf: Cloud EconomicsChris Bailey
 
FrenchKit: End to End Application Development with Swift
FrenchKit: End to End Application Development with SwiftFrenchKit: End to End Application Development with Swift
FrenchKit: End to End Application Development with SwiftChris Bailey
 
Node Summit 2016: Web App Architectures
Node Summit 2016:  Web App ArchitecturesNode Summit 2016:  Web App Architectures
Node Summit 2016: Web App ArchitecturesChris Bailey
 

More from Chris Bailey (20)

NodeJS Interactive 2019: FaaS meets Frameworks
NodeJS Interactive 2019:  FaaS meets FrameworksNodeJS Interactive 2019:  FaaS meets Frameworks
NodeJS Interactive 2019: FaaS meets Frameworks
 
Voxxed Micro-services: Serverless JakartaEE - JAX-RS comes to FaaS
Voxxed Micro-services: Serverless JakartaEE - JAX-RS comes to FaaSVoxxed Micro-services: Serverless JakartaEE - JAX-RS comes to FaaS
Voxxed Micro-services: Serverless JakartaEE - JAX-RS comes to FaaS
 
Silicon Valley Code Camp 2019 - Reaching the Cloud Native World
Silicon Valley Code Camp 2019 - Reaching the Cloud Native WorldSilicon Valley Code Camp 2019 - Reaching the Cloud Native World
Silicon Valley Code Camp 2019 - Reaching the Cloud Native World
 
FaaS Meets Java EE: Developing Cloud Native Applications at Speed
FaaS Meets Java EE: Developing Cloud Native Applications at SpeedFaaS Meets Java EE: Developing Cloud Native Applications at Speed
FaaS Meets Java EE: Developing Cloud Native Applications at Speed
 
AltConf 2019: Server-Side Swift State of the Union
AltConf 2019:  Server-Side Swift State of the UnionAltConf 2019:  Server-Side Swift State of the Union
AltConf 2019: Server-Side Swift State of the Union
 
Server-side Swift with Swagger
Server-side Swift with SwaggerServer-side Swift with Swagger
Server-side Swift with Swagger
 
Node Summit 2018: Cloud Native Node.js
Node Summit 2018: Cloud Native Node.jsNode Summit 2018: Cloud Native Node.js
Node Summit 2018: Cloud Native Node.js
 
Index - BFFs vs GraphQL
Index - BFFs vs GraphQLIndex - BFFs vs GraphQL
Index - BFFs vs GraphQL
 
Swift Cloud Workshop - Codable, the key to Fullstack Swift
Swift Cloud Workshop - Codable, the key to Fullstack SwiftSwift Cloud Workshop - Codable, the key to Fullstack Swift
Swift Cloud Workshop - Codable, the key to Fullstack Swift
 
Try!Swift India 2017: All you need is Swift
Try!Swift India 2017: All you need is SwiftTry!Swift India 2017: All you need is Swift
Try!Swift India 2017: All you need is Swift
 
Swift Summit 2017: Server Swift State of the Union
Swift Summit 2017: Server Swift State of the UnionSwift Summit 2017: Server Swift State of the Union
Swift Summit 2017: Server Swift State of the Union
 
IBM Cloud University: Java, Node.js and Swift
IBM Cloud University: Java, Node.js and SwiftIBM Cloud University: Java, Node.js and Swift
IBM Cloud University: Java, Node.js and Swift
 
FrenchKit 2017: Server(less) Swift
FrenchKit 2017: Server(less) SwiftFrenchKit 2017: Server(less) Swift
FrenchKit 2017: Server(less) Swift
 
AltConf 2017: Full Stack Swift in 30 Minutes
AltConf 2017: Full Stack Swift in 30 MinutesAltConf 2017: Full Stack Swift in 30 Minutes
AltConf 2017: Full Stack Swift in 30 Minutes
 
InterConnect: Server Side Swift for Java Developers
InterConnect:  Server Side Swift for Java DevelopersInterConnect:  Server Side Swift for Java Developers
InterConnect: Server Side Swift for Java Developers
 
Playgrounds: Mobile + Swift = BFF
Playgrounds: Mobile + Swift = BFFPlaygrounds: Mobile + Swift = BFF
Playgrounds: Mobile + Swift = BFF
 
Swift Summit: Pushing the boundaries of Swift to the Server
Swift Summit: Pushing the boundaries of Swift to the ServerSwift Summit: Pushing the boundaries of Swift to the Server
Swift Summit: Pushing the boundaries of Swift to the Server
 
O'Reilly Software Architecture Conf: Cloud Economics
O'Reilly Software Architecture Conf: Cloud EconomicsO'Reilly Software Architecture Conf: Cloud Economics
O'Reilly Software Architecture Conf: Cloud Economics
 
FrenchKit: End to End Application Development with Swift
FrenchKit: End to End Application Development with SwiftFrenchKit: End to End Application Development with Swift
FrenchKit: End to End Application Development with Swift
 
Node Summit 2016: Web App Architectures
Node Summit 2016:  Web App ArchitecturesNode Summit 2016:  Web App Architectures
Node Summit 2016: Web App Architectures
 

Recently uploaded

GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jNeo4j
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...OnePlan Solutions
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?Alexandre Beguel
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorTier1 app
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecturerahul_net
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITmanoharjgpsolutions
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolsosttopstonverter
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdfAndrey Devyatkin
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...Bert Jan Schrijver
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shardsChristopher Curtin
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxRTS corp
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencessuser9e7c64
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesKrzysztofKkol1
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesVictoriaMetrics
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 

Recently uploaded (20)

GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryError
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecture
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh IT
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration tools
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conference
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 Updates
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 

Swift Cloud Workshop - Swift Microservices

  • 1. Deploying Swift
 With Docker and Kubernetes Swift Cloud Workshop 3
 February 23rd, 2018 Chris Bailey
 (@Chris__Bailey)
  • 5. : Key Technologies Container Orchestration Package and Deploy
  • 6. : Key Technologies Container Orchestration MonitoringPackage and Deploy
  • 7. : Key Technologies Container Orchestration Monitoring Fault TolerancePackage and Deploy
  • 9. func add(_ a: Int, to b: Int) -> Void { print(a + b) } let a = ”5” let b = 3 Sources/* Sources/Application/Application.swift Tests/* Package.swift README.md .gitignore Kitura
  • 10. func add(_ a: Int, to b: Int) -> Void { print(a + b) } let a = ”5” let b = 3 Sources/* Sources/Application/Application.swift Tests/* Package.swift README.md .gitignore Kitura import Kitura import LoggerAPI import CloudEnvironment import KituraContracts import Health public let projectPath = ConfigurationManager.BasePath.project.path public let health = Health() public class App { let router = Router() let cloudEnv = CloudEnv() public init() throws { } func postInit() throws { initializeMetrics(app: self) initializeHealthRoutes(app: self) } public func run() throws { try postInit() Kitura.addHTTPServer(onPort: cloudEnv.port, with: router) Kitura.run() } }
  • 11. func add(_ a: Int, to b: Int) -> Void { print(a + b) } let a = ”5” let b = 3 Sources/* Sources/Application/Application.swift Tests/* Package.swift README.md .gitignore Dockerfile Dockerfile-tools .dockerignore
  • 12. func add(_ a: Int, to b: Int) -> Void { print(a + b) } let a = ”5” let b = 3 Sources/* Sources/Application/Application.swift Tests/* Package.swift README.md .gitignore Dockerfile Dockerfile-tools .dockerignore FROM ibmcom/swift-ubuntu-runtime:4.0 # We can replace this port with what the user wants EXPOSE 8080 # Install system level packages # RUN apt-get update && apt-get dist-upgrade -y # Add utils files ADD https://raw.githubusercontent.com/IBM-Swift/swift-ubuntu- docker/master/utils/run-utils.sh /swift-utils/run-utils.sh ADD https://raw.githubusercontent.com/IBM-Swift/swift-ubuntu- docker/master/utils/common-utils.sh /swift-utils/common-utils.sh RUN chmod -R 555 /swift-utils # Bundle application source & binaries COPY . /swift-project # Command to start Swift application CMD [ "sh", "-c", "cd /swift-project && .build-ubuntu/release/ helium" ]
  • 13. func add(_ a: Int, to b: Int) -> Void { print(a + b) } let a = ”5” let b = 3 Sources/* Sources/Application/Application.swift Tests/* Package.swift README.md .gitignore Dockerfile Dockerfile-tools .dockerignore Dockerfile Dockerfile-tools
  • 14. $ docker build -t <your username>/swift-app .

  • 15. $ docker build -t <your username>/swift-app .
 $ docker run -p 49160:8080 -d <your username>/swift-app
  • 16. $ docker build -t <your username>/swift-app .
 $ docker run -p 49160:8080 -d <your username>/swift-app
  • 17. $ docker build -t <your username>/swift-app .
 $ docker run -p 49160:8080 -d <your username>/swift-app
  • 18. func add(_ a: Int, to b: Int) -> Void { print(a + b) } let a = ”5” let b = 3 Sources/* Sources/Application/Application.swift Tests/* Package.swift README.md .gitignore Dockerfile Dockerfile-tools .dockerignore chart/swift-app/Chart.yaml chart/swift-app/templates/deployment.yaml chart/swift-app/templates/hpa.yaml chart/swift-app/templates/service.yaml chart/swift-app/values.yaml HELM CHARTS
  • 19. func add(_ a: Int, to b: Int) -> Void { print(a + b) } let a = ”5” let b = 3 Sources/* Sources/Application/Application.swift Tests/* Package.swift README.md .gitignore Dockerfile Dockerfile-tools .dockerignore chart/swift-app/Chart.yaml chart/swift-app/templates/deployment.yaml chart/swift-app/templates/hpa.yaml chart/swift-app/templates/service.yaml chart/swift-app/values.yaml HELM CHARTS apiVersion: v1 description: A Helm chart for Kubernetes name: swift-app version: 1.0.0
  • 20. func add(_ a: Int, to b: Int) -> Void { print(a + b) } let a = ”5” let b = 3 Sources/* Sources/Application/Application.swift Tests/* Package.swift README.md .gitignore Dockerfile Dockerfile-tools .dockerignore chart/swift-app/Chart.yaml chart/swift-app/templates/deployment.yaml chart/swift-app/templates/hpa.yaml chart/swift-app/templates/service.yaml chart/swift-app/values.yaml HELM CHARTS apiVersion: extensions/v1beta1 kind: Deployment metadata: name: “{{ .Chart.Name }}-deployment" labels: chart: “{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}’ spec: replicas: “{{ .Values.replicaCount }}” revisionHistoryLimit: “{{ .Values.revisionHistoryLimit }}” template: metadata: labels: app: “{{ .Chart.Name }}-selector" version: "current" spec: containers: - name: “{{ .Chart.Name }}” image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" imagePullPolicy: Always livenessProbe: httpGet: path: /health port: {{ .Values.service.servicePort }} initialDelaySeconds: {{.Values.livenessProbe.initialDelaySeconds}} periodSeconds: {{ .Values.livenessProbe.periodSeconds}} resources: requests: cpu: "{{ .Values.image.resources.requests.cpu }}" memory: "{{ .Values.image.resources.requests.memory }}" env: - name: PORT
  • 21. func add(_ a: Int, to b: Int) -> Void { print(a + b) } let a = ”5” let b = 3 Sources/* Sources/Application/Application.swift Tests/* Package.swift README.md .gitignore Dockerfile Dockerfile-tools .dockerignore chart/swift-app/Chart.yaml chart/swift-app/templates/deployment.yaml chart/swift-app/templates/hpa.yaml chart/swift-app/templates/service.yaml chart/swift-app/values.yaml HELM CHARTS apiVersion: autoscaling/v2beta1 kind: HorizontalPodAutoscaler metadata: name: "{{ .Chart.Name }}-hpa-policy" namespace: default spec: scaleTargetRef: apiVersion: apps/v1beta1 kind: Deployment name: "{{ .Chart.Name }}-deployment" minReplicas: {{ .Values.hpa.minReplicas }} maxReplicas: {{ .Values.hpa.maxReplicas }} metrics: - type: Resource resource: name: cpu targetAverageUtilization: {{.Values.hpa.metrics.cpu.targetAverageUtilization}} - type: Resource resource: name: memory targetAverageUtilization: {{.Values.hpa.metrics.memory.targetAverageUtilization}} {{ end }}
  • 22. func add(_ a: Int, to b: Int) -> Void { print(a + b) } let a = ”5” let b = 3 Sources/* Sources/Application/Application.swift Tests/* Package.swift README.md .gitignore Dockerfile Dockerfile-tools .dockerignore chart/swift-app/Chart.yaml chart/swift-app/templates/deployment.yaml chart/swift-app/templates/hpa.yaml chart/swift-app/templates/service.yaml chart/swift-app/values.yaml HELM CHARTS apiVersion: v1 kind: Service metadata: annotations: prometheus.io/scrape: 'true' name: "{{ .Chart.Name }}-service" labels: chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" spec: type: {{ .Values.service.type }} ports: - name: http port: {{ .Values.service.servicePort }} selector: app: "{{ .Chart.Name }}-selector"
  • 23. func add(_ a: Int, to b: Int) -> Void { print(a + b) } let a = ”5” let b = 3 Sources/* Sources/Application/Application.swift Tests/* Package.swift README.md .gitignore Dockerfile Dockerfile-tools .dockerignore chart/swift-app/Chart.yaml chart/swift-app/templates/deployment.yaml chart/swift-app/templates/hpa.yaml chart/swift-app/templates/service.yaml chart/swift-app/values.yaml HELM CHARTS replicaCount: 1 revisionHistoryLimit: 1 image: repository: registry.ng.bluemix.net/replace-namespace/swift-app tag: v1.0.0 pullPolicy: Always resources: requests: cpu: 200m memory: 300Mi livenessProbe: initialDelaySeconds: 3000 periodSeconds: 1000 service: name: Node type: NodePort servicePort: 8080 hpa: enabled: false minReplicas: 1 maxReplicas: 2 metrics: cpu: targetAverageUtilization: 70 memory: targetAverageUtilization: 70 services: base: enabled: false replicaCount: 1 image: tag : v0.9.9 weight: 100 prometheus: enabled: false
  • 24. $ helm package ./chart/swift-app
  • 25. $ helm package ./chart/swift-app $ helm install ./swift-app-1.0.0.tgz
  • 26. $ helm package ./chart/swift-app $ helm install ./swift-app-1.0.0.tgz
  • 27. $ helm package ./chart/swift-app $ helm install ./swift-app-1.0.0.tgz
  • 28. func add(_ a: Int, to b: Int) -> Void { print(a + b) } let a = ”5” let b = 3 Sources/* Sources/Application/Application.swift Tests/* Package.swift README.md .gitignore Dockerfile Dockerfile-tools .dockerignore chart/swift-app/Chart.yaml chart/swift-app/templates/deployment.yaml chart/swift-app/templates/hpa.yaml chart/swift-app/templates/service.yaml chart/swift-app/values.yaml Jenkinsfile
  • 29. func add(_ a: Int, to b: Int) -> Void { print(a + b) } let a = ”5” let b = 3 Sources/* Sources/Application/Application.swift Tests/* Package.swift README.md .gitignore Dockerfile Dockerfile-tools .dockerignore chart/swift-app/Chart.yaml chart/swift-app/templates/deployment.yaml chart/swift-app/templates/hpa.yaml chart/swift-app/templates/service.yaml chart/swift-app/values.yaml Jenkinsfile #!groovy @Library('MicroserviceBuilder') _ microserviceBuilderPipeline { image = ‘swift-app’ }
  • 31. • Checks status of service • Requires /health endpoint providing data
 • Restarts service if not 200 OK • Restarts service if no response
 Microservice Health: Liveness Probes
  • 32. func add(_ a: Int, to b: Int) -> Void { print(a + b) } let a = ”5” let b = 3 Sources/* Sources/Application/Application.swift Tests/* Package.swift README.md .gitignore Kitura
  • 33. func add(_ a: Int, to b: Int) -> Void { print(a + b) } let a = ”5” let b = 3 Sources/* Sources/Application/Application.swift Tests/* Package.swift README.md .gitignore Kitura import Kitura import LoggerAPI import CloudEnvironment import KituraContracts import Health public let projectPath = ConfigurationManager.BasePath.project.path public let health = Health() public class App { let router = Router() let cloudEnv = CloudEnv() public init() throws { } func postInit() throws { initializeMetrics(app: self) initializeHealthRoutes(app: self) } public func run() throws { try postInit() Kitura.addHTTPServer(onPort: cloudEnv.port, with: router) Kitura.run() } }
  • 34. func add(_ a: Int, to b: Int) -> Void { print(a + b) } let a = ”5” let b = 3 Sources/* Sources/Application/Application.swift Sources/Application/Routes/Health.swift Tests/* Package.swift README.md .gitignore Kitura import LoggerAPI func initializeHealthRoutes(app: App) { app.router.get("/health") { request, response, _ in let result = health.status.toSimpleDictionary() if health.status.state == .UP { try response.send(json: result).end() } else { try response.status(.serviceUnavailable).send(json: result).end() } } }
  • 35. • Provides “fault tolerance” to an application
 • Enables handling of failed downstream services • Prevents repeated calls to failed services • Provides alternative fallback function
 • Integrates with monitoring Microservice Resilience: Hystrix and CircuitBreaker
  • 36. • Provides “fault tolerance” to an application
 • Enables handling of failed downstream services • Prevents repeated calls to failed services • Provides alternative fallback function
 • Integrates with monitoring Microservice Resilience: Hystrix and CircuitBreaker
  • 37. func add(_ a: Int, to b: Int) -> Void { print(a + b) } let a = ”5” let b = 3 Sources/* Sources/Application/Application.swift Sources/Application/Routes/Health.swift
 Tests/* Package.swift README.md .gitignore Kitura breaker = CircuitBreaker( name: "breaker",
 timeout: 10000, maxFailures: 3, rollingWindow: 60000, command: myCommand, fallback: myFallback) func myFallback(err: BreakerError, msg: String) { Log.verbose("Error: (error)") Log.verbose("Message: (msg)") } func myCommand(invocation: Invocation<(String), String>) {
 
 } breaker.run(commandArgs: , fallbackArgs:) CircuitBreaker
  • 38. func add(_ a: Int, to b: Int) -> Void { print(a + b) } let a = ”5” let b = 3 Sources/* Sources/Application/Application.swift Sources/Application/Routes/Health.swift
 Tests/* Package.swift README.md .gitignore Kitura breaker = CircuitBreaker( name: "breaker",
 timeout: 10000, maxFailures: 3, rollingWindow: 60000, command: myCommand, fallback: myFallback) func myFallback(err: BreakerError, msg: String) { Log.verbose("Error: (error)") Log.verbose("Message: (msg)") } func myCommand(invocation: Invocation<(String), String>) {
 
 } breaker.run(commandArgs: , fallbackArgs:) CircuitBreaker
  • 39. func add(_ a: Int, to b: Int) -> Void { print(a + b) } let a = ”5” let b = 3 Sources/* Sources/Application/Application.swift Sources/Application/Routes/Health.swift
 Tests/* Package.swift README.md .gitignore Kitura breaker = CircuitBreaker( name: "breaker",
 timeout: 10000, maxFailures: 3, rollingWindow: 60000, command: myCommand, fallback: myFallback) func myFallback(err: BreakerError, msg: String) { Log.verbose("Error: (error)") Log.verbose("Message: (msg)") } func myCommand(invocation: Invocation<(String), String>) {
 
 } breaker.run(commandArgs: , fallbackArgs:) CircuitBreaker
  • 40. func add(_ a: Int, to b: Int) -> Void { print(a + b) } let a = ”5” let b = 3 Sources/* Sources/Application/Application.swift Sources/Application/Routes/Health.swift
 Tests/* Package.swift README.md .gitignore Kitura breaker = CircuitBreaker( name: "breaker",
 timeout: 10000, maxFailures: 3, rollingWindow: 60000, command: myCommand, fallback: myFallback) func myFallback(err: BreakerError, msg: String) { Log.verbose("Error: (error)") Log.verbose("Message: (msg)") } func myCommand(invocation: Invocation<(String), String>) {
 
 } breaker.run(commandArgs: , fallbackArgs:) CircuitBreaker
  • 41. func add(_ a: Int, to b: Int) -> Void { print(a + b) } let a = ”5” let b = 3 Sources/* Sources/Application/Application.swift Sources/Application/Routes/Health.swift
 Tests/* Package.swift README.md .gitignore Kitura let circuitParameters = CircuitParameters( timeout: 2000, maxFailures: 2, fallback: myFallback) let request = RestRequest(method: .get, url: "/hello") request.circuitParameters = circuitParameters SwiftyRequest
  • 42. func add(_ a: Int, to b: Int) -> Void { print(a + b) } let a = ”5” let b = 3 Sources/* Sources/Application/Application.swift Sources/Application/Routes/Health.swift
 Tests/* Package.swift README.md .gitignore Kitura let circuitParameters = CircuitParameters( timeout: 2000, maxFailures: 2, fallback: myFallback) let request = RestRequest(method: .get, url: "/hello") request.circuitParameters = circuitParameters SwiftyRequest
  • 43. • Collects data from each enabled service
 • Requires /metrics endpoint providing data
 • Provides storage and correlation capabilities • Provide customisable dashboard
 • Integrates with Graphana, Graphite, etc Microservice Metrics: Prometheus
  • 44. func add(_ a: Int, to b: Int) -> Void { print(a + b) } let a = ”5” let b = 3 Sources/* Sources/Application/Application.swift Tests/* Package.swift README.md .gitignore Kitura
  • 45. func add(_ a: Int, to b: Int) -> Void { print(a + b) } let a = ”5” let b = 3 Sources/* Sources/Application/Application.swift Sources/Application/Routes/Health.swift
 Tests/* Package.swift README.md .gitignore Kitura import Kitura import LoggerAPI import CloudEnvironment import KituraContracts import Health public let projectPath = ConfigurationManager.BasePath.project.path public let health = Health() public class App { let router = Router() let cloudEnv = CloudEnv() public init() throws { } func postInit() throws { initializeMetrics(app: self) initializeHealthRoutes(app: self) } public func run() throws { try postInit() Kitura.addHTTPServer(onPort: cloudEnv.port, with: router) Kitura.run() } }
  • 46. func add(_ a: Int, to b: Int) -> Void { print(a + b) } let a = ”5” let b = 3 Sources/* Sources/Application/Application.swift Sources/Application/Routes/Health.swift Sources/Applicaton/Metrics.swift Tests/* Package.swift README.md .gitignore Kitura import Kitura import SwiftMetrics import SwiftMetricsDash import SwiftMetricsPrometheus import LoggerAPI var swiftMetrics: SwiftMetrics? var swiftMetricsDash: SwiftMetricsDash? var swiftMetricsPrometheus: SwiftMetricsPrometheus? func initializeMetrics(router: Router) { do { let metrics = try SwiftMetrics() let dashboard = try SwiftMetricsDash(swiftMetricsInstance: metrics, endpoint: router) let prometheus = try SwiftMetricsPrometheus(swiftMetricsInstance: metrics, endpoint: router) swiftMetrics = metrics swiftMetricsDash = dashboard swiftMetricsPrometheus = prometheus Log.info("Initialized metrics.") } catch { Log.warning("Failed to initialize metrics: (error)") } }
  • 47.
  • 48.
  • 49. • ‘SwiftMetricsDash’ provides self-hosted monitoring
 • Inbound and Outbound request performance • Resource monitoring • ++ Dispatch queue monitoring
 • ++ profiling and flame graphs Deep Analysis: ‘SwiftMetricsDash’
  • 50. func add(_ a: Int, to b: Int) -> Void { print(a + b) } let a = ”5” let b = 3 Sources/* Sources/Application/Application.swift Sources/Application/Routes/Health.swift Sources/Applicaton/Metrics.swift Tests/* Package.swift README.md .gitignore Kitura import Kitura import SwiftMetrics import SwiftMetricsDash import SwiftMetricsPrometheus import LoggerAPI var swiftMetrics: SwiftMetrics? var swiftMetricsDash: SwiftMetricsDash? var swiftMetricsPrometheus: SwiftMetricsPrometheus? func initializeMetrics(router: Router) { do { let metrics = try SwiftMetrics() let dashboard = try SwiftMetricsDash(swiftMetricsInstance: metrics, endpoint: router) let prometheus = try SwiftMetricsPrometheus(swiftMetricsInstance: metrics, endpoint: router) swiftMetrics = metrics swiftMetricsDash = dashboard swiftMetricsPrometheus = prometheus Log.info("Initialized metrics.") } catch { Log.warning("Failed to initialize metrics: (error)") } }
  • 51. func add(_ a: Int, to b: Int) -> Void { print(a + b) } let a = ”5” let b = 3 Sources/* Sources/Application/Application.swift Sources/Application/Routes/Health.swift Sources/Applicaton/Metrics.swift Tests/* Package.swift README.md .gitignore Kitura import Kitura import SwiftMetrics import SwiftMetricsDash import SwiftMetricsPrometheus import LoggerAPI var swiftMetrics: SwiftMetrics? var swiftMetricsDash: SwiftMetricsDash? var swiftMetricsPrometheus: SwiftMetricsPrometheus? func initializeMetrics(router: Router) { do { let metrics = try SwiftMetrics() let dashboard = try SwiftMetricsDash(swiftMetricsInstance: metrics, endpoint: router) let prometheus = try SwiftMetricsPrometheus(swiftMetricsInstance: metrics, endpoint: router) swiftMetrics = metrics swiftMetricsDash = dashboard swiftMetricsPrometheus = prometheus Log.info("Initialized metrics.") } catch { Log.warning("Failed to initialize metrics: (error)") } }
  • 53. $ kitura init$ kitura init
  • 54. DEMO
  • 56. Config Fault Tolerance Health Check Health Metrics JWT Propagation externalize configuration to improve portability build robust behavior to cope with unexpected failures common format to determine service availability common REST endpoints for monitoring service health interoperable authentication and role- based access control
  • 57. Config Fault Tolerance Health Check Health Metrics JWT Propagation externalize configuration to improve portability build robust behavior to cope with unexpected failures common format to determine service availability common REST endpoints for monitoring service health interoperable authentication and role- based access control CloudEnvironment CircuitBreaker Health SwiftMetricsPrometheus Swift-JWT
  • 58. Config Fault Tolerance Health Check Health Metrics JWT Propagation externalize configuration to improve portability build robust behavior to cope with unexpected failures common format to determine service availability common REST endpoints for monitoring service health interoperable authentication and role- based access control CloudEnvironment CircuitBreaker Health SwiftMetricsPrometheus Swift-JWT ibm-cloud-env hystrix-js /health appmetrics-prometheus jsonwebtoken
  • 59. 59 IBM Foundation Support for Runtimes generator-nodeserver appmetrics monitoring generator-swiftserver swiftmetrics monitoringjavametrics monitoring IBM Support for Runtimes Enterprise Support: Runtimes
  • 60. 60 LoopBack IBM Foundation Support for Runtimes generator-nodeserver appmetrics monitoring generator-swiftserver swiftmetrics monitoringjavametrics monitoring IBM Support for Runtimes IBM Advanced Support for Runtime Frameworks Enterprise Support: Frameworks
  • 61. 61 LoopBack IBM Foundation Support for Runtimes IBM Advanced Support for Runtime Frameworks generator-nodeserver appmetrics monitoring generator-swiftserver swiftmetrics monitoringjavametrics monitoring IBM Support for Runtimes Enterprise Support: Module Ecosystems
  • 63. PUBLIC NETWORK CLOUD NETWORK CATALOG ORDER INVENTORY USER MySQL MongoDB SPARK ELASTICSEARCH BACKEND FOR
 FRONTEND MICROSERVICES SERVICES LOAD
 BALANCER
  • 64. PUBLIC NETWORK CLOUD NETWORK CATALOG ORDER INVENTORY USER MySQL MongoDB SPARK ELASTICSEARCH BACKEND FOR
 FRONTEND MICROSERVICES SERVICES LOAD
 BALANCER
  • 65. PUBLIC NETWORK CLOUD NETWORK CATALOG ORDER INVENTORY USER MySQL MongoDB SPARK ELASTICSEARCH BACKEND FOR
 FRONTEND MICROSERVICES SERVICES LOAD
 BALANCER
  • 66. PUBLIC NETWORK CLOUD NETWORK CATALOG ORDER INVENTORY USER MySQL MongoDB SPARK ELASTICSEARCH BACKEND FOR
 FRONTEND MICROSERVICES SERVICES LOAD
 BALANCER
  • 67. PUBLIC NETWORK CLOUD NETWORK CATALOG ORDER INVENTORY USER MySQL MongoDB SPARK ELASTICSEARCH BACKEND FOR
 FRONTEND MICROSERVICES SERVICES LOAD
 BALANCER
  • 68. PUBLIC NETWORK CLOUD NETWORK CATALOG ORDER INVENTORY USER MySQL MongoDB SPARK ELASTICSEARCH BACKEND FOR
 FRONTEND MICROSERVICES SERVICES LOAD
 BALANCER
  • 69. PUBLIC NETWORK CLOUD NETWORK CATALOG ORDER INVENTORY USER MySQL MongoDB SPARK ELASTICSEARCH BACKEND FOR
 FRONTEND MICROSERVICES SERVICES LOAD
 BALANCER
  • 74. BROWSER LOAD BALANCER WEB BFF ORDER SERVICE MongoDB TIME
  • 75. BROWSER LOAD BALANCER WEB BFF ORDER SERVICE MongoDB INVENTORY SERVICE TIME
  • 76. MySQL BROWSER LOAD BALANCER WEB BFF ORDER SERVICE MongoDB INVENTORY SERVICE TIME
  • 77. MySQL BROWSER LOAD BALANCER WEB BFF ORDER SERVICE MongoDB INVENTORY SERVICE MongoDB TIME
  • 78. • Collects data from each enabled service
 • Propagates correlation ID using HTTP headers
 • Provides sampling, tracing, and debug capabilities • Collects microsecond timestamps
 • Correlates data in Zipkin server • Presents data in Zipkin dashboard Request Tracking: OpenTracing and Zipkin
  • 79.