We improve your systems with passion HELM 2 Originally developed by Deis 2015 and donated to Cloud Native Computing Foundation 2018 Second generation available and third generation development is started at July 2018 Package manager for Kubernetes clusters
We improve your systems with passion What is Helm? 3 •Helm charts are build on top of Kubernetes manifests •Charts are stored in a registry called Helm Museum •It use a templating preprocessing and managed release of Kubernetes resources •Ability to consider scalability from the get-go •SRE’s and developer can search of charts and scratch it.
We improve your systems with passion 4 • Kubernetes is a container orchestrator. • It’s how to run containers at scale. • It’s a very active open-source platform with lots of contributors, start at 6. June 2014 • Originally developed by Google and donated to Cloud Native Computing Foundation
We improve your systems with passion K8s Deployment Challenge 7 Move to microservice or serverless architecture. Applications consists from multiple components each component has its own resources and can be scaled individually. It’s hard to ... ... manage, edit and update multiple K8s configurations ... deploy multiple K8s configurations as a SINGLE application ... share and reuse K8s configurations and applications ... parametrize and support multiple environments ... manage application releases: rollout, rollback, diff, history ... define deployment lifecycle (control operations to be run in different phases) ... validate release state after deployment
We improve your systems with passion What Helm can do for you? 8 •Create new charts, aka package K8s manifests, from scratch •Package charts into chart archive (tgz) file •Interact with chart repositories where charts are stored •Install and uninstall charts into an existing Kubernetes cluster •Manage the release cycle of charts that have been installed with Helm
We improve your systems with passion Chart 9 a package of Kubernetes manifests Release a chart instance is loaded into Kubernetes Repository a download area of published charts Template a Kubernetes configuration file mixed with Go/Sprig templates Concepts
We improve your systems with passion How Helm 2 works? 10 client api-service tiller service(s) https grpc brew install kubernetes-helm curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get | bash or
We improve your systems with passion Helm cli commands 12 completion Generate autocompletions script for the specified shell (bash or zsh) create create a new chart with the given name delete given a release name, delete the release from Kubernetes dependency manage a chart's dependencies fetch download a chart from a repository and (optionally) unpack it in local directory get download a named release history fetch release history home displays the location of HELM_HOME init initialize Helm on both client and server inspect inspect a chart install install a chart archive lint examines a chart for possible issues list list releases package package a chart directory into a chart archive plugin add, list, or remove Helm plugins repo add, list, remove, update, and index chart repositories reset uninstalls Tiller from a cluster rollback roll back a release to a previous revision search search for a keyword in charts serve start a local http web server status displays the status of the named release template locally render templates test test a release upgrade upgrade a release verify verify that a chart at the given path has been signed and is valid version print the client/server version information
We improve your systems with passion Flow Control 22 If/Else {{ if PIPELINE }} # Do something {{ else if OTHER PIPELINE }} # Do something else {{ else }} # Default case {{ end }} data: myvalue: "Hello World" drink: {{ .Values.favorite.drink | default "tea" | quote }} food: {{ .Values.favorite.food | upper | quote }} {{- if eq .Values.favorite.drink "lemonade" }} mug: true {{- end }} # notice the "-" in the left, if will help eliminate newline before variable
We improve your systems with passion Flow Control 23 With data: myvalue: "Hello World" {{- with .Values.favorite }} drink: {{ .drink | default "tea" | quote }} food: {{ .food | upper | quote }} {{- end }} # instead of writing ".Values.favorite.drink"
We improve your systems with passion Flow Control 24 Range # predefined variable pizzaToppings: - mushrooms - cheese - peppers - onions toppings: |- {{- range $i, $val := .Values.pizzaTopping }} - {{ . | title | quote }} # upper first character, then quote {{- end }} sizes: |- {{- range tuple "small" "medium" "large" }} - {{ . }} {{- end }} # make a quick list
We improve your systems with passion Flow Control 26 Nested Templates # _helpers.tpl {{/* Generate basic labels */}} {{- define "my_labels" }} labels: generator: helm date: {{ now | htmlDate }} version: {{ .Chart.Version }} name: {{ .Chart.Name }} {{- end }} # configmap.yaml apiVersion: v1 kind: ConfigMap metadata: name: {{ .Release.Name }}-configmap {{- template "my_labels" . }} # Notice the final dot, it will pass the global scope inside template file. Without it version & name will not be generated. {{- include "my_labels" . | indent 2 }} # similar to "template" directive, have the ability to control indentation
We improve your systems with passion Helm: Hook reference 32 pre-install: Executes after templates are rendered, but before any resources are created in Kubernetes. post-install: Executes after all resources are loaded into Kubernetes pre-delete: Executes on a deletion request before any resources are deleted from Kubernetes. post-delete: Executes on a deletion request after all of the release’s resources have been deleted. pre-upgrade: Executes on an upgrade request after templates are rendered, but before any resources are loaded into Kubernetes (e.g. before a Kubernetes apply operation). post-upgrade: Executes on an upgrade after all resources have been upgraded. pre-rollback: Executes on a rollback request after templates are rendered, but before any resources have been rolled back. post-rollback: Executes on a rollback request after all resources have been modified. crd-install: Adds CRD resources before any other checks a
We improve your systems with passion Voting app 36 Web Ingress Web Service Vote Vote Pod Vote Pod Redis Master Service Redis Pod Vote Result Pod Vote Result Pod PostgreSQL Service PostgreSQL Pod ReplicaSet Deployment ReplicaSet Deployment Web Service Vote Result Vote Worker Pod ReplicaSet Deployment ReplicaSet Deployment ReplicaSet Deployment DNS & LB /<release-name>-vote /<release-name>-result Redis Master Pod StatefulSet PersistenceVolumeClaim Redis Slave Service Volume (data)
We improve your systems with passion 39 Text http://voting-app-traefi-yujm3v.k8s.customer.bee42.cloud/dev-vote http://voting-app-traefi-yujm3v.k8s.customer.bee42.cloud/dev-result
We improve your systems with passion Kubernets stacking 40 Your multi tenant multi stage multi branches multi services SYSTEM Kubernetes Platform Application Services k8s Extensions Linux OS vm or bare metal k8s node CRI CNI CSI CLI wireguard operator controller alerts tracing RBAC Security Auth metrics dns lb/ingress ReplicaSet Deployment RBAC ServiceAccount PodSecurityPolicy NetWorkPolicy Limits Auth Pod container container Service Ingress ReplicaSet Deployment RBAC ServiceAccount PodSecurityPolicy NetWorkPolicy Limits Auth Namespace Dev Namespace PreProd Kubernets Backplane Pod container container Service Ingress logging clusterAPI Image repo Backup Vault SCM Pipelines Load Balancer / Router / DNS Artefact repo Service Backplane Extensions Volumes Network Kubernetes extensions
We improve your systems with passion PodSecurityPolicy 42 apiVersion: policy/v1beta1 kind: PodSecurityPolicy metadata: name: restricted annotations: seccomp.security.alpha.kubernetes.io/allowedProfileNames: 'docker/default' apparmor.security.beta.kubernetes.io/allowedProfileNames: 'runtime/default' seccomp.security.alpha.kubernetes.io/defaultProfileName: 'docker/default' apparmor.security.beta.kubernetes.io/defaultProfileName: 'runtime/default' spec: privileged: false # Required to prevent escalations to root. allowPrivilegeEscalation: false # This is redundant with non-root + disallow privilege escalation, # but we can provide it for defense in depth. requiredDropCapabilities: - ALL # Allow core volume types. volumes: - 'configMap' - 'emptyDir' - 'projected' - 'secret' - 'downwardAPI' # Assume that persistentVolumes set up by the cluster admin are safe to use. - 'persistentVolumeClaim' hostNetwork: false hostIPC: false hostPID: false runAsUser: # Require the container to run without root privileges. rule: 'MustRunAsNonRoot' seLinux: # This policy assumes the nodes are using AppArmor rather than SELinux. rule: 'RunAsAny' supplementalGroups: rule: 'MustRunAs' ranges: # Forbid adding the root group. - min: 1 max: 65535 fsGroup: rule: 'MustRunAs' ranges: # Forbid adding the root group. - min: 1 max: 65535 readOnlyRootFilesystem: false https://kubernetes.io/docs/concepts/policy/pod-security-policy/
We improve your systems with passion Lessons learned 43 • Use the immutable deployment pattern • Only system pods need access to the Api Server • Add PodSecurityPolicy and limits of the resource usages • Limit the network access with a NetworkPolicy • Start with a Deny All Policy • Use multiple tiller with limit RBAC roles and track your K8s cluster users • Check your container images with CVE Checkers (Clair, NeuVector, AquaSec, … ) • Add more Know How to your teams: Teach your Ops and Dev colleagues • Share your Knowledge and go to events, conferences and meetups • Think about Chaos Engineering: Replace your system components every time and do that really! • Automate all what you can and never stop this doing! • Don`t allow manuell manipulation at your K8s Cluster
We improve your systems with passion 44 Container System Blueprint: Beehive Orchestration Provisioning Security Config Metrics Alarming Logging Traceing Artefact Registry Vault Auth Source Code CI/CD Pipeline Storage Network API Gateway Routing Loadbalancer, DNS and Firewall On Premise Cloud Operating Systems Backends VM machines Databases Bare metal Container machines Container machines Data Bastion
We improve your systems with passion Kubernetes poster pre registration started https://tinyurl.com/y9js3p7w 50 delivery starts today PREVIEW PREVIEW WE
We improve your systems with passion Cloud Native System Architect & bee42 founder Peter Roßbach @PRossbach [email protected] https://bee42.com https://devops-gathering.io 51 Save the date… #DOG19 11.-13. March 2019 at Bochum
We improve your systems with passion References 52 [Sprig library](https://godoc.org/github.com/Masterminds/sprig [Deis Workflow](https://github.com/deis/workflow/tree/master/charts/workflow)) [OpenStack chart](https://github.com/sapcc/openstack-helm) [Helm.sh](https://helm.sh) [Bitnami charts](https://github.com/bitnami/charts) [kubernetes charts](https://github.com/kubernetes/charts)