Giter VIP home page Giter VIP logo

skaffold-demo's Introduction

Example: µSvcs with Skaffold

In this example:

  • Deploy multiple applications with skaffold
  • In development, only rebuild and redeploy the artifacts that have changed
  • Deploy multiple applications outside the working directory

In the real world, Kubernetes deployments will consist of multiple applications that work together. In this example, we'll walk through using skaffold to develop and deploy two applications, an exposed "web" frontend which calls an unexposed "app" backend.

WARNING: If you're running this on a cloud cluster, this example will create a service and expose a webserver. It's highly suggested that you only run this example on a local, private cluster like minikube or Kubernetes in Docker for Desktop.

Running the example on minikube

From this directory, run

skaffold dev

Now, in a different terminal, hit the leeroy-web endpoint

$ curl $(minikube service leeroy-web --url)
leeroooooy app!

Now, let's change the message in leeroy-app without changing leeroy-web. Add a few exclamations points because this is exhilarating stuff.

In leeroy-app/app.go, change the message here

func handler(w http.ResponseWriter, r *http.Request) {
	fmt.Fprintf(w, "leeroooooy app!!!\n")
}

Once you see the log message

[leeroy-app-5b4dfdcbc6-6vf6r leeroy-app] 2018/03/30 06:28:47 leeroy app server ready

Your service will be ready to hit again with

$ curl $(minikube service leeroy-web --url)
leeroooooy app!!!

Configuration walkthrough

Let's walk through the first part of the skaffold.yaml

  artifacts:
  - image: leeroy-web
    context: ./leeroy-web/
  - image: leeroy-app
    context: ./leeroy-app/

We're deploying a leeroy-web image, which we build in the context of its subdirectory and a leeroy-app image built in a similar manner.

leeroy-web will listen for requests, and then make a simple HTTP call to leeroy-app using Kubernetes service discovery and return that result.

In the deploy stanza, we use the glob matching pattern to deploy all YAML and JSON files in the respective Kubernetes manifest directories.

deploy:
  kubectl:
    manifests:
    - ./leeroy-web/kubernetes/*
    - ./leeroy-app/kubernetes/*

skaffold-demo's People

Contributors

ravening avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.