-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds script to create a release using Tekton
This adds a bash script to deploy new version of hub on a cluster using Tekton Pipelines. This will create a git tag push it to tektoncd/hub and install and run pipelines for hub which will push images to quay.io/tekton-hub. Signed-off-by: Shivam Mukhade <[email protected]>
- Loading branch information
SM43
committed
May 17, 2021
1 parent
3da81da
commit 0a1bc05
Showing
23 changed files
with
864 additions
and
18 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 |
---|---|---|
|
@@ -16,7 +16,6 @@ apiVersion: v1 | |
kind: Secret | ||
metadata: | ||
name: db | ||
namespace: tekton-hub | ||
labels: | ||
app: db | ||
type: Opaque | ||
|
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
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 |
---|---|---|
|
@@ -16,7 +16,6 @@ apiVersion: apps/v1 | |
kind: Deployment | ||
metadata: | ||
name: db | ||
namespace: tekton-hub | ||
labels: | ||
app: db | ||
spec: | ||
|
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 |
---|---|---|
|
@@ -16,7 +16,6 @@ apiVersion: v1 | |
kind: Service | ||
metadata: | ||
name: db | ||
namespace: tekton-hub | ||
labels: | ||
app: db | ||
spec: | ||
|
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
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
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 |
---|---|---|
|
@@ -16,7 +16,6 @@ apiVersion: v1 | |
kind: ConfigMap | ||
metadata: | ||
name: api | ||
namespace: tekton-hub | ||
labels: | ||
app: api | ||
data: | ||
|
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
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 |
---|---|---|
|
@@ -17,7 +17,6 @@ apiVersion: v1 | |
kind: Service | ||
metadata: | ||
name: api | ||
namespace: tekton-hub | ||
labels: | ||
app: api | ||
spec: | ||
|
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
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 |
---|---|---|
|
@@ -3,7 +3,6 @@ apiVersion: apps/v1 | |
kind: Deployment | ||
metadata: | ||
name: ui | ||
namespace: tekton-hub | ||
labels: | ||
app: ui | ||
spec: | ||
|
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 |
---|---|---|
|
@@ -3,7 +3,6 @@ apiVersion: v1 | |
kind: Service | ||
metadata: | ||
name: ui | ||
namespace: tekton-hub | ||
labels: | ||
app: ui | ||
spec: | ||
|
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
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
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
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
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
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
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,45 @@ | ||
# Release Script | ||
|
||
The Release script does the following tasks: | ||
- fetch the latest main branch | ||
- create and push a git tag by version provided from the user | ||
- create supporting configuration for hub on the cluster | ||
- create secret and roles for the Tekton Pipelines | ||
- install the pipeline which will deploy the hub on the clusters | ||
|
||
## Prerequisites | ||
|
||
- Kubernetes or OpenShift cluster with Tekton Pipelines installed | ||
- kubectl CLI | ||
- git CLI | ||
|
||
### User Prerequisites | ||
|
||
- Access to push images to `quay.io/tekton-hub` | ||
- Access to push git tag to `tektoncd/hub` | ||
|
||
## Before Running the Script | ||
|
||
- Enable Tekton Bundle in Pipelines | ||
- Check the last hub release version [here](https://github.com/tektoncd/hub/releases) and enter the next in the script to | ||
- If you are deploying hub on a clean cluster | ||
- You will need GitHub OAuth. You can create one using the steps given [here](https://docs.github.com/en/developers/apps/creating-an-oauth-app). Use any url for creating OAuth, later you can change it once hub is deployed. | ||
|
||
|
||
## Running the Script | ||
|
||
This will deploy the hub in `tekton-hub` namespace and run the Tekton pipelines for it in the `tekton-hub-ci` namespace. | ||
|
||
Input asked by the script: | ||
- Target Release Version: This is the tag to be created and pushed to the repository. Check the last tag created and enter the next verion. | ||
- Deploying on Openshift? Enter (Y or n) depending on your cluster. If OpenShift is selected, it will configure adm policy for the service account. | ||
- If there are not existing hub configuration in `tekton-hub` namespace, the script will ask for | ||
- Database Configuration: Enter Database name, user and password for the db to be created | ||
- GitHub OAuth Configuration: Enter the OAuth Configuration you have created. | ||
- JWT Signing key: Enter any random key which will be used to sign User JWTs. | ||
- Access and Refresh Expire Time: Enter the time the token should be expired in. Refresh Expire time must be greater than Access Expire time. You can input time as `1d` = 1 day, `15h` = 15 hours, `30m` = 30 minutes. | ||
- Hub Config Raw URL: No need to change it unless you are not deploying hub from tektoncd/hub. | ||
NOTE: If you have already hub instance in tekton-hub namespace and the above configuration are already created using secrets and config maps, then the above step will be skipped. | ||
- Quay registry credentials: Enter your credentials to push images to the registry | ||
|
||
Once, that is done,the script will create all configuration and then install the pipeline and resources requires by it. And start the Pipeline. |
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,95 @@ | ||
# Copyright © 2021 The Tekton Authors. | ||
# | ||
# 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. | ||
|
||
apiVersion: tekton.dev/v1beta1 | ||
kind: Task | ||
metadata: | ||
name: golang-db-test | ||
labels: | ||
app.kubernetes.io/version: "0.1" | ||
annotations: | ||
tekton.dev/pipelines.minVersion: "0.12.1" | ||
tekton.dev/tags: test | ||
tekton.dev/displayName: "golang test" | ||
spec: | ||
description: >- | ||
This Task is Golang task to test Go projects. | ||
params: | ||
- name: package | ||
description: package (and its children) under test | ||
- name: packages | ||
description: "packages to test (default: ./...)" | ||
default: "./..." | ||
- name: path_context | ||
description: path to the directory to use as context. | ||
default: "." | ||
- name: version | ||
description: golang version to use for tests | ||
default: "latest" | ||
- name: flags | ||
description: flags to use for the test command | ||
default: -race -cover -v | ||
- name: GOOS | ||
description: "running program's operating system target" | ||
default: linux | ||
- name: GOARCH | ||
description: "running program's architecture target" | ||
default: amd64 | ||
- name: GO111MODULE | ||
description: "value of module support" | ||
default: auto | ||
workspaces: | ||
- name: source | ||
steps: | ||
- name: unit-test | ||
image: docker.io/library/golang:$(params.version) | ||
script: | | ||
SRC_PATH="$GOPATH/src/$(params.package)/$(params.path_context)" | ||
mkdir -p $SRC_PATH | ||
cp -R "$(workspaces.source.path)"/"$(params.path_context)"/* $SRC_PATH | ||
cd $SRC_PATH | ||
go test $(params.flags) $(params.packages) | ||
env: | ||
- name: GOOS | ||
value: "$(params.GOOS)" | ||
- name: GOARCH | ||
value: "$(params.GOARCH)" | ||
- name: GO111MODULE | ||
value: "$(params.GO111MODULE)" | ||
- name: POSTGRES_HOST | ||
value: localhost | ||
- name: POSTGRES_DB | ||
value: hub_test | ||
- name: POSTGRES_USER | ||
value: postgres | ||
- name: POSTGRES_PASSWORD | ||
value: postgres | ||
- name: POSTGRES_PORT | ||
value: "5432" | ||
sidecars: | ||
- image: postgres:12@sha256:8f10c40e5e687b2cbf2f28acb5192049cdb89ef1a8db44d2f21e6bdd1a36e4be | ||
name: db | ||
ports: | ||
- containerPort: 5432 | ||
protocol: TCP | ||
env: | ||
- name: POSTGRES_DB | ||
value: hub_test | ||
- name: POSTGRES_USER | ||
value: postgres | ||
- name: POSTGRES_PASSWORD | ||
value: postgres | ||
- name: PGDATA | ||
value: /var/lib/postgresql/data/pgdata |
Oops, something went wrong.