Sharing lessons learned from IBM Garage—Cloud Native Node.js AppsSession: 4569
Carlos [email protected] Garage Solution Engineering
Contents
THINK 2020 / 4569 / April 21, 2020 / © 2020 IBM Corporation 2
The IBM Garage 03
The Container 04Base Images 05Best practices Dockerfile 06
The Service 08Kubernetes 09
The Operations 12Distributed Tracing 13Metrics 14Monitoring Dashboards 15
IBM Garage
3
Let the IBM Garage elevate the way you work.
Use the IBM Garage Method for Cloudto enable business, development, and operations to continuously design, deliver, and validate new function.
The Method combines best of class industry methods, plus our own deep experience and IBM methods, informed by thousands of client engagements.
Enterprise Design Thinking
ü Focus on user outcomesü Empower diverse teamsü Reinvent restlessly
LeanStartup
ü Test assumptionsü Define a hypothesisü Develop a Minimum Viable
Product (MVP)ü Measure successü Continuously collect
feedback
Cloud NativePractices
ü Adopt DevOpsü Develop collaborativelyü Apply Pair Programmingü Use Test Driven
Development (TDD)ü Continuously deploy code
The Container
THINK 2020 / 4569 / April 21, 2020 / © 2020 IBM Corporation 4
“Package your application in an ephemeral way, secured and light”
Base Images
THINK 2020 / 4569 / April 21, 2020 / © 2020 IBM Corporation 5
– Pick a good base image actively maintain for security vulnerabilities (i.e.. Red Hat UBI)
– Use image that do NOT run as root
– Supports latest LTS version of runtime
Images best practices
THINK 2020 / 4569 / April 21, 2020 / © 2020 IBM Corporation 6
– Do not compile or package artifacts outside Dockerfile
– Exclude with .dockerignore
– Use multi-stage builds to drastically reduce size
– Leverage build cache
– Use Labels to annotate Image
– Use environment variable to control PORT exposed
Demo Containers
THINK 2020 / 4569 / April 21, 2020 / © 2020 IBM Corporation 7
The Service
THINK 2020 / 4569 / April 21, 2020 / © 2020 IBM Corporation 8
“Provide services in flexible, scalable, and reliable way”
Kubernetes
THINK 2020 / 4569 / April 21, 2020 / © 2020 IBM Corporation 9
– Define Memory and CPU Requests and Limits – Define Ports with name– Define Probes for Liveness and Readiness
Demo Kubernetes
THINK 2020 / 4569 / April 21, 2020 / © 2020 IBM Corporation 11
The Operations
THINK 2020 / 4569 / April 21, 2020 / © 2020 IBM Corporation 12
“Find problem before they show up in production”
Metrics
THINK 2020 / 4569 / April 21, 2020 / © 2020 IBM Corporation 13
– Use Prometheus standard format for Metrics– Emit Metrics from application– Use Prometheus client node.js library– If Istio is available, then leverage metrics from
Istio instead of application
Monitoring
THINK 2020 / 4569 / April 21, 2020 / © 2020 IBM Corporation 14
– Use Grafana or Sysdig dashboards to visualize metrics
– Use Alert Manager or Sysdig to alert someone or a about a problem
– Use Graphs during performance testing to visualize across the different metrics types (network, memory, cpu, storage)
Tracing
THINK 2020 / 4569 / April 21, 2020 / © 2020 IBM Corporation 15
– Use Jaeger as the tool to collect traces– Use Jaeger client node.js library– Use traces to find latency problems across
services– Use traces within same container to find function
affecting performance – Use traces as form of distributed logging
Demo Operations
THINK 2020 / 4569 / April 21, 2020 / © 2020 IBM Corporation 16
Thank you.
THINK 2020 / 4569 / April 21, 2020 / © 2020 IBM Corporation 17
THINK 2020 / 4569 / April 21, 2020 / © 2020 IBM Corporation 18