Skip to content

Instantly share code, notes, and snippets.

@timosalm
Last active April 9, 2020 07:09
Show Gist options
  • Save timosalm/14f2eeb2372e4fd2ddf966f8ab0dcfe8 to your computer and use it in GitHub Desktop.
Save timosalm/14f2eeb2372e4fd2ddf966f8ab0dcfe8 to your computer and use it in GitHub Desktop.
Introduction to Pivotal Build Service

Prerequisites

  1. Download and install the pb CLI from Pivotal Network https://network.pivotal.io/products/build-service
mv pb-0.1.0-darwin pb
chmod +x pb
sudo mv pb /usr/local/bin
  1. To get access you will need to get kubeconfig access to the cluster where PBS is running. You can do this most easily with the pks cli:
pks get-kubeconfig production -a <build-service-api> -u <YOUR_USERNAME> -p <YOUR_PASSWORD> -k
  1. Create a project
pb project create sample-project
  1. Set the project as a target
pb project target sample-project
  1. Create a registry-secret.yaml file with your push credentials for the docker registry based on the 2-registry-secret.yaml file below and and apply
pb secrets registry apply -f registry-secret.yaml
  1. Create a repository-secret.yaml file with your credentials for the git repository based on the 3-repository-secret.yaml file below and and apply
pb secrets git apply -f repository-secret.yaml
  1. Fork the sample repository https://github.com/buildpack/sample-java-app to test the automatic rebuild functionality

  2. Create a PBS image configuration file (image.yaml) with your forked repository based on the 4-image.yaml file below and apply

pb image apply -f image.yaml
  1. View all builds for the image and wait until the status is SUCCESS
pb image builds index.docker.io/<docker-registry-username>/pbs-sample-java-app:latest 

(Optional) View logs from the first build for the image:

pb image logs index.docker.io/<docker-registry-username>/pbs-sample-java-app:latest -b 1
  1. Push any update to the forked sample app repository. Pivotal Build Service should recognize the update and automatically rebuild your image.

You can see this for example by viewing the builds(step #11)

  1. Run the latest image of the app locally with docker
docker run -p 8080:8080 <docker-registry-username>/pbs-sample-java-app
  1. Open localhost:8080 in your favorite browser

  2. Delete project and all associated resources

pb image delete index.docker.io/<docker-registry-username>/pbs-sample-java-app:latest
pb project delete sample-project
registry: index.docker.io
username: <docker-registry-username>
password: <docker-registry-password>
repository: https://github.com/<github-username>/
username: <github-username>
password: <github-username> or <github-accesss-token>
source:
git:
url: https://github.com/<github-username>/sample-java-app
revision: master
image:
tag: <docker-registry-username>/pbs-sample-java-app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment