KEMBAR78
My kubernetes toolkit | PDF
1
My Kubernetes toolkit
- Sreenivas Makam
Developing Kubernetes
applications is frustrating.
Too much
configuration.
Debugging
is a pain.
Applications
have so many
moving parts.
I spend too
much time
outside of my
code.
Helpers
Kubectx
kubens
Config Mgmt
Kustomize
Pkg Mgmt
Helm
Build
Dockerfile
Kaniko
Jib
CI/CD
Skaffold
IDE
Cloud
code for
VSCODE
My favorite tools
Kubectx and Kubens
● kubectx - Utility to manage and switch between Kubernetes contexts of different
clusters
● Easy to manage dealing with multiple Kubernetes clusters(including GCP, AWS,
Azure, Docker for desktop, minikube)
● Kubens - Utility to switch between Kubernetes namespaces smoothly
● Kubectx and kubens - combination saves a lot of time
https://github.com/ahmetb/kubectx
Kustomize Overview
Additional Features
● Apply common:
○ Labels
○ Annotations
● Add a prefix to all resource names
● Easily manage ConfigMaps and
Secrets
System for managing and
applying patches on top of
existing Kubernetes YAML
Easier to maintain than
templates
Integrated with kubectl
Overlays for Kubernetes
Manifests
Security overlay
Production Overlay
Base Manifests
2O LOC
40 LOC
500 LOC
Merge in
overrides at each
layer
Kustomize example1
apiVersion: v1
kind: Pod
metadata:
name: myapp-pod
labels:
app: myapp
spec:
containers:
- name: myapp
image: busybox
command: ['app']
apiVersion: v1
kind: Pod
metadata:
name: myapp-pod
spec:
containers:
- name: myapp
command: ['app', '--dev']
apiVersion: v1
kind: Pod
metadata:
name: myapp-pod
labels:
app: myapp
spec:
containers:
- name: myapp
image: busybox
command: ['app', '--dev']
base.yaml patch.yaml output.yaml
Skaffold build
Kustomize example2
apiVersion: apps/v1
kind: Deployment
metadata:
name: the-deployment
spec:
replicas: 1
template:
metadata:
labels:
deployment: hello
spec:
containers:
- name: the-container
image: monopole/hello:1
apiVersion: apps/v1
kind: Deployment
metadata:
name: the-deployment
spec:
replicas: 3
apiVersion: apps/v1
kind: Deployment
metadata:
name: prod-the-deployment
spec:
replicas: 3
template:
metadata:
labels:
deployment: hello
Stage: production
spec:
containers:
- name: the-container
image: monopole/hello:1
base.yaml patch.yaml output.yaml
namePrefix: prod-
bases:
- ../base-manifest
commonLabels:
stage: production
patches:
- patch.yml
kustomization.yaml
Skaffold build
Helm
● Package manager for Kubernetes applications
● Charts are easy to create, version, share, and publish
● Helm 3 removes server side component Tiller and this makes Helm very easy to
use
● Helm can also help as template manager for Kubernetes, but using templates can
get complex
helm search wordpress
helm install stable/wordpress
Jib
● Creates Container images for Java without Dockerfile
○ Don’t need to worry about Dockerfile best practises
○ Daemonless
● Available as plugins for Maven and Gradle
● Optimized for fast builds
Steps:
Apply plugin
Mvn jib:build (or) gradle jib
Skaffold
● Fast local kubernetes development
● Works with any build(Dockerfile, Jib), test and deploy tools(helm, kubectl,
kustomize)
● Backend for cloud code
● Client side lightweight tool
● Supports profiles that allows extension into different environments
Skaffold init
Skaffold run - single deploy
Skaffold dev - continuous deploy
Skaffold stages
Cloud Code
Building highly scalable applications with
Kubernetes can be hard, Google Cloud Code
extends your IDE so that you can continuously
deploy to a cluster, and edit/debug just like you
were working with local code.
Available for VS code and Intellij
Cloud Code for IDEs Features
1 32
Debugging Cluster browsingKubernetes inner
development loop
4 65
Integrations with
popular tools and
libraries
Google Cloud
Platform
integrations
Templates and
editing
The tools you need for Cloud Native development, leveraging your favorite OS,
IDE, language and cloud. Available in the Visual Studio Code Marketplace.
Support for
1 2 3 4
Getting
Started
Local
Development
Deploy to
Remote Cluster
Troubleshooting -
Debugging & logs
Cloud Code for Visual Studio Code
Demo
Voting Application
Node.js Node.js
Frontend Service
index.html
results.html
Voting Service
/get
/post
https://github.com/smakam/voting-app
Voting Application Kustomization
Base manifest
Replicas: 1
stage: staging
Staging manifest
Replicas: 2
stage: production
Prod manifest
https://github.com/smakam/voting-app

My kubernetes toolkit

  • 1.
  • 2.
    Developing Kubernetes applications isfrustrating. Too much configuration. Debugging is a pain. Applications have so many moving parts. I spend too much time outside of my code.
  • 3.
  • 4.
    Kubectx and Kubens ●kubectx - Utility to manage and switch between Kubernetes contexts of different clusters ● Easy to manage dealing with multiple Kubernetes clusters(including GCP, AWS, Azure, Docker for desktop, minikube) ● Kubens - Utility to switch between Kubernetes namespaces smoothly ● Kubectx and kubens - combination saves a lot of time https://github.com/ahmetb/kubectx
  • 5.
    Kustomize Overview Additional Features ●Apply common: ○ Labels ○ Annotations ● Add a prefix to all resource names ● Easily manage ConfigMaps and Secrets System for managing and applying patches on top of existing Kubernetes YAML Easier to maintain than templates Integrated with kubectl
  • 6.
    Overlays for Kubernetes Manifests Securityoverlay Production Overlay Base Manifests 2O LOC 40 LOC 500 LOC Merge in overrides at each layer
  • 7.
    Kustomize example1 apiVersion: v1 kind:Pod metadata: name: myapp-pod labels: app: myapp spec: containers: - name: myapp image: busybox command: ['app'] apiVersion: v1 kind: Pod metadata: name: myapp-pod spec: containers: - name: myapp command: ['app', '--dev'] apiVersion: v1 kind: Pod metadata: name: myapp-pod labels: app: myapp spec: containers: - name: myapp image: busybox command: ['app', '--dev'] base.yaml patch.yaml output.yaml Skaffold build
  • 8.
    Kustomize example2 apiVersion: apps/v1 kind:Deployment metadata: name: the-deployment spec: replicas: 1 template: metadata: labels: deployment: hello spec: containers: - name: the-container image: monopole/hello:1 apiVersion: apps/v1 kind: Deployment metadata: name: the-deployment spec: replicas: 3 apiVersion: apps/v1 kind: Deployment metadata: name: prod-the-deployment spec: replicas: 3 template: metadata: labels: deployment: hello Stage: production spec: containers: - name: the-container image: monopole/hello:1 base.yaml patch.yaml output.yaml namePrefix: prod- bases: - ../base-manifest commonLabels: stage: production patches: - patch.yml kustomization.yaml Skaffold build
  • 9.
    Helm ● Package managerfor Kubernetes applications ● Charts are easy to create, version, share, and publish ● Helm 3 removes server side component Tiller and this makes Helm very easy to use ● Helm can also help as template manager for Kubernetes, but using templates can get complex helm search wordpress helm install stable/wordpress
  • 10.
    Jib ● Creates Containerimages for Java without Dockerfile ○ Don’t need to worry about Dockerfile best practises ○ Daemonless ● Available as plugins for Maven and Gradle ● Optimized for fast builds Steps: Apply plugin Mvn jib:build (or) gradle jib
  • 11.
    Skaffold ● Fast localkubernetes development ● Works with any build(Dockerfile, Jib), test and deploy tools(helm, kubectl, kustomize) ● Backend for cloud code ● Client side lightweight tool ● Supports profiles that allows extension into different environments Skaffold init Skaffold run - single deploy Skaffold dev - continuous deploy
  • 12.
  • 13.
    Cloud Code Building highlyscalable applications with Kubernetes can be hard, Google Cloud Code extends your IDE so that you can continuously deploy to a cluster, and edit/debug just like you were working with local code. Available for VS code and Intellij
  • 14.
    Cloud Code forIDEs Features 1 32 Debugging Cluster browsingKubernetes inner development loop 4 65 Integrations with popular tools and libraries Google Cloud Platform integrations Templates and editing
  • 15.
    The tools youneed for Cloud Native development, leveraging your favorite OS, IDE, language and cloud. Available in the Visual Studio Code Marketplace. Support for 1 2 3 4 Getting Started Local Development Deploy to Remote Cluster Troubleshooting - Debugging & logs Cloud Code for Visual Studio Code
  • 16.
  • 17.
    Voting Application Node.js Node.js FrontendService index.html results.html Voting Service /get /post https://github.com/smakam/voting-app
  • 18.
    Voting Application Kustomization Basemanifest Replicas: 1 stage: staging Staging manifest Replicas: 2 stage: production Prod manifest https://github.com/smakam/voting-app