Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify custom builder example #3183

Merged
merged 1 commit into from
Nov 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 10 additions & 27 deletions integration/examples/custom/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This is a simple example based on
* *deploying* a single container pod using `kubectl`

## Before you begin

For this tutorial to work, you will need to have Skaffold and a Kubernetes cluster set up.
To learn more about how to set up Skaffold and a Kubernetes cluster, see the https://skaffold.dev/docs/getting-started[getting started docs].

Expand All @@ -27,30 +28,18 @@ $ git clone https://github.com/GoogleContainerTools/skaffold
$ cd skaffold/examples/buildpacks
```

Set the default buildpack to one that can build Go applications:

``` shell
$ pack set-default-builder heroku/buildpacks
```



Take a look at the `build.sh` file, which uses `pack` to containerize source code with buildpacks:

```shell
$ cat build.sh
#!/bin/bash
#!/usr/bin/env bash
set -e
images=$(echo $IMAGES | tr " " "\n")

for image in $images
do
pack build $image
if $PUSH_IMAGE
then
docker push $image
fi
done

pack build --builder=heroku/buildpacks $IMAGE

if $PUSH_IMAGE; then
docker push $IMAGE
fi
```

and the skaffold config, which configures artifact `gcr.io/k8s-skaffold/skaffold-example` to build with `build.sh`:
Expand All @@ -64,13 +53,6 @@ build:
- image: gcr.io/k8s-skaffold/skaffold-example
custom:
buildCommand: ./build.sh
dependencies:
paths:
- .
deploy:
kubectl:
manifests:
- k8s-*
```
For more information about how this works, see the Skaffold custom builder https://skaffold.dev/docs/how-tos/builders/#custom-build-script-run-locally[documentation].

Expand All @@ -79,13 +61,14 @@ Now, use Skaffold to deploy this application to your Kubernetes cluster:
```shell
$ skaffold run --tail --default-repo <your repo>
```

With this command, Skaffold will build the `skaffold-example` artifact with buildpacks and deploy the application to Kubernetes.
You should be able to see "Hello, World!" printed every second in the Skaffold logs.

To clean up your Kubernetes cluster, run:

```shell
$ skaffold delete --default-repo <your repo>
$ skaffold delete
```

ifndef::env-github[]
Expand Down
13 changes: 5 additions & 8 deletions integration/examples/custom/build.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
#!/bin/bash
#!/usr/bin/env bash
set -e
image=$(echo $IMAGE)

if [ ! -z "$image" ]; then
pack build $image
if $PUSH_IMAGE
then
docker push $image
fi
pack build --builder=heroku/buildpacks $IMAGE

if $PUSH_IMAGE; then
docker push $IMAGE
fi
7 changes: 0 additions & 7 deletions integration/examples/custom/skaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,3 @@ build:
- image: gcr.io/k8s-skaffold/skaffold-example
custom:
buildCommand: ./build.sh
dependencies:
paths:
- .
deploy:
kubectl:
manifests:
- k8s-*