kubernetes ci/cd with helm

22
Kubernetes CI/CD with Helm: Checking in your deployment configuration as code Adnan Abdulhussein - @prydonius Software Engineer, Bitnami

Upload: adnan-abdulhussein

Post on 19-Mar-2017

370 views

Category:

Software


8 download

TRANSCRIPT

Page 1: Kubernetes CI/CD with Helm

Kubernetes CI/CD with Helm:Checking in your deployment configuration as code

Adnan Abdulhussein - @prydoniusSoftware Engineer, Bitnami

Page 2: Kubernetes CI/CD with Helm

Agenda

Benefits of configuration/infrastructure as code

Managing Kubernetes deployments

Introduction to Helm

Demo CI/CD pipeline with Helm

Page 3: Kubernetes CI/CD with Helm

Configuration and Infrastructureas Code

Host Management CI/CD InfrastructurePackaging

Page 4: Kubernetes CI/CD with Helm

Configuration and Infrastructureas Code

Why?

Version Control

Consistent

Reproducible

Rollbacks

Auditing

Code Review

Page 5: Kubernetes CI/CD with Helm

Tools

Source Code Management CI/CD Platform Deployment Tool Orchestration

Platform

Page 6: Kubernetes CI/CD with Helm

Kubernetes Resource Definitions

MariaDB

Serviceresource

Database tier

Secretresource

Deploymentresource

Application

Serviceresource

Backend tier

Config Mapresource

Deploymentresource

Nginx

Serviceresource

Frontend tier

Deploymentresource

Page 7: Kubernetes CI/CD with Helm

Example: Kubernetes Resource

apiVersion: v1kind: Deploymentmetadata: name: my-appspec: replicas: 3 template: metadata: labels: app: my-app spec: containers: - name: my-app image: prydonius/node-todo:v1.0.0 ports: - containerPort: 8080 livenessProbe: httpGet: path: / port: 8080 initialDelaySeconds: 120 timeoutSeconds: 5

Page 8: Kubernetes CI/CD with Helm

Example: Deploying to Kubernetes

$ kubectl apply -f ./mariadb-secret.yamlsecret "mariadb" configured$ kubectl apply -f ./mariadb-deployment.yamldeployment "mariadb" configured$ kubectl apply -f ./mariadb-service.yamlservice "mariadb" configured

$ kubectl apply -f ./application-configmap.yamlconfigmap "application" configured$ kubectl apply -f ./application-deployment.yamldeployment "application" configured$ kubectl apply -f ./application-service.yamlservice "application" configured

$ kubectl apply -f ./nginx-deployment.yamldeployment "nginx" configured$ kubectl apply -f ./nginx-service.yamlservice "nginx" configured

Page 9: Kubernetes CI/CD with Helm

Managing raw manifests can be difficult

No template parameterization

No application lifecycle hooks

No history of releases

Page 10: Kubernetes CI/CD with Helm

Tool for managing resources as a single unit

Reuse resources

Logically group app resources

Manage app lifecycles

Page 11: Kubernetes CI/CD with Helm

Charts(packages)

Application definitions

Consist ofMetadata (Chart.yaml)

Kubernetes templates

Configuration file (values.yaml)

Documentation

Can depend on other charts

Page 12: Kubernetes CI/CD with Helm

Navigating a Chart

MariaDB

Serviceresource

Database tier

Secretresource

Deploymentresource

Application

Serviceresource

Backend tier

Config Mapresource

Deploymentresource

Nginx

Serviceresource

Frontend tier

DeploymentresourceDocumentation

Metadata

Config File

helm install my-app

Page 13: Kubernetes CI/CD with Helm

myapp├── Chart.yaml├── README.md├── charts│ └── mariadb-0.5.8.tgz├── templates│ ├── deployment.yaml│ └── ...└── values.yaml

Navigating a Chart

Page 14: Kubernetes CI/CD with Helm

Public charts repository

Page 15: Kubernetes CI/CD with Helm

CLI tool

Takes a local Chart path

Set parameters used in Chart templates

Release state stored in cluster

How the Helm can I setup CD?

Page 16: Kubernetes CI/CD with Helm

Generic CI/CD pipeline

Code/config change

Build

Test

Publish artifacts

Staging/QA Deployment

Production Deployment

Manual verification

Page 17: Kubernetes CI/CD with Helm

Demo: CI/CD Pipeline

Code/config change

Build

Test

Push Docker image

Staging/QA Deployment

Production Deployment

Manual verification

Page 18: Kubernetes CI/CD with Helm

Demo: Todo List App

Application Code

Dockerfile

Jenkinsfile

Helm Chart

prydonius/node-todo

Amazing Todo App

● Express.js server

● Angular frontend

● MongoDB database

Page 19: Kubernetes CI/CD with Helm

Demo

Page 20: Kubernetes CI/CD with Helm

Helm + Jenkins vs. SpinnakerHelm and Jenkins

+ config as code, single source of truth

+ multi-branch support (including pull requests)

+ rich source of plugins

+ single platform for CI and CD

Spinnaker

- more deployment strategies

- more opinionated

- standardized configurations

- deploy multiple clouds/platforms

Page 21: Kubernetes CI/CD with Helm

Helm Community

Over 100 contributors

1.5 years old

Slack channel: Kubernetes/#Helm

Public dev meetings: Thursdays @ 9:30 pacific

Weekly updates & demos at SIG-Apps meetings: Mondays @ 9am pacific

Join us!

Page 22: Kubernetes CI/CD with Helm

Thank youTime for questions and (hopefully) answers...