forked from GoogleCloudPlatform/click-to-deploy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split GCB triggers for Kubernetes applications (GoogleCloudPlatform#535)
- Loading branch information
Showing
26 changed files
with
990 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
.build/ | ||
*.pyc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
matrix: | ||
include: | ||
- language: python | ||
python: 2.7 | ||
install: pip install jinja2 | ||
script: ./cloudbuild-k8s-generator.py --verify_only | ||
env: TARGET=python-test | ||
- language: ruby | ||
install: gem install foodcritic | ||
script: | ||
- foodcritic --version | ||
- foodcritic --cookbook-path=vm/chef/cookbooks --rule-file=vm/chef/.foodcritic --epic-fai=any | ||
env: TARGET=vm-lint | ||
|
||
script: make "${TARGET}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright 2019 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# TODO(wgrzelak): Invoke targets into the container. | ||
|
||
python-test: | ||
@python --version | ||
@python -m unittest discover -s scripts -p "*_test.py" | ||
|
||
vm-lint: | ||
@foodcritic --version | ||
@foodcritic --cookbook-path=vm/chef/cookbooks --rule-file=vm/chef/.foodcritic --epic-fail=any |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,41 @@ | ||
# About | ||
|
||
Source for Google Click to Deploy solutions listed on | ||
Google Cloud Marketplace. | ||
Source for Google Click to Deploy solutions listed on Google Cloud Marketplace. | ||
|
||
# Disclaimer | ||
|
||
This is not an officially supported Google product. | ||
|
||
# Cloud Build CI | ||
|
||
This repository uses Cloud Build for continuous integration. The Cloud Build configuration file is located at [`cloudbuild.yaml`](cloudbuild.yaml). | ||
This repository uses Cloud Build for continuous integration. The Cloud Build | ||
configuration file is located at [`cloudbuild-k8s.yaml`](cloudbuild-k8s.yaml) | ||
for Kubernetes applications and [`cloudbuild-vm.yaml`](cloudbuild-vm.yaml) for | ||
[VM applications](vm/README.md#cloud-build-ci). | ||
|
||
## Manually run the build | ||
## Manually run the build for K8s applications | ||
|
||
Cloud Build can be triggered manually by running the following command | ||
from the root directory of this repository: | ||
Cloud Build can be triggered manually. Run the following command from the root | ||
directory of this repository: | ||
|
||
```shell | ||
export GCP_PROJECT_TO_RUN_CLOUD_BUILD=<> | ||
export GKE_CLUSTER_NAME=<> | ||
export GKE_CLUSTER_LOCATION=<e.g. us-central1> | ||
export SOLUTION_NAME=<e.g. wordpress> | ||
|
||
gcloud builds submit . \ | ||
--config cloudbuild.yaml \ | ||
--substitutions _CLUSTER_NAME=$GKE_CLUSTER_NAME,_CLUSTER_LOCATION=$GKE_CLUSTER_LOCATION \ | ||
--config cloudbuild-k8s.yaml \ | ||
--substitutions _CLUSTER_NAME=$GKE_CLUSTER_NAME,_CLUSTER_LOCATION=$GKE_CLUSTER_LOCATION,_SOLUTION_NAME=$SOLUTION_NAME \ | ||
--project $GCP_PROJECT_TO_RUN_CLOUD_BUILD \ | ||
--verbosity info | ||
``` | ||
|
||
## Cloud Build configuration generator | ||
### Build steps | ||
|
||
To make the `cloudbuild.yaml` configuration easier to maintain, a generator for | ||
its contents was created. | ||
|
||
1. The generator uses Jinja2 templates, install it using `pip install jinja2` | ||
command. | ||
1. To regenerate the file, run the following command: | ||
|
||
```shell | ||
./cloudbuild-k8s-generator.py | ||
``` | ||
|
||
1. As a result, new content will be saved in the `cloudbuild.yaml` file. | ||
1. Build `click-to-deploy` Docker image. The image contains the necessary tools | ||
required by the CI pipeline. | ||
1. Generate Cloud Build configuration for an application defined in | ||
`$_SOLUTION_NAME` variable. The configuration contains all required steps to | ||
test the application. | ||
1. Run additional Cloud Build instance using the generated configuration. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Copyright 2019 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
timeout: 1800s # 30m | ||
steps: | ||
|
||
- id: Build C2D Docker Image | ||
name: gcr.io/cloud-builders/docker | ||
args: | ||
- build | ||
- --tag | ||
- click-to-deploy | ||
- --file | ||
- k8s.Dockerfile | ||
- . | ||
|
||
- id: Run Cloud Build K8s Generator | ||
name: click-to-deploy | ||
entrypoint: python | ||
args: | ||
- scripts/cloudbuild_k8s_generator.py | ||
- --solution | ||
- $_SOLUTION_NAME | ||
- --output | ||
- k8s/$_SOLUTION_NAME/cloudbuild.yaml | ||
|
||
- id: Test Solution | ||
name: gcr.io/cloud-builders/gcloud | ||
args: | ||
- builds | ||
- submit | ||
- --config | ||
- k8s/$_SOLUTION_NAME/cloudbuild.yaml | ||
- --substitutions | ||
- _CLUSTER_NAME=$_CLUSTER_NAME,_CLUSTER_LOCATION=$_CLUSTER_LOCATION | ||
- . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Copyright 2019 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
FROM gcr.io/google-appengine/debian9:latest | ||
|
||
RUN set -eux \ | ||
&& apt-get update \ | ||
&& apt-get install python-pip -y \ | ||
&& pip install jinja2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.