Container Native Development Tools

A presentation at All Things Cloud Computing Bay Area in July 2019 in Santa Clara, CA, USA by Mickey Boxell

Slide 1

Slide 1

Native Container Native Development Tools Compared: Draft, Skaffold, and Tilt Mickey Boxell – Oracle Cloud cloudnative.oracle.com Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 2

Slide 2

Slide 3

Slide 3

Sponsorships available: Sponsorships available: Prospectus

Slide 4

Slide 4

Who am I? Mickey Boxell Product Manager, Cloud Advocate, etc. Oracle Cloud Native Labs Share best practices and build original solutions and content for developers with a key focus on cloud native/container native, open source, and DevOps http://cloudnative.oracle.com/ Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 5

Slide 5

Microservice Environments • Distributed • Container-based • Polyglot • Scalable • Ephemeral Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 6

Slide 6

Development Workflow • Step 1: Write code • Step 2: Build code • Step 3: Run code • Step 4: Identify issues and return to Step 1 Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 7

Slide 7

Container Native Development Workflow • Step 1: Write code • Step 2: Build code Step 2.1: Build a container image Step 2.2: Push the image to a registry • Step 3: Run code Deploy to Kubernetes cluster • Step 4: Identify issues and return to Step 1 Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 8

Slide 8

Traditional Deployment: Helidon/Java $ mvn archetype:generate -DinteractiveMode=false \ -DarchetypeGroupId=io.helidon.archetypes \ -DarchetypeArtifactId=helidon-quickstart-se \ -DarchetypeVersion=1.1.1 \ -DgroupId=io.helidon.examples \ -DartifactId=helidon-quickstart-se
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 9

Slide 9

Traditional Deployment: Helidon/Java $ cd helidon-quickstart-se $ mvn package $ java -jar target/helidon-quickstart-se.jar Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 10

Slide 10

Container Native Deployment: Helidon/Java $ docker build -t helidon-quickstart-se . $ docker run —rm -p 8080:8080 helidon-quickstart-se:latest Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 11

Slide 11

Local Kubernetes Cluster Deployment: Helidon/Java $ kubectl apply -f app.yaml Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 12

Slide 12

Remote Kubernetes Cluster Deployment: Helidon/Java $ docker tag \ helidon-quickstart-se:latest \ <regioncode>.ocir.io/<tenancy-name>/<repo-name>/<image-name>:<tag> $ docker push \ <region-code>.ocir.io/<tenancy-name>/<reponame>/<image-name>:<tag> $ kubectl apply -f app.yaml* * modified with a container image matching the registry Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 13

Slide 13

The Whole Flow Step 1: Write code Step 2: Build code AND build the image AND push the image to a registry $ mvn package $ docker build -t helidon-quickstart-se . $ docker tag \ helidon-quickstart-se:latest \ <region-code>.ocir.io/<tenancy-name>/<reponame>/<image-name>:<tag> $ docker push \ <region-code>.ocir.io/<tenancy-name>/<repo-name>/<image-name>:<tag> Step 3: Deploy to Kubernetes Cluster $ kubectl apply -f app.yaml Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 14

Slide 14

That seems like a lot of typing Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 15

Slide 15

Of the same set of commands Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 16

Slide 16

Over and over Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 17

Slide 17

Why Did I Care? • Simple code changes took too much time & too many keystrokes • e.g. Was my endpoint zipkin.monitoring:9411 or 10.0.32.4:9411/zipkin or something else? • Each change required me to: build code, build image, tag image, push image, apply manifest Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 18

Slide 18

Why Not Just Use CI/CD? • You need tools that operate at a high speed • You can’t take a CI/CD system that takes minutes and make it take seconds or milliseconds • Every second matters to developer productivity • This is a different problem from “how do you ship?” Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 19

Slide 19

When Does This Take Place? • The inner loop of the container native development workflow: the period of time during which you are writing code, but have not yet pushed it to a version control system • More simply: “when you’re iterating on code pre-commit” Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 20

Slide 20

“What you do a few times a day is different from what you do hundreds of times a day“ – Dan Bentley, Tilt Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 21

Slide 21

Why Deploy To A Cluster? • Run diagnostic tools – logging, tracing, etc. • Run integration and dependency tests Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 22

Slide 22

Why Deploy To A Remote Cluster? • Resource exhaustion • Match test environment to production environment • Compliance – not everyone has the option of a local cluster Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 23

Slide 23

There’s even more going on under the covers Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 24

Slide 24

Dockerfile # 1st stage, build the app

2nd stage, build the runtime image

FROM maven:3.5.4-jdk-9 as build FROM openjdk:8-jre-slimWORKDIR /helidon WORKDIR /helidon

Copy the binary built in the 1st stage

Create a first layer to cache the “Maven World” in the local

COPY —from=build /helidon/target/helidon-quickstart-se.jar ./ repository. Incremental docker builds will always resume after COPY —from=build /helidon/target/libs ./libsCMD [“java”, “-jar”, that, unless you update the pom “helidon-quickstart-se.jar”] ADD pom.xml . RUN mvn package –DskipTests # Do the Maven build! Incremental docker builds will resume here when you change sources ADD src src RUN mvn package –DskipTests RUN echo “done!” Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 25

Slide 25

So why not take a similar approach to push and deploy? Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 26

Slide 26

Build, Push, Deploy Tools Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 27

Slide 27

What Are These Tools? • Draft by Microsoft Azure • Skaffold by Google • Tilt by Windmill Engineering Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 28

Slide 28

What Do These Tools Do? • Build code • Build an image of your project • Push the image to a registry service of your choice • Deploy the image onto a Kubernetes cluster • Save you time and clicks! • And they are all open source Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 29

Slide 29

Pre-Requisites • Docker • Kubernetes cluster • Local: Docker For Desktop/Minikube/etc. • Remote: Oracle Container Engine for Kubernetes (OKE) • Kubectl • An image registry service • Oracle Cloud Infrastructure Registry (OCIR) Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 30

Slide 30

Sample Application • Helidon Framework - Java libraries for writing microservices • Quickstart-SE sample application/archetype • And a colorful front end J Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 31

Slide 31

Draft Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 32

Slide 32

Draft • Low barrier to entry: Draft packs • draft create: boilerplate artifacts to run existing apps in K8s • Dockerfile, Helm charts Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 33

Slide 33

Using Draft Pre-Reqs: Docker, Kubectl, Helm • draft init – install packs/plugins and configure $DRAFT_HOME • draft create – create boilerplate based on application language • draft config set registry phx.ocir.io/oracle-cloudnative/draft creates .draft directory and config.toml • docker login • draft up + draft delete - make registry public or use imagepullsecrets Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 34

Slide 34

Using Draft • Port forward: draft connect • Logs: draft logs Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 35

Slide 35

Draft • Boilerplate is helpful to get started • No watch/continuous deployment feature • Helm can be overly-complicated and is the only deployment option • VS Code integration • Not actively being worked on L Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 36

Slide 36

Skaffold Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 37

Slide 37

Skaffold • Flexible • Many build options (Dockerfile locally, Dockerfile in-cluster with Kaniko, Dockerfile on the cloud, Jib Maven/Gradle locally, etc.) • Many deploy options (kubectl, Helm, Kustomize) • Many image tag policies Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 38

Slide 38

Using Skaffold Pre-Reqs: Docker, Kubectl • vi skaffold.yaml – specifies workflow steps • skaffold config set default-repo phx.ocir.io/oraclecloudnative/skaffold – creates .skaffold file • docker login • skaffold run + skaffold delete or skaffold dev - make registry public or use imagepullsecrets + change image spec in app.yaml Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 39

Slide 39

Using Skaffold • Logs: skaffold run –tail • Port-forward: automatic based on pod spec configuration or with —port-forward flag Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 40

Slide 40

Skaffold • Profiles feature • A set of settings stored in skaffold.yaml that overrides the build, test, and deploy sections of your current configuration • skaffold run -p [PROFILE] • Deploy multiple microservices at once • File sync – copy changed files to a container to avoid a full rebuild • Deploy once with skaffold run or continuously with skaffold dev Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 41

Slide 41

Tilt Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 42

Slide 42

Tilt • Heads up display and browser UI Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 43

Slide 43

Using Tilt Pre-Reqs: Docker, Kubectl • vi Tiltfile – specifies workflow steps • Set registry path in the Tiltfile or tilt_option.json • docker login • tilt up + tilt down - make registry public or use imagepullsecrets + change image spec in app.yaml Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 44

Slide 44

Using Tilt • B opens a port forward based on Tiltfile resource URL • Browser UI includes resource preview page • Logs available on the UI – X to expand logs Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 45

Slide 45

Tilt • Heads up display and browser UI • Python Skylark config file – concise and extensible • LiveUpdate: update a running container in place • Instead of building a new image and redeploying from scratch • Deploys multiple microservices - sample application “servantes” • No single deploy option • Dedicated, focused development team Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 46

Slide 46

Key Takeaways • Developer productivity - automate away countless manual steps • Client-side tools – aside from Helm/Tiller • These tools can deploy to both local and remote clusters • The registry step can be bypassed for local clusters • Useful as a step before pushing to source control and/or CI • They are meant to complement, not replace a CI/CD system Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 47

Slide 47

Differentiators • Getting started boilerplate • Flexibility • Heads up display Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 48

Slide 48

Additional Development Tools • • Visual Studio Code – Kubernetes Tools Extension: • Visually interact with your cluster, run commands • Simplify yaml creation Telepresence: • Connect a locally running service to a remote cluster • Code Server - in-cluster IDE – I don’t think this is a great idea J • Ksync – file sync between local directory and a running container Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell

Slide 49

Slide 49

Native Stay Connected Medium: https://medium.com/oracledevs Twitter: @mickeyboxell Linkedin: https://www.linkedin.com/in/mickeyboxell/ Try Oracle Cloud: https://cloud.oracle.com/tryit cloudnative.oracle.com Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | @mickeyboxell