From 50f1a523ae4b4722647bb84b43a80d4ebe32ee66 Mon Sep 17 00:00:00 2001 From: Matt Rickard Date: Mon, 24 Sep 2018 10:54:34 -0700 Subject: [PATCH 1/5] [examples] revert examples back to 0.14.0 release (v1alpha2) --- examples/annotated-skaffold.yaml | 9 +++------ examples/bazel/skaffold.yaml | 2 +- examples/getting-started/skaffold.yaml | 2 +- examples/helm-deployment/README.adoc | 2 -- examples/helm-deployment/skaffold.yaml | 5 ++--- examples/kaniko/skaffold.yaml | 5 ++--- examples/kustomize/skaffold.yaml | 2 +- examples/microservices/skaffold.yaml | 2 +- .../tagging-with-environment-variables/skaffold.yaml | 2 +- 9 files changed, 12 insertions(+), 19 deletions(-) diff --git a/examples/annotated-skaffold.yaml b/examples/annotated-skaffold.yaml index ac9399483eb..3f2a69a0686 100644 --- a/examples/annotated-skaffold.yaml +++ b/examples/annotated-skaffold.yaml @@ -1,4 +1,4 @@ -apiVersion: skaffold/v1alpha3 +apiVersion: skaffold/v1alpha2 kind: Config build: # tagPolicy determines how skaffold is going to tag your images. @@ -101,8 +101,7 @@ build: # See https://github.com/GoogleContainerTools/kaniko#running-kaniko-in-a-kubernetes-cluster # # kaniko: - # buildContext: - # gcsBucket: k8s-skaffold + # gcsBucket: k8s-skaffold # pullSecret: /a/secret/path/serviceaccount.json # namespace: default # timeout: 20m @@ -147,9 +146,7 @@ deploy: # releases: # - name: skaffold-helm # chartPath: skaffold-helm - # valuesFiles: - # - first-values-file.yaml - # - second-values-file.yaml + # valuesFilePath: helm-skaffold-values.yaml # values: # image: skaffold-helm # namespace: skaffold diff --git a/examples/bazel/skaffold.yaml b/examples/bazel/skaffold.yaml index 6424b8091a3..a29ce7b74db 100644 --- a/examples/bazel/skaffold.yaml +++ b/examples/bazel/skaffold.yaml @@ -1,4 +1,4 @@ -apiVersion: skaffold/v1alpha3 +apiVersion: skaffold/v1alpha2 kind: Config build: artifacts: diff --git a/examples/getting-started/skaffold.yaml b/examples/getting-started/skaffold.yaml index fb4d4adbc4c..2c5d8ef12b6 100644 --- a/examples/getting-started/skaffold.yaml +++ b/examples/getting-started/skaffold.yaml @@ -1,4 +1,4 @@ -apiVersion: skaffold/v1alpha3 +apiVersion: skaffold/v1alpha2 kind: Config build: artifacts: diff --git a/examples/helm-deployment/README.adoc b/examples/helm-deployment/README.adoc index 1fd3e17f3d8..a4d94cb3afc 100644 --- a/examples/helm-deployment/README.adoc +++ b/examples/helm-deployment/README.adoc @@ -30,8 +30,6 @@ deploy: namespace: skaffold values: image: skaffold-helm - valuesFiles: - - helm-values-file.yaml ``` This part tells skaffold to set the `image` parameter of the values file to the built skaffold-helm image and tag. diff --git a/examples/helm-deployment/skaffold.yaml b/examples/helm-deployment/skaffold.yaml index 6c5ae9febdc..6511d582764 100644 --- a/examples/helm-deployment/skaffold.yaml +++ b/examples/helm-deployment/skaffold.yaml @@ -1,4 +1,4 @@ -apiVersion: skaffold/v1alpha3 +apiVersion: skaffold/v1alpha2 kind: Config build: tagPolicy: @@ -11,8 +11,7 @@ deploy: - name: skaffold-helm chartPath: skaffold-helm #wait: true - #valuesFiles: - #- helm-skaffold-values.yaml + #valuesFilePath: helm-skaffold-values.yaml values: image: gcr.io/k8s-skaffold/skaffold-helm #recreatePods will pass --recreate-pods to helm upgrade diff --git a/examples/kaniko/skaffold.yaml b/examples/kaniko/skaffold.yaml index 09271f92719..1b81d4a523d 100644 --- a/examples/kaniko/skaffold.yaml +++ b/examples/kaniko/skaffold.yaml @@ -1,11 +1,10 @@ -apiVersion: skaffold/v1alpha3 +apiVersion: skaffold/v1alpha2 kind: Config build: artifacts: - imageName: gcr.io/k8s-skaffold/skaffold-example kaniko: - buildContext: - gcsBucket: skaffold-kaniko + gcsBucket: skaffold-kaniko pullSecretName: e2esecret namespace: default deploy: diff --git a/examples/kustomize/skaffold.yaml b/examples/kustomize/skaffold.yaml index 0ad12da902c..65edfabae9a 100644 --- a/examples/kustomize/skaffold.yaml +++ b/examples/kustomize/skaffold.yaml @@ -1,4 +1,4 @@ -apiVersion: skaffold/v1alpha3 +apiVersion: skaffold/v1alpha2 kind: Config deploy: kustomize: {} diff --git a/examples/microservices/skaffold.yaml b/examples/microservices/skaffold.yaml index 09625d7e8a1..1cc1615e56c 100644 --- a/examples/microservices/skaffold.yaml +++ b/examples/microservices/skaffold.yaml @@ -1,4 +1,4 @@ -apiVersion: skaffold/v1alpha3 +apiVersion: skaffold/v1alpha2 kind: Config build: artifacts: diff --git a/examples/tagging-with-environment-variables/skaffold.yaml b/examples/tagging-with-environment-variables/skaffold.yaml index 4cb86eb796b..93dc15c23e5 100644 --- a/examples/tagging-with-environment-variables/skaffold.yaml +++ b/examples/tagging-with-environment-variables/skaffold.yaml @@ -1,4 +1,4 @@ -apiVersion: skaffold/v1alpha3 +apiVersion: skaffold/v1alpha2 kind: Config build: artifacts: From db4fada77c098ac267ef87a33dc9f6d5640fd73b Mon Sep 17 00:00:00 2001 From: Matt Rickard Date: Mon, 24 Sep 2018 10:55:03 -0700 Subject: [PATCH 2/5] [integration] use examples at HEAD (v1alpha3) --- integration/examples/README.adoc | 29 +++ integration/examples/annotated-skaffold.yaml | 179 ++++++++++++++++++ integration/examples/bazel/BUILD | 9 + integration/examples/bazel/README.adoc | 42 ++++ integration/examples/bazel/WORKSPACE | 27 +++ integration/examples/bazel/bazel-bazel | 1 + integration/examples/bazel/bazel-bin | 1 + integration/examples/bazel/bazel-genfiles | 1 + integration/examples/bazel/bazel-out | 1 + integration/examples/bazel/bazel-testlogs | 1 + integration/examples/bazel/k8s/k8s-pod.yaml | 8 + integration/examples/bazel/main.go | 13 ++ integration/examples/bazel/skaffold.yaml | 12 ++ .../examples/getting-started/Dockerfile | 7 + .../examples/getting-started/README.adoc | 33 ++++ .../examples/getting-started/k8s-pod.yaml | 8 + integration/examples/getting-started/main.go | 14 ++ .../examples/getting-started/skaffold.yaml | 14 ++ .../examples/helm-deployment/Dockerfile | 1 + .../examples/helm-deployment/README.adoc | 41 ++++ .../helm-deployment/skaffold-helm/.helmignore | 21 ++ .../helm-deployment/skaffold-helm/Chart.yaml | 4 + .../skaffold-helm/templates/_helpers.tpl | 16 ++ .../skaffold-helm/templates/deployment.yaml | 29 +++ .../skaffold-helm/templates/ingress.yaml | 32 ++++ .../skaffold-helm/templates/service.yaml | 19 ++ .../helm-deployment/skaffold-helm/values.yaml | 39 ++++ .../examples/helm-deployment/skaffold.yaml | 26 +++ integration/examples/kaniko/Dockerfile | 6 + integration/examples/kaniko/README.adoc | 34 ++++ integration/examples/kaniko/k8s-pod.yaml | 8 + integration/examples/kaniko/main.go | 13 ++ integration/examples/kaniko/skaffold.yaml | 14 ++ integration/examples/kustomize/README.adoc | 30 +++ .../examples/kustomize/deployment.yaml | 19 ++ .../examples/kustomize/kustomization.yaml | 4 + integration/examples/kustomize/patch.yaml | 13 ++ integration/examples/kustomize/skaffold.yaml | 4 + .../examples/microservices/README.adoc | 83 ++++++++ .../microservices/leeroy-app/Dockerfile | 7 + .../examples/microservices/leeroy-app/app.go | 17 ++ .../leeroy-app/kubernetes/deployment.yaml | 35 ++++ .../microservices/leeroy-web/Dockerfile | 7 + .../leeroy-web/kubernetes/deployment.yaml | 37 ++++ .../examples/microservices/leeroy-web/web.go | 26 +++ .../examples/microservices/skaffold.yaml | 13 ++ .../Dockerfile | 5 + .../README.adoc | 45 +++++ .../k8s-pod.yaml | 9 + .../main.go | 13 ++ .../skaffold.yaml | 12 ++ integration/run_test.go | 16 +- 52 files changed, 1090 insertions(+), 8 deletions(-) create mode 100644 integration/examples/README.adoc create mode 100644 integration/examples/annotated-skaffold.yaml create mode 100644 integration/examples/bazel/BUILD create mode 100644 integration/examples/bazel/README.adoc create mode 100644 integration/examples/bazel/WORKSPACE create mode 120000 integration/examples/bazel/bazel-bazel create mode 120000 integration/examples/bazel/bazel-bin create mode 120000 integration/examples/bazel/bazel-genfiles create mode 120000 integration/examples/bazel/bazel-out create mode 120000 integration/examples/bazel/bazel-testlogs create mode 100644 integration/examples/bazel/k8s/k8s-pod.yaml create mode 100644 integration/examples/bazel/main.go create mode 100644 integration/examples/bazel/skaffold.yaml create mode 100644 integration/examples/getting-started/Dockerfile create mode 100644 integration/examples/getting-started/README.adoc create mode 100644 integration/examples/getting-started/k8s-pod.yaml create mode 100644 integration/examples/getting-started/main.go create mode 100644 integration/examples/getting-started/skaffold.yaml create mode 100644 integration/examples/helm-deployment/Dockerfile create mode 100644 integration/examples/helm-deployment/README.adoc create mode 100644 integration/examples/helm-deployment/skaffold-helm/.helmignore create mode 100644 integration/examples/helm-deployment/skaffold-helm/Chart.yaml create mode 100644 integration/examples/helm-deployment/skaffold-helm/templates/_helpers.tpl create mode 100644 integration/examples/helm-deployment/skaffold-helm/templates/deployment.yaml create mode 100644 integration/examples/helm-deployment/skaffold-helm/templates/ingress.yaml create mode 100644 integration/examples/helm-deployment/skaffold-helm/templates/service.yaml create mode 100644 integration/examples/helm-deployment/skaffold-helm/values.yaml create mode 100644 integration/examples/helm-deployment/skaffold.yaml create mode 100644 integration/examples/kaniko/Dockerfile create mode 100644 integration/examples/kaniko/README.adoc create mode 100644 integration/examples/kaniko/k8s-pod.yaml create mode 100644 integration/examples/kaniko/main.go create mode 100644 integration/examples/kaniko/skaffold.yaml create mode 100644 integration/examples/kustomize/README.adoc create mode 100644 integration/examples/kustomize/deployment.yaml create mode 100644 integration/examples/kustomize/kustomization.yaml create mode 100644 integration/examples/kustomize/patch.yaml create mode 100644 integration/examples/kustomize/skaffold.yaml create mode 100644 integration/examples/microservices/README.adoc create mode 100644 integration/examples/microservices/leeroy-app/Dockerfile create mode 100644 integration/examples/microservices/leeroy-app/app.go create mode 100644 integration/examples/microservices/leeroy-app/kubernetes/deployment.yaml create mode 100644 integration/examples/microservices/leeroy-web/Dockerfile create mode 100644 integration/examples/microservices/leeroy-web/kubernetes/deployment.yaml create mode 100644 integration/examples/microservices/leeroy-web/web.go create mode 100644 integration/examples/microservices/skaffold.yaml create mode 100644 integration/examples/tagging-with-environment-variables/Dockerfile create mode 100644 integration/examples/tagging-with-environment-variables/README.adoc create mode 100644 integration/examples/tagging-with-environment-variables/k8s-pod.yaml create mode 100644 integration/examples/tagging-with-environment-variables/main.go create mode 100644 integration/examples/tagging-with-environment-variables/skaffold.yaml diff --git a/integration/examples/README.adoc b/integration/examples/README.adoc new file mode 100644 index 00000000000..5f29d60538e --- /dev/null +++ b/integration/examples/README.adoc @@ -0,0 +1,29 @@ +== Examples +:icons: font + +To run any of the examples, replace `k8s-project` with your GCP project ID. + +ifndef::env-github[] + +link:{github-repo-tree}/examples[see on Github icon:github[]] + +include::./getting-started/README.adoc[] +include::./microservices/README.adoc[] +include::./tagging-with-environment-variables/README.adoc[] +include::./helm-deployment/README.adoc[] +include::./kustomize/README.adoc[] +include::./kaniko/README.adoc[] +include::./bazel/README.adoc[] +endif::[] + +ifdef::env-github[] + +- link:./getting-started[] +- link:./microservices[] +- link:./tagging-with-environment-variables[] +- link:./helm-deployment[] +- link:./kustomize[] +- link:./kaniko[] +- link:./bazel[] + +endif::[] diff --git a/integration/examples/annotated-skaffold.yaml b/integration/examples/annotated-skaffold.yaml new file mode 100644 index 00000000000..ac9399483eb --- /dev/null +++ b/integration/examples/annotated-skaffold.yaml @@ -0,0 +1,179 @@ +apiVersion: skaffold/v1alpha3 +kind: Config +build: + # tagPolicy determines how skaffold is going to tag your images. + # We provide a few strategies here, although you most likely won't need to care! + # The policy can `gitCommit`, `sha256` or `envTemplate`. + # If not specified, it defaults to `gitCommit: {}`. + tagPolicy: + # Tag the image with the git commit of your current repository. + gitCommit: {} + + # Tag the image with the checksum of the built image (image id). + # sha256: {} + + # Tag the image with a configurable template string. + # The template must be in the golang text/template syntax: https://golang.org/pkg/text/template/ + # The template is compiled and executed against the current environment, + # with those variables injected: + # IMAGE_NAME | Name of the image being built, as supplied in the artifacts section. + # DIGEST | Digest of the newly built image. For eg. `sha256:27ffc7f352665cc50ae3cbcc4b2725e36062f1b38c611b6f95d6df9a7510de23`. + # DIGEST_ALGO | Algorithm used by the digest: For eg. `sha256`. + # DIGEST_HEX | Digest of the newly built image. For eg. `27ffc7f352665cc50ae3cbcc4b2725e36062f1b38c611b6f95d6df9a7510de23`. + # Example + # envTemplate: + # template: "{{.RELEASE}}-{{.IMAGE_NAME}}" + + # Tag the image with the build timestamp. + # The format can be overridden with golang formats, see: https://golang.org/pkg/time/#Time.Format + # Default format is "2006-01-02_15-04-05.999_MST + # The timezone is by default the local timezone, this can be overridden, see https://golang.org/pkg/time/#Time.LoadLocation + # dateTime: + # format: "2006-01-02" + # timezone: "UTC" + + # artifacts is a list of the actual images you're going to be building + # you can include as many as you want here. + artifacts: + # The name of the image to be built. + - imageName: gcr.io/k8s-skaffold/skaffold-example + # The path to your dockerfile context. Defaults to ".". + workspace: ../examples/getting-started + + # Each artifact is of a given type among: `docker` and `bazel`. + # If not specified, it defaults to `docker: {}`. + docker: + # Dockerfile's location relative to workspace. Defaults to "Dockerfile" + dockerfilePath: Dockerfile + # Key/value arguements passed to the docker build. + buildArgs: + key1: "value1" + key2: "value2" + # Images to consider as cache sources + cacheFrom: + - image1 + - image2 + # Dockerfile target name to build. + # target: stageName + + # bazel requires bazel CLI to be installed and the artifacts sources to + # contain Bazel configuration files. + # bazel: + # target: //:skaffold_example.tar + +# This next section is where you'll put your specific builder configuration. + # Valid builders are `local`, `googleCloudBuild` and `kaniko`. + # Defaults to `local: {}` + + # Pushing the images can be skipped. If no value is specified, it'll default to + # `true` on minikube or Docker for Desktop, for even faster build and deploy cycles. + # `false` on other types of kubernetes clusters that require pushing the images. + # skaffold defers to your ~/.docker/config for authentication information. + # If you're using Google Container Registry, make sure that you have gcloud and + # docker-credentials-helper-gcr configured correctly. + # + # By default, the local builder connects to the Docker daemon with Go code to build + # images. If `useDockerCLI` is set, skaffold will simply shell out to the docker CLI. + # `useBuildkit` can also be set to activate the experimental BuildKit feature. + # + # local: + # skipPush: true + # useDockerCLI: false + # useBuildkit: false + + # Docker artifacts can be built on Google Cloud Build. The projectId then needs + # to be provided and the currently logged user should be given permissions to trigger + # new builds on Cloud Build. + # If the projectId is not provided, Skaffold will try to guess it from the image name. + # For eg. If the artifact image name is gcr.io/myproject/image, then Skaffold will use + # the `myproject` GCP project. + # All the other parameters are also optional. The default values are listed here: + # googleCloudBuild: + # projectId: YOUR_PROJECT + # diskSizeGb: 200 + # machineType: "N1_HIGHCPU_8"|"N1_HIGHCPU_32" + # timeout: 10000S + # dockerImage: gcr.io/cloud-builders/docker + + # Docker artifacts can be built on a Kubernetes cluster with Kaniko. + # Sources will be sent to a GCS bucket whose name is provided. + # Kaniko also needs access to a service account to push the final image. + # See https://github.com/GoogleContainerTools/kaniko#running-kaniko-in-a-kubernetes-cluster + # + # kaniko: + # buildContext: + # gcsBucket: k8s-skaffold + # pullSecret: /a/secret/path/serviceaccount.json + # namespace: default + # timeout: 20m + +# The deploy section has all the information needed to deploy. Along with build: +# it is a required section. +deploy: + # The type of the deployment method can be `kubectl` or `helm`. + + # The kubectl deployer uses a client side `kubectl apply` to apply the manifests to the cluster. + # You'll need a kubectl CLI version installed that's compatible with your cluster. + kubectl: + # manifests to deploy from files. + manifests: + - ../examples/getting-started/k8s-* + # kubectl can be passed additional option flags either on every command (Global), + # on creations (Apply) or deletions (Delete). + # flags: + # global: [""] + # apply: [""] + # delete: [""] + + # manifests to deploy from remote cluster. + # The path to where these manifests live in remote kubernetes cluster. + # Example + # remoteManifests: + # - deployment/web-app1 + # - namespace:deployment/web-app2 + + # kustomize: + # kustomizePath: "kustomization.yaml" + # kustomize deploys manifests with kubectl. + # kubectl can be passed additional option flags either on every command (Global), + # on creations (Apply) or deletions (Delete). + # flags: + # global: [""] + # apply: [""] + # delete: [""] + + # helm: + # helm releases to deploy. + # releases: + # - name: skaffold-helm + # chartPath: skaffold-helm + # valuesFiles: + # - first-values-file.yaml + # - second-values-file.yaml + # values: + # image: skaffold-helm + # namespace: skaffold + # version: "" + # recreatePods: false + # + # # setValues get appended to the helm deploy with --set. + # setValues: + # key: "value" + # + # # packaged section allows to package chart setting specific version + # # and/or appVersion using "helm package" command. + # packaged: + # # version is passed to "helm package --version" flag. + # # Note that you can specify both static string or dynamic template. + # version: {{ .CHART_VERSION }}-dirty + # # appVersion is passed to "helm package --app-version" flag. + # # Note that you can specify both static string or dynamic template. + # appVersion: {{ .CHART_VERSION }}-dirty + +# profiles section has all the profile information which can be used to override any build or deploy configuration +profiles: + - name: gcb + build: + googleCloudBuild: + projectId: k8s-skaffold + diff --git a/integration/examples/bazel/BUILD b/integration/examples/bazel/BUILD new file mode 100644 index 00000000000..ba00afe13d3 --- /dev/null +++ b/integration/examples/bazel/BUILD @@ -0,0 +1,9 @@ +load("@io_bazel_rules_docker//go:image.bzl", "go_image") + +go_image( + name = "skaffold_example", + srcs = ["main.go"], + goos = "linux", + goarch = "amd64", + static = "on", +) diff --git a/integration/examples/bazel/README.adoc b/integration/examples/bazel/README.adoc new file mode 100644 index 00000000000..20e8f2e2ac2 --- /dev/null +++ b/integration/examples/bazel/README.adoc @@ -0,0 +1,42 @@ +=== Example: bazel +:icons: font + +Bazel is one of the supported builders in Skaffold. +The way you configure it in `skaffold.yaml` is the following build stanza: + +[source,yaml] +---- +build: + artifacts: + - imageName: gcr.io/k8s-skaffold/skaffold-example + workspace: . <1> + bazel: # <2> + target: //:skaffold_example.tar # <3> +---- +<1> make sure the workspace contains the bazel files (`WORKSPACE`, `BUILD`) +<2> add bazel to each artifact +<3> specify target - our builder will use this to load to the image to the Docker daemon + +ifndef::env-github[] +==== link:{github-repo-tree}/examples/bazel[Example files icon:github[]] + +[source,yaml, indent=3, title=skaffold.yaml] +---- +include::skaffold.yaml[] +---- + +[source,go, indent=3, title=main.go, syntax=go] +---- +include::main.go[] +---- + +[source,bazel, indent=3, title=WORKSPACE] +---- +include::WORKSPACE[] +---- + +[source,bazel, indent=3, title=BUILD] +---- +include::BUILD[] +---- +endif::[] diff --git a/integration/examples/bazel/WORKSPACE b/integration/examples/bazel/WORKSPACE new file mode 100644 index 00000000000..2f1599b6a10 --- /dev/null +++ b/integration/examples/bazel/WORKSPACE @@ -0,0 +1,27 @@ +workspace(name = "skaffold") + +git_repository( + name = "io_bazel_rules_docker", + remote = "https://github.com/bazelbuild/rules_docker.git", + tag = "v0.4.0", +) + +http_archive( + name = "io_bazel_rules_go", + sha256 = "feba3278c13cde8d67e341a837f69a029f698d7a27ddbb2a202be7a10b22142a", + url = "https://github.com/bazelbuild/rules_go/releases/download/0.10.3/rules_go-0.10.3.tar.gz", +) + +load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains") + +go_rules_dependencies() +go_register_toolchains( + go_version = "1.10.1", +) + +load( + "@io_bazel_rules_docker//go:image.bzl", + _go_image_repos = "repositories", +) + +_go_image_repos() diff --git a/integration/examples/bazel/bazel-bazel b/integration/examples/bazel/bazel-bazel new file mode 120000 index 00000000000..695b14fdd87 --- /dev/null +++ b/integration/examples/bazel/bazel-bazel @@ -0,0 +1 @@ +/private/var/tmp/_bazel_mrick/6d90e34b053448fe4d36a0feb550668e/execroot/skaffold \ No newline at end of file diff --git a/integration/examples/bazel/bazel-bin b/integration/examples/bazel/bazel-bin new file mode 120000 index 00000000000..f5fb9ee1aad --- /dev/null +++ b/integration/examples/bazel/bazel-bin @@ -0,0 +1 @@ +/private/var/tmp/_bazel_mrick/6d90e34b053448fe4d36a0feb550668e/execroot/skaffold/bazel-out/darwin-fastbuild/bin \ No newline at end of file diff --git a/integration/examples/bazel/bazel-genfiles b/integration/examples/bazel/bazel-genfiles new file mode 120000 index 00000000000..7eca468d4f7 --- /dev/null +++ b/integration/examples/bazel/bazel-genfiles @@ -0,0 +1 @@ +/private/var/tmp/_bazel_mrick/6d90e34b053448fe4d36a0feb550668e/execroot/skaffold/bazel-out/darwin-fastbuild/genfiles \ No newline at end of file diff --git a/integration/examples/bazel/bazel-out b/integration/examples/bazel/bazel-out new file mode 120000 index 00000000000..9950c1455cb --- /dev/null +++ b/integration/examples/bazel/bazel-out @@ -0,0 +1 @@ +/private/var/tmp/_bazel_mrick/6d90e34b053448fe4d36a0feb550668e/execroot/skaffold/bazel-out \ No newline at end of file diff --git a/integration/examples/bazel/bazel-testlogs b/integration/examples/bazel/bazel-testlogs new file mode 120000 index 00000000000..c757be5b1a4 --- /dev/null +++ b/integration/examples/bazel/bazel-testlogs @@ -0,0 +1 @@ +/private/var/tmp/_bazel_mrick/6d90e34b053448fe4d36a0feb550668e/execroot/skaffold/bazel-out/darwin-fastbuild/testlogs \ No newline at end of file diff --git a/integration/examples/bazel/k8s/k8s-pod.yaml b/integration/examples/bazel/k8s/k8s-pod.yaml new file mode 100644 index 00000000000..2ecd153fb4f --- /dev/null +++ b/integration/examples/bazel/k8s/k8s-pod.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: Pod +metadata: + name: bazel +spec: + containers: + - name: bazel + image: gcr.io/k8s-skaffold/skaffold-bazel diff --git a/integration/examples/bazel/main.go b/integration/examples/bazel/main.go new file mode 100644 index 00000000000..8f98567919a --- /dev/null +++ b/integration/examples/bazel/main.go @@ -0,0 +1,13 @@ +package main + +import ( + "fmt" + "time" +) + +func main() { + for { + fmt.Println("Hello bazel!!!!") + time.Sleep(time.Second * 1) + } +} diff --git a/integration/examples/bazel/skaffold.yaml b/integration/examples/bazel/skaffold.yaml new file mode 100644 index 00000000000..6424b8091a3 --- /dev/null +++ b/integration/examples/bazel/skaffold.yaml @@ -0,0 +1,12 @@ +apiVersion: skaffold/v1alpha3 +kind: Config +build: + artifacts: + - imageName: gcr.io/k8s-skaffold/skaffold-bazel + workspace: . + bazel: + target: //:skaffold_example.tar + local: {} +deploy: + kubectl: + manifests: diff --git a/integration/examples/getting-started/Dockerfile b/integration/examples/getting-started/Dockerfile new file mode 100644 index 00000000000..184d6cce3e3 --- /dev/null +++ b/integration/examples/getting-started/Dockerfile @@ -0,0 +1,7 @@ +FROM golang:1.10.1-alpine3.7 as builder +COPY main.go . +RUN go build -o /app main.go + +FROM alpine:3.7 +CMD ["./app"] +COPY --from=builder /app . diff --git a/integration/examples/getting-started/README.adoc b/integration/examples/getting-started/README.adoc new file mode 100644 index 00000000000..ba15fd56e93 --- /dev/null +++ b/integration/examples/getting-started/README.adoc @@ -0,0 +1,33 @@ +=== Example: Getting started with a simple go app +:icons: font + +This is a simple example based on + +* *building* a single go file app and with a multistage `Dockerfile` using local docker to build +* *tagging* using the default tagPolicy (`gitCommit`) +* *deploying* a single container pod using `kubectl` + +ifndef::env-github[] +==== link:{github-repo-tree}/examples/getting-started[Example files icon:github[]] + +[source,yaml, indent=3, title=skaffold.yaml] +---- +include::skaffold.yaml[] +---- + +[source,go, indent=3, title=main.go, syntax=go] +---- +include::main.go[] +---- + +[source,docker, indent=3, title=Dockerfile] +---- +include::Dockerfile[] +---- + +[source,yaml, indent=3, title=k8s-pod.yaml] +---- +include::k8s-pod.yaml[] +---- + +endif::[] diff --git a/integration/examples/getting-started/k8s-pod.yaml b/integration/examples/getting-started/k8s-pod.yaml new file mode 100644 index 00000000000..14cc6911607 --- /dev/null +++ b/integration/examples/getting-started/k8s-pod.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: Pod +metadata: + name: getting-started +spec: + containers: + - name: getting-started + image: gcr.io/k8s-skaffold/skaffold-example diff --git a/integration/examples/getting-started/main.go b/integration/examples/getting-started/main.go new file mode 100644 index 00000000000..593721cfe2e --- /dev/null +++ b/integration/examples/getting-started/main.go @@ -0,0 +1,14 @@ +package main + +import ( + "fmt" + "time" +) + +func main() { + for { + fmt.Println("Hello world!") + + time.Sleep(time.Second * 1) + } +} diff --git a/integration/examples/getting-started/skaffold.yaml b/integration/examples/getting-started/skaffold.yaml new file mode 100644 index 00000000000..fb4d4adbc4c --- /dev/null +++ b/integration/examples/getting-started/skaffold.yaml @@ -0,0 +1,14 @@ +apiVersion: skaffold/v1alpha3 +kind: Config +build: + artifacts: + - imageName: gcr.io/k8s-skaffold/skaffold-example +deploy: + kubectl: + manifests: + - k8s-* +profiles: + - name: gcb + build: + googleCloudBuild: + projectId: k8s-skaffold diff --git a/integration/examples/helm-deployment/Dockerfile b/integration/examples/helm-deployment/Dockerfile new file mode 100644 index 00000000000..75eca2cb8ef --- /dev/null +++ b/integration/examples/helm-deployment/Dockerfile @@ -0,0 +1 @@ +FROM nginx:stable diff --git a/integration/examples/helm-deployment/README.adoc b/integration/examples/helm-deployment/README.adoc new file mode 100644 index 00000000000..1fd3e17f3d8 --- /dev/null +++ b/integration/examples/helm-deployment/README.adoc @@ -0,0 +1,41 @@ +=== Example: helm +:icons: font + +ifndef::env-github[] +link:{github-repo-tree}/examples/helm-deployment[see on Github icon:github[]] +endif::[] + +==== Deploy multiple releases with Helm + +You can deploy multiple releases with skaffold, each will need a chartPath, a values file, and namespace. +Skaffold can inject intermediate build tags in the the values map in the skaffold.yaml. + +Let's walk through the skaffold yaml + +We'll be building an image called `skaffold-helm`, and its a dockerfile, so we'll add it to the artifacts. +``` +build: + artifacts: + - imageName: skaffold-helm +``` + +Now, we want to deploy this image with helm. +We add a new release in the helm part of the deploy stanza. +``` +deploy: + helm: + releases: + - name: skaffold-helm + chartPath: skaffold-helm + namespace: skaffold + values: + image: skaffold-helm + valuesFiles: + - helm-values-file.yaml +``` + +This part tells skaffold to set the `image` parameter of the values file to the built skaffold-helm image and tag. +``` + values: + image: skaffold-helm +``` diff --git a/integration/examples/helm-deployment/skaffold-helm/.helmignore b/integration/examples/helm-deployment/skaffold-helm/.helmignore new file mode 100644 index 00000000000..f0c13194444 --- /dev/null +++ b/integration/examples/helm-deployment/skaffold-helm/.helmignore @@ -0,0 +1,21 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj diff --git a/integration/examples/helm-deployment/skaffold-helm/Chart.yaml b/integration/examples/helm-deployment/skaffold-helm/Chart.yaml new file mode 100644 index 00000000000..f4fcfadbec9 --- /dev/null +++ b/integration/examples/helm-deployment/skaffold-helm/Chart.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +description: A Helm chart for Kubernetes +name: skaffold-helm +version: 0.1.0 diff --git a/integration/examples/helm-deployment/skaffold-helm/templates/_helpers.tpl b/integration/examples/helm-deployment/skaffold-helm/templates/_helpers.tpl new file mode 100644 index 00000000000..537a7399829 --- /dev/null +++ b/integration/examples/helm-deployment/skaffold-helm/templates/_helpers.tpl @@ -0,0 +1,16 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "skaffold-helm.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +*/}} +{{- define "skaffold-helm.fullname" -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/integration/examples/helm-deployment/skaffold-helm/templates/deployment.yaml b/integration/examples/helm-deployment/skaffold-helm/templates/deployment.yaml new file mode 100644 index 00000000000..c66fb3d31aa --- /dev/null +++ b/integration/examples/helm-deployment/skaffold-helm/templates/deployment.yaml @@ -0,0 +1,29 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: {{ .Release.Name }} + labels: + app: {{ template "skaffold-helm.name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + template: + metadata: + labels: + app: {{ template "skaffold-helm.name" . }} + release: {{ .Release.Name }} + spec: + containers: + - name: {{ .Chart.Name }} + image: {{ .Values.image }} + imagePullPolicy: {{ .Values.pullPolicy }} + command: ["/bin/bash", "-c", "--" ] + args: ["while true; do sleep 30; done;"] + resources: +{{ toYaml .Values.resources | indent 12 }} + {{- if .Values.nodeSelector }} + nodeSelector: +{{ toYaml .Values.nodeSelector | indent 8 }} + {{- end }} diff --git a/integration/examples/helm-deployment/skaffold-helm/templates/ingress.yaml b/integration/examples/helm-deployment/skaffold-helm/templates/ingress.yaml new file mode 100644 index 00000000000..87fe1e813e6 --- /dev/null +++ b/integration/examples/helm-deployment/skaffold-helm/templates/ingress.yaml @@ -0,0 +1,32 @@ +{{- if .Values.ingress.enabled -}} +{{- $serviceName := include "skaffold-helm.fullname" . -}} +{{- $servicePort := .Values.service.externalPort -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ template "skaffold-helm.fullname" . }} + labels: + app: {{ template "skaffold-helm.name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + annotations: + {{- range $key, $value := .Values.ingress.annotations }} + {{ $key }}: {{ $value | quote }} + {{- end }} +spec: + rules: + {{- range $host := .Values.ingress.hosts }} + - host: {{ $host }} + http: + paths: + - path: / + backend: + serviceName: {{ $serviceName }} + servicePort: {{ $servicePort }} + {{- end -}} + {{- if .Values.ingress.tls }} + tls: +{{ toYaml .Values.ingress.tls | indent 4 }} + {{- end -}} +{{- end -}} diff --git a/integration/examples/helm-deployment/skaffold-helm/templates/service.yaml b/integration/examples/helm-deployment/skaffold-helm/templates/service.yaml new file mode 100644 index 00000000000..da7b3ef867b --- /dev/null +++ b/integration/examples/helm-deployment/skaffold-helm/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ template "skaffold-helm.fullname" . }} + labels: + app: {{ template "skaffold-helm.name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.externalPort }} + targetPort: {{ .Values.service.internalPort }} + protocol: TCP + name: {{ .Values.service.name }} + selector: + app: {{ template "skaffold-helm.name" . }} + release: {{ .Release.Name }} diff --git a/integration/examples/helm-deployment/skaffold-helm/values.yaml b/integration/examples/helm-deployment/skaffold-helm/values.yaml new file mode 100644 index 00000000000..5ac1a982123 --- /dev/null +++ b/integration/examples/helm-deployment/skaffold-helm/values.yaml @@ -0,0 +1,39 @@ +# Default values for skaffold-helm. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. +replicaCount: 1 +image: nginx:stable +# This is the helm convention on declaring images +# image: +# repository: nginx +# tag: stable +# pullPolicy: IfNotPresent +service: + name: nginx + type: ClusterIP + externalPort: 80 + internalPort: 80 +ingress: + enabled: false + # Used to create an Ingress record. + hosts: + - chart-example.local + annotations: + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + tls: + # Secrets must be manually created in the namespace. + # - secretName: chart-example-tls + # hosts: + # - chart-example.local +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi diff --git a/integration/examples/helm-deployment/skaffold.yaml b/integration/examples/helm-deployment/skaffold.yaml new file mode 100644 index 00000000000..6c5ae9febdc --- /dev/null +++ b/integration/examples/helm-deployment/skaffold.yaml @@ -0,0 +1,26 @@ +apiVersion: skaffold/v1alpha3 +kind: Config +build: + tagPolicy: + sha256: {} + artifacts: + - imageName: gcr.io/k8s-skaffold/skaffold-helm +deploy: + helm: + releases: + - name: skaffold-helm + chartPath: skaffold-helm + #wait: true + #valuesFiles: + #- helm-skaffold-values.yaml + values: + image: gcr.io/k8s-skaffold/skaffold-helm + #recreatePods will pass --recreate-pods to helm upgrade + #recreatePods: true + #overrides builds an override values.yaml file to run with the helm deploy + #overrides: + # some: + # key: someValue + #setValues get appended to the helm deploy with --set. + #setValues: + #some.key: someValue diff --git a/integration/examples/kaniko/Dockerfile b/integration/examples/kaniko/Dockerfile new file mode 100644 index 00000000000..2d107918ad0 --- /dev/null +++ b/integration/examples/kaniko/Dockerfile @@ -0,0 +1,6 @@ +FROM gcr.io/google-appengine/golang + +WORKDIR /go/src/github.com/GoogleCloudPlatform/skaffold +CMD ["./app"] +COPY main.go . +RUN go build -o app main.go diff --git a/integration/examples/kaniko/README.adoc b/integration/examples/kaniko/README.adoc new file mode 100644 index 00000000000..537f94a53a6 --- /dev/null +++ b/integration/examples/kaniko/README.adoc @@ -0,0 +1,34 @@ +=== Example: kaniko +:icons: font + +This is an example demonstrating + +* *building* a single go file app and with a single stage `Dockerfile` using https://github.com/GoogleContainerTools/kaniko[kaniko] to build on a K8S cluster +* *tagging* using the default tagPolicy (`gitCommit`) +* *deploying* a single container pod using `kubectl` + +ifndef::env-github[] +==== Example files +link:{github-repo-tree}/examples/kaniko[see on Github icon:github[]] + +[source,yaml, indent=3, title=skaffold.yaml] +---- +include::skaffold.yaml[] +---- + +[source,go, indent=3, title=main.go, syntax=go] +---- +include::main.go[] +---- + +[source,docker, indent=3, title=Dockerfile] +---- +include::Dockerfile[] +---- + +[source,yaml, indent=3, title=k8s-pod.yaml] +---- +include::k8s-pod.yaml[] +---- + +endif::[] diff --git a/integration/examples/kaniko/k8s-pod.yaml b/integration/examples/kaniko/k8s-pod.yaml new file mode 100644 index 00000000000..920e94c5b76 --- /dev/null +++ b/integration/examples/kaniko/k8s-pod.yaml @@ -0,0 +1,8 @@ +apiVersion: v1 +kind: Pod +metadata: + name: getting-started-kaniko +spec: + containers: + - name: getting-started + image: gcr.io/k8s-skaffold/skaffold-example \ No newline at end of file diff --git a/integration/examples/kaniko/main.go b/integration/examples/kaniko/main.go new file mode 100644 index 00000000000..64b7bdfc4a1 --- /dev/null +++ b/integration/examples/kaniko/main.go @@ -0,0 +1,13 @@ +package main + +import ( + "fmt" + "time" +) + +func main() { + for { + fmt.Println("Hello world!") + time.Sleep(time.Second * 1) + } +} diff --git a/integration/examples/kaniko/skaffold.yaml b/integration/examples/kaniko/skaffold.yaml new file mode 100644 index 00000000000..09271f92719 --- /dev/null +++ b/integration/examples/kaniko/skaffold.yaml @@ -0,0 +1,14 @@ +apiVersion: skaffold/v1alpha3 +kind: Config +build: + artifacts: + - imageName: gcr.io/k8s-skaffold/skaffold-example + kaniko: + buildContext: + gcsBucket: skaffold-kaniko + pullSecretName: e2esecret + namespace: default +deploy: + kubectl: + manifests: + - k8s-* diff --git a/integration/examples/kustomize/README.adoc b/integration/examples/kustomize/README.adoc new file mode 100644 index 00000000000..8db1e0fb390 --- /dev/null +++ b/integration/examples/kustomize/README.adoc @@ -0,0 +1,30 @@ +=== Example: kustomize +:icons: font + +This is an example demonstrating how skaffold can work with kustomize with the `skaffold deploy` command. + +ifndef::env-github[] +==== Example files +link:{github-repo-tree}/examples/kustomize[see on Github icon:github[]] + +[source,yaml, indent=3, title=skaffold.yaml] +---- +include::skaffold.yaml[] +---- + +[source,yaml, indent=3, title=kustomization.yaml] +---- +include::kustomization.yaml[] +---- + +[source,patch, indent=3, title=patch.yaml] +---- +include::patch.yaml[] +---- + +[source,patch, indent=3, title=deployment.yaml] +---- +include::deployment.yaml[] +---- + +endif::[] diff --git a/integration/examples/kustomize/deployment.yaml b/integration/examples/kustomize/deployment.yaml new file mode 100644 index 00000000000..44546fd5616 --- /dev/null +++ b/integration/examples/kustomize/deployment.yaml @@ -0,0 +1,19 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: kustomize-test + labels: + app: kustomize-test +spec: + replicas: 1 + selector: + matchLabels: + app: kustomize-test + template: + metadata: + labels: + app: kustomize-test + spec: + containers: + - name: kustomize-test + image: gcr.io/k8s-skaffold/not/a/valid/image diff --git a/integration/examples/kustomize/kustomization.yaml b/integration/examples/kustomize/kustomization.yaml new file mode 100644 index 00000000000..88b1320b5b9 --- /dev/null +++ b/integration/examples/kustomize/kustomization.yaml @@ -0,0 +1,4 @@ +resources: + - deployment.yaml +patches: + - patch.yaml diff --git a/integration/examples/kustomize/patch.yaml b/integration/examples/kustomize/patch.yaml new file mode 100644 index 00000000000..0583d7a3318 --- /dev/null +++ b/integration/examples/kustomize/patch.yaml @@ -0,0 +1,13 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: kustomize-test +spec: + template: + spec: + containers: + - name: kustomize-test + image: index.docker.io/library/busybox + command: + - sleep + - "3600" diff --git a/integration/examples/kustomize/skaffold.yaml b/integration/examples/kustomize/skaffold.yaml new file mode 100644 index 00000000000..0ad12da902c --- /dev/null +++ b/integration/examples/kustomize/skaffold.yaml @@ -0,0 +1,4 @@ +apiVersion: skaffold/v1alpha3 +kind: Config +deploy: + kustomize: {} diff --git a/integration/examples/microservices/README.adoc b/integration/examples/microservices/README.adoc new file mode 100644 index 00000000000..7a32dea63f7 --- /dev/null +++ b/integration/examples/microservices/README.adoc @@ -0,0 +1,83 @@ +=== Example: µSvcs with Skaffold +:icons: font + +ifndef::env-github[] +link:{github-repo-tree}/examples/microservices[see on Github icon:github[]] +endif::[] + +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 + +```bash +$ skaffold dev +``` + +Now, in a different terminal, hit the `leeroy-web` endpoint + +```bash +$ 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 + +```golang +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 + +```yaml + artifacts: + - imageName: gcr.io/k8s-skaffold/leeroy-web + workspace: ./leeroy-web/ + - imageName: gcr.io/k8s-skaffold/leeroy-app + workspace: ./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. + +```yaml +deploy: + kubectl: + manifests: + - ./leeroy-web/kubernetes/* + - ./leeroy-app/kubernetes/* +``` + diff --git a/integration/examples/microservices/leeroy-app/Dockerfile b/integration/examples/microservices/leeroy-app/Dockerfile new file mode 100644 index 00000000000..6c10e125d7a --- /dev/null +++ b/integration/examples/microservices/leeroy-app/Dockerfile @@ -0,0 +1,7 @@ +FROM golang:1.10.1-alpine3.7 as builder +COPY app.go . +RUN go build -o /app . + +FROM alpine:3.7 +CMD ["./app"] +COPY --from=builder /app . diff --git a/integration/examples/microservices/leeroy-app/app.go b/integration/examples/microservices/leeroy-app/app.go new file mode 100644 index 00000000000..40f9c08afac --- /dev/null +++ b/integration/examples/microservices/leeroy-app/app.go @@ -0,0 +1,17 @@ +package main + +import ( + "fmt" + "log" + "net/http" +) + +func handler(w http.ResponseWriter, r *http.Request) { + fmt.Fprintf(w, "leeroooooy app!!\n") +} + +func main() { + log.Print("leeroy app server ready") + http.HandleFunc("/", handler) + http.ListenAndServe(":50051", nil) +} diff --git a/integration/examples/microservices/leeroy-app/kubernetes/deployment.yaml b/integration/examples/microservices/leeroy-app/kubernetes/deployment.yaml new file mode 100644 index 00000000000..56ef7152fef --- /dev/null +++ b/integration/examples/microservices/leeroy-app/kubernetes/deployment.yaml @@ -0,0 +1,35 @@ +apiVersion: v1 +kind: Service +metadata: + name: leeroy-app + labels: + app: leeroy-app +spec: + clusterIP: None + ports: + - port: 50051 + name: leeroy-app + selector: + app: leeroy-app +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: leeroy-app + labels: + app: leeroy-app +spec: + replicas: 1 + selector: + matchLabels: + app: leeroy-app + template: + metadata: + labels: + app: leeroy-app + spec: + containers: + - name: leeroy-app + image: gcr.io/k8s-skaffold/leeroy-app + ports: + - containerPort: 50051 diff --git a/integration/examples/microservices/leeroy-web/Dockerfile b/integration/examples/microservices/leeroy-web/Dockerfile new file mode 100644 index 00000000000..fba8dd8007b --- /dev/null +++ b/integration/examples/microservices/leeroy-web/Dockerfile @@ -0,0 +1,7 @@ +FROM golang:1.10.1-alpine3.7 as builder +COPY web.go . +RUN go build -o /web . + +FROM alpine:3.7 +CMD ["./web"] +COPY --from=builder /web . diff --git a/integration/examples/microservices/leeroy-web/kubernetes/deployment.yaml b/integration/examples/microservices/leeroy-web/kubernetes/deployment.yaml new file mode 100644 index 00000000000..fd8ad0bc032 --- /dev/null +++ b/integration/examples/microservices/leeroy-web/kubernetes/deployment.yaml @@ -0,0 +1,37 @@ +apiVersion: v1 +kind: Service +metadata: + name: leeroy-web + labels: + app: leeroy-web +spec: + type: NodePort + ports: + - port: 8080 + targetPort: 8080 + protocol: TCP + name: leeroy-web + selector: + app: leeroy-web +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: leeroy-web + labels: + app: leeroy-web +spec: + replicas: 1 + selector: + matchLabels: + app: leeroy-web + template: + metadata: + labels: + app: leeroy-web + spec: + containers: + - name: leeroy-web + image: gcr.io/k8s-skaffold/leeroy-web + ports: + - containerPort: 8080 diff --git a/integration/examples/microservices/leeroy-web/web.go b/integration/examples/microservices/leeroy-web/web.go new file mode 100644 index 00000000000..419fd62e067 --- /dev/null +++ b/integration/examples/microservices/leeroy-web/web.go @@ -0,0 +1,26 @@ +package main + +import ( + "io" + "net/http" + + "log" +) + +func handler(w http.ResponseWriter, r *http.Request) { + resp, err := http.Get("http://leeroy-app:50051") + if err != nil { + panic(err) + } + defer resp.Body.Close() + if _, err := io.Copy(w, resp.Body); err != nil { + panic(err) + } + +} + +func main() { + log.Print("leeroy web server ready") + http.HandleFunc("/", handler) + http.ListenAndServe(":8080", nil) +} diff --git a/integration/examples/microservices/skaffold.yaml b/integration/examples/microservices/skaffold.yaml new file mode 100644 index 00000000000..09625d7e8a1 --- /dev/null +++ b/integration/examples/microservices/skaffold.yaml @@ -0,0 +1,13 @@ +apiVersion: skaffold/v1alpha3 +kind: Config +build: + artifacts: + - imageName: gcr.io/k8s-skaffold/leeroy-web + workspace: ./leeroy-web/ + - imageName: gcr.io/k8s-skaffold/leeroy-app + workspace: ./leeroy-app/ +deploy: + kubectl: + manifests: + - ./leeroy-web/kubernetes/* + - ./leeroy-app/kubernetes/* diff --git a/integration/examples/tagging-with-environment-variables/Dockerfile b/integration/examples/tagging-with-environment-variables/Dockerfile new file mode 100644 index 00000000000..bf21da631a5 --- /dev/null +++ b/integration/examples/tagging-with-environment-variables/Dockerfile @@ -0,0 +1,5 @@ +FROM golang:1.10.1-alpine3.7 + +CMD ["./app"] +COPY main.go . +RUN go build -o app main.go diff --git a/integration/examples/tagging-with-environment-variables/README.adoc b/integration/examples/tagging-with-environment-variables/README.adoc new file mode 100644 index 00000000000..15d4d0abebf --- /dev/null +++ b/integration/examples/tagging-with-environment-variables/README.adoc @@ -0,0 +1,45 @@ +=== Example: using the envTemplate tag policy +:icons: font + +This example reuses the image name and uses an environment variable `FOO` to tag the image. +The way you configure it in `skaffold.yaml` is the following build stanza: + +[source,yaml] +---- +build: + artifacts: + - imageName: gcr.io/k8s-skaffold/skaffold-example + tagPolicy: # <1> + envTemplate: # <1> + template: "{{.IMAGE_NAME}}:{{.FOO}}" # <2> +---- +<1> define tagPolicy to be envTemplate +<2> use https://golang.org/pkg/text/template[go templates] syntax + +The `IMAGE_NAME` variable is built-in and reuses the value defined in the artifacts' `imageName`. + + +ifndef::env-github[] + + +==== link:{github-repo-tree}/examples/tagging-with-environment-variables[Example files icon:github[]] +[source,yaml, indent=3, title=skaffold.yaml] +---- +include::skaffold.yaml[] +---- + +[source,go, indent=3, title=main.go, syntax=go] +---- +include::main.go[] +---- + +[source,docker, indent=3, title=Dockerfile] +---- +include::Dockerfile[] +---- + +[source,yaml, indent=3, title=k8s-pod.yaml] +---- +include::k8s-pod.yaml[] +---- +endif::[] diff --git a/integration/examples/tagging-with-environment-variables/k8s-pod.yaml b/integration/examples/tagging-with-environment-variables/k8s-pod.yaml new file mode 100644 index 00000000000..846600e0a43 --- /dev/null +++ b/integration/examples/tagging-with-environment-variables/k8s-pod.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: Pod +metadata: + name: getting-started +spec: + containers: + - name: getting-started + image: gcr.io/k8s-skaffold/skaffold-example + imagePullPolicy: IfNotPresent diff --git a/integration/examples/tagging-with-environment-variables/main.go b/integration/examples/tagging-with-environment-variables/main.go new file mode 100644 index 00000000000..64b7bdfc4a1 --- /dev/null +++ b/integration/examples/tagging-with-environment-variables/main.go @@ -0,0 +1,13 @@ +package main + +import ( + "fmt" + "time" +) + +func main() { + for { + fmt.Println("Hello world!") + time.Sleep(time.Second * 1) + } +} diff --git a/integration/examples/tagging-with-environment-variables/skaffold.yaml b/integration/examples/tagging-with-environment-variables/skaffold.yaml new file mode 100644 index 00000000000..4cb86eb796b --- /dev/null +++ b/integration/examples/tagging-with-environment-variables/skaffold.yaml @@ -0,0 +1,12 @@ +apiVersion: skaffold/v1alpha3 +kind: Config +build: + artifacts: + - imageName: gcr.io/k8s-skaffold/skaffold-example + tagPolicy: + envTemplate: + template: "{{.IMAGE_NAME}}:{{.FOO}}" +deploy: + kubectl: + manifests: + - k8s-* diff --git a/integration/run_test.go b/integration/run_test.go index 50efae0f6d5..f729f788bc2 100644 --- a/integration/run_test.go +++ b/integration/run_test.go @@ -91,27 +91,27 @@ func TestRun(t *testing.T) { description: "getting-started example", args: []string{"run"}, pods: []string{"getting-started"}, - dir: "../examples/getting-started", + dir: "examples/getting-started", }, { description: "annotated getting-started example", args: []string{"run"}, filename: "annotated-skaffold.yaml", pods: []string{"getting-started"}, - dir: "../examples", + dir: "examples", }, { description: "getting-started envTagger", args: []string{"run"}, pods: []string{"getting-started"}, - dir: "../examples/tagging-with-environment-variables", + dir: "examples/tagging-with-environment-variables", env: []string{"FOO=foo"}, }, { description: "gcb builder example", args: []string{"run", "-p", "gcb"}, pods: []string{"getting-started"}, - dir: "../examples/getting-started", + dir: "examples/getting-started", remoteOnly: true, }, { @@ -126,26 +126,26 @@ func TestRun(t *testing.T) { t.Fatalf("Wrong image name in kustomized deployment: %s", d.Spec.Template.Spec.Containers[0].Image) } }, - dir: "../examples/kustomize", + dir: "examples/kustomize", }, { description: "bazel example", args: []string{"run"}, pods: []string{"bazel"}, - dir: "../examples/bazel", + dir: "examples/bazel", }, { description: "kaniko example", args: []string{"run"}, pods: []string{"getting-started-kaniko"}, - dir: "../examples/kaniko", + dir: "examples/kaniko", remoteOnly: true, }, { description: "helm example", args: []string{"run"}, deployments: []string{"skaffold-helm"}, - dir: "../examples/helm-deployment", + dir: "examples/helm-deployment", remoteOnly: true, }, } From 2a73a8e996280c02a45b585dea252e332f33aeeb Mon Sep 17 00:00:00 2001 From: Matt Rickard Date: Mon, 24 Sep 2018 11:00:39 -0700 Subject: [PATCH 3/5] [docs] add examples disclaimer for users at HEAD --- examples/README.adoc | 5 +++++ integration/examples/README.adoc | 5 +++++ integration/examples/bazel/bazel-bazel | 1 - integration/examples/bazel/bazel-bin | 1 - integration/examples/bazel/bazel-genfiles | 1 - integration/examples/bazel/bazel-out | 1 - integration/examples/bazel/bazel-testlogs | 1 - 7 files changed, 10 insertions(+), 5 deletions(-) delete mode 120000 integration/examples/bazel/bazel-bazel delete mode 120000 integration/examples/bazel/bazel-bin delete mode 120000 integration/examples/bazel/bazel-genfiles delete mode 120000 integration/examples/bazel/bazel-out delete mode 120000 integration/examples/bazel/bazel-testlogs diff --git a/examples/README.adoc b/examples/README.adoc index 5f29d60538e..e1d0057a724 100644 --- a/examples/README.adoc +++ b/examples/README.adoc @@ -2,6 +2,11 @@ :icons: font To run any of the examples, replace `k8s-project` with your GCP project ID. +These examples are made to work with the latest release of skaffold. + +If you are running skaffold at HEAD or have built it from source, please use the examples at integration/examples. + +If you wish to make changes to these examples, please edit the ones at integration/examples, as those will be synced on release. ifndef::env-github[] diff --git a/integration/examples/README.adoc b/integration/examples/README.adoc index 5f29d60538e..e1d0057a724 100644 --- a/integration/examples/README.adoc +++ b/integration/examples/README.adoc @@ -2,6 +2,11 @@ :icons: font To run any of the examples, replace `k8s-project` with your GCP project ID. +These examples are made to work with the latest release of skaffold. + +If you are running skaffold at HEAD or have built it from source, please use the examples at integration/examples. + +If you wish to make changes to these examples, please edit the ones at integration/examples, as those will be synced on release. ifndef::env-github[] diff --git a/integration/examples/bazel/bazel-bazel b/integration/examples/bazel/bazel-bazel deleted file mode 120000 index 695b14fdd87..00000000000 --- a/integration/examples/bazel/bazel-bazel +++ /dev/null @@ -1 +0,0 @@ -/private/var/tmp/_bazel_mrick/6d90e34b053448fe4d36a0feb550668e/execroot/skaffold \ No newline at end of file diff --git a/integration/examples/bazel/bazel-bin b/integration/examples/bazel/bazel-bin deleted file mode 120000 index f5fb9ee1aad..00000000000 --- a/integration/examples/bazel/bazel-bin +++ /dev/null @@ -1 +0,0 @@ -/private/var/tmp/_bazel_mrick/6d90e34b053448fe4d36a0feb550668e/execroot/skaffold/bazel-out/darwin-fastbuild/bin \ No newline at end of file diff --git a/integration/examples/bazel/bazel-genfiles b/integration/examples/bazel/bazel-genfiles deleted file mode 120000 index 7eca468d4f7..00000000000 --- a/integration/examples/bazel/bazel-genfiles +++ /dev/null @@ -1 +0,0 @@ -/private/var/tmp/_bazel_mrick/6d90e34b053448fe4d36a0feb550668e/execroot/skaffold/bazel-out/darwin-fastbuild/genfiles \ No newline at end of file diff --git a/integration/examples/bazel/bazel-out b/integration/examples/bazel/bazel-out deleted file mode 120000 index 9950c1455cb..00000000000 --- a/integration/examples/bazel/bazel-out +++ /dev/null @@ -1 +0,0 @@ -/private/var/tmp/_bazel_mrick/6d90e34b053448fe4d36a0feb550668e/execroot/skaffold/bazel-out \ No newline at end of file diff --git a/integration/examples/bazel/bazel-testlogs b/integration/examples/bazel/bazel-testlogs deleted file mode 120000 index c757be5b1a4..00000000000 --- a/integration/examples/bazel/bazel-testlogs +++ /dev/null @@ -1 +0,0 @@ -/private/var/tmp/_bazel_mrick/6d90e34b053448fe4d36a0feb550668e/execroot/skaffold/bazel-out/darwin-fastbuild/testlogs \ No newline at end of file From cc59d39e835e9c66f6b1f1c59967f3067672738e Mon Sep 17 00:00:00 2001 From: Matt Rickard Date: Mon, 24 Sep 2018 11:13:14 -0700 Subject: [PATCH 4/5] update release notes script to sync examples --- hack/release_notes/release_notes.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hack/release_notes/release_notes.sh b/hack/release_notes/release_notes.sh index f1518b2af01..3f4bf8eac49 100755 --- a/hack/release_notes/release_notes.sh +++ b/hack/release_notes/release_notes.sh @@ -12,8 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. +DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +EXAMPLES_DIR=${DIR}/../../examples +INTEGRATION_EXAMPLES_DIR=${DIR}/../../integration/examples + # you can pass your github token with --token here if you run out of requests go run hack/release_notes/listpullreqs.go +# sync files from integration examples to examples/ +rm -rf ${EXAMPLES_DIR} && rm -rf ${INTEGRATION_EXAMPLES_DIR}/bazel/bazel-* && cp -r ${INTEGRATION_EXAMPLES_DIR} ${EXAMPLES_DIR} + echo "Huge thank you for this release towards our contributors: " git log "$(git describe --abbrev=0)".. --format="%aN" --reverse | sort | uniq | awk '{printf "- %s\n", $0 }' From 83e71c97136021c00199bf6b393df56848d54113 Mon Sep 17 00:00:00 2001 From: Matt Rickard Date: Mon, 24 Sep 2018 17:43:22 -0700 Subject: [PATCH 5/5] rename release_notes.sh to release.sh --- hack/{release_notes/release_notes.sh => release.sh} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename hack/{release_notes/release_notes.sh => release.sh} (88%) diff --git a/hack/release_notes/release_notes.sh b/hack/release.sh similarity index 88% rename from hack/release_notes/release_notes.sh rename to hack/release.sh index 3f4bf8eac49..9fbe57389f3 100755 --- a/hack/release_notes/release_notes.sh +++ b/hack/release.sh @@ -13,11 +13,11 @@ # limitations under the License. DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) -EXAMPLES_DIR=${DIR}/../../examples -INTEGRATION_EXAMPLES_DIR=${DIR}/../../integration/examples +EXAMPLES_DIR=${DIR}/../examples +INTEGRATION_EXAMPLES_DIR=${DIR}/../integration/examples # you can pass your github token with --token here if you run out of requests -go run hack/release_notes/listpullreqs.go +go run ${DIR}/release_notes/listpullreqs.go # sync files from integration examples to examples/ rm -rf ${EXAMPLES_DIR} && rm -rf ${INTEGRATION_EXAMPLES_DIR}/bazel/bazel-* && cp -r ${INTEGRATION_EXAMPLES_DIR} ${EXAMPLES_DIR}