Slide 1

Slide 1 text

Concourse CI/CD Meetup Tokyo #7 2017/11/14 Kazuki Suda @superbrothers Continuous Delivery with Concourse and Kubernetes

Slide 2

Slide 2 text

Kazuki Suda / @superbrothers ▶ Software Engineer@Z Lab ▶ One of the organizers of Kubernetes Meetup Tokyo

Slide 3

Slide 3 text

Agenda 1. What is Kubernetes? 2. How to deploy your application to Kubernetes? 3. Continuous Delivery with Concourse and Kubernetes 3

Slide 4

Slide 4 text

What is Kubernetes?

Slide 5

Slide 5 text

Kubernetes ▶ Container orchestrator ▶ Configure, deploy and manage containers ▶ κυβερνήτης: Geek for “Helmsman” ▶ Manage applications, not machines 5 “Kubernetes is open source—a contrast to Borg and Omega,
 which were developed as purely Google-internal systems. “ Borg, Omega, and Kubernetes
 https://research.google.com/pubs/pub44843.html

Slide 6

Slide 6 text

Compare with other platforms 6 ▶ Infrastructure as a Service ▶ VM, Disk, Network Kubernetes ▶ Container as a Service ▶ Run and manage containers ▶ Every application Cloud Foundry ▶ Platform as a Service ▶ Deploy apps from code ▶ HTTPɺAPIɺWeb OpenStack

Slide 7

Slide 7 text

Kubernetes: Up & Running

Slide 8

Slide 8 text

How to deploy your application to Kubernetes?

Slide 9

Slide 9 text

How to deploy your application to Kubernetes? kubectl: CLI for controlling the Kubernetes cluster ▶ run: Run a particular container image on the cluster ▶ create: Create resources ▶ delete: Delete resources ▶ apply: Apply a configuration to resources ▶ get: Display one or many objects 9

Slide 10

Slide 10 text

Imperative command ▶ The simplest way to run a one-off task in a cluster # Start a replicated container of nginx $ kubectl run myapp —image=nginx:latest —replicas=5 10

Slide 11

Slide 11 text

Imperative object configuration ▶ Create, update and delete Kubernetes objects by using kubectl along with manifest files written in YAML or JSON # Create a resource by a manifest file $ kubectl create -f nginx-deployment.yaml 11

Slide 12

Slide 12 text

Declarative object configuration ▶ Use kubectl apply to create and update objects as needed # Create/Update a resource by a manifest file $ kubectl apply -f nginx-deployment.yaml 12

Slide 13

Slide 13 text

Management techniques 13 Kubernetes Object Management Management technique Operates on Recommended environment Imperative commands Live objects Development projects Imperative object configuration Individual files Production projects Declarative object configuration Directories of files Production projects

Slide 14

Slide 14 text

Continuous Delivery with Concourse and Kubernetes

Slide 15

Slide 15 text

Slide 16

Slide 16 text

Versions Providing multiple versions which corresponds to the version of kubectl. ▶ zlabjp/kubernetes-resource:1.8 ▶ zlabjp/kubernetes-resource:1.7 ▶ zlabjp/kubernetes-resource:1.6 16

Slide 17

Slide 17 text

Source configuration ▶ kubeconfig + kubeconfig: A kubeconfig file kubeconfig: | apiVersion: v1 clusters: - cluster: ... 17

Slide 18

Slide 18 text

How to create a kubeconfig file? 18 https://github.com/zlabjp/kubernetes-scripts ▶ create-kubeconfig + This script allows you to easily create a kubeconfig file to access the apiserver with the specified serviceaccount.

Slide 19

Slide 19 text

Source configuration ▶ Cluster options + server: The address and port of the API server + token: Bearer token for authentication + namespace: The namespace scope + certificate_authority: A certificate file + insecure_skip_tls_verify: If true, the API server's certificate will not be checked for validity 19

Slide 20

Slide 20 text

Behaviour ▶ check: Do nothing ▶ in: Do nothing ▶ out: Control the Kubernetes cluster + Control the Kubernetes cluster like kubectl apply, kubectl delete, kubectl label and so on. 20

Slide 21

Slide 21 text

out parameters ▶ kubectl (Requried) + Specify the operation that you want to perform on one or more resources, for example apply, delete, label. ▶ wait_until_ready (Optional) + The number of seconds that waits until all pods are ready. 0 means don't wait. Defaults to 30. 21

Slide 22

Slide 22 text

out parameters ▶ wait_until_ready_interval (Optional) + The interval (sec) on which to check whether all pods are ready. Defaults to 3. ▶ wait_until_ready_selector (Optional) + A label selector to identify a set of pods which to check whether those are ready. Defaults to every pods in the namespace. 22

Slide 23

Slide 23 text

resource_types: - name: kubernetes type: docker-image source: repository: zlabjp/kubernetes-resource tag: "1.8" resources: - name: prod type: kubernetes source: kubeconfig: ((prod-kubeconfig)) - name: repo type: git source: ... jobs: - name: prod-deploy plan: - get: repo trigger: true - put: prod params: kubectl: apply -f repo/deploy -f repo/deploy/prod wait_until_ready_selector: app=myapp

Slide 24

Slide 24 text

https://github.com/zlabjp/concourse-meetup-tokyo-7-demo

Slide 25

Slide 25 text

Please feel free to contribute! ▶ https://github.com/zlabjp/kubernetes-resource/issues 25

Slide 26

Slide 26 text

Thanks! ▶ Slide + bit.ly/concourse-and-k8s ▶ Questions? + Kazuki Suda + @superbrothers