github.com/GoogleContainerTools/skaffold/v2@v2.13.2/examples/microservices/README.md (about) 1 ### Example: µSvcs with Skaffold 2 3 [](https://ssh.cloud.google.com/cloudshell/editor?cloudshell_git_repo=https://github.com/GoogleContainerTools/skaffold&cloudshell_open_in_editor=README.md&cloudshell_workspace=examples/microservices) 4 5 In this example: 6 7 * Deploy multiple applications with skaffold 8 * In development, only rebuild and redeploy the artifacts that have changed 9 * Deploy multiple applications outside the working directory 10 * Define dependencies between artifacts 11 12 In the real world, Kubernetes deployments will consist of multiple applications that work together. 13 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. 14 15 **WARNING: If you're running this on a cloud cluster, this example will create a service and expose a webserver. 16 It's highly suggested that you only run this example on a local, private cluster like minikube or Kubernetes in Docker for Desktop.** 17 18 #### Running the example on minikube 19 20 From this directory, run 21 22 ```bash 23 skaffold dev 24 ``` 25 26 Now, in a different terminal, hit the `leeroy-web` endpoint 27 28 ```bash 29 $ curl $(minikube service leeroy-web --url) 30 leeroooooy app! 31 ``` 32 33 Now, let's change the message in `leeroy-app` without changing `leeroy-web`. 34 Add a few exclamations points because this is exhilarating stuff. 35 36 In `leeroy-app/app.go`, change the message here 37 38 ```golang 39 func handler(w http.ResponseWriter, r *http.Request) { 40 fmt.Fprintf(w, "leeroooooy app!!!\n") 41 } 42 ``` 43 44 Once you see the log message 45 46 ``` 47 [leeroy-app-5b4dfdcbc6-6vf6r leeroy-app] 2018/03/30 06:28:47 leeroy app server ready 48 ``` 49 50 Your service will be ready to hit again with 51 52 ```bash 53 $ curl $(minikube service leeroy-web --url) 54 leeroooooy app!!! 55 ``` 56 57 #### Configuration walkthrough 58 59 Let's walk through the first part of the skaffold.yaml 60 61 ```yaml 62 artifacts: 63 - image: leeroy-web 64 context: leeroy-web 65 requires: 66 - image: base 67 alias: BASE 68 - image: leeroy-app 69 context: leeroy-app 70 requires: 71 - image: base 72 alias: BASE 73 - image: base 74 context: base 75 ``` 76 77 We're deploying a `leeroy-web` image, which we build in the context of its subdirectory and a `leeroy-app` image built similarly. Both of these artifacts depend on the `base` artifact which their `Dockerfile`s can reference as a build argument keyed on the alias `BASE`. 78 79 ```dockerfile 80 ARG BASE 81 ... 82 FROM $BASE 83 COPY --from=builder /app . 84 ``` 85 `leeroy-web` will listen for requests, and then make a simple HTTP call to `leeroy-app` using Kubernetes service discovery and return that result. 86 87 In the deploy stanza, we use the glob matching pattern to deploy all YAML and JSON files in the respective Kubernetes manifest directories. 88 89 ```yaml 90 manifests: 91 rawYaml: 92 - ./leeroy-web/kubernetes/* 93 - ./leeroy-app/kubernetes/* 94 ``` 95