Skip to content

Commit 03ef591

Browse files
authored
Change tekton example to use tkn (#74)
1 parent d3bfd0f commit 03ef591

File tree

4 files changed

+16
-70
lines changed

4 files changed

+16
-70
lines changed

tekton-example/README.md

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ Creation of a TaskRun (using `promote-run.yaml`) will then further promote from
1212
## Other Files
1313
- `service-promote.yaml`: This is the Tekton Task used for promoting from one repository to another. It creates a PullRequest and this represents the promotion from one environment to another (for example, from development to production - in this case represented as repositories)
1414
- `service-promote-pipeline.yaml`: Creates a pipeline that executes `build-task.yaml` and `service-promote.yaml`
15-
- `service-promote-pipeline-run.yaml`: Creates a PipelineRun that executes the `service-promote-pipeline` - This will build the code and promote it to a repository you have specified
1615
- `promote.yaml`: Creates a pull request from one repository to another repository
17-
- `promote-run.yaml`: Creates a TaskRun that executes a task promoting from a testing repository to a production repository
1816
- `build-task.yaml`: This task builds a git source into a docker image and pushes to a docker registry
1917
- `gitconfig`: Data file for the configmap - includes a GitHub user ID and email address
2018

@@ -23,7 +21,8 @@ Creation of a TaskRun (using `promote-run.yaml`) will then further promote from
2321
- You will need two repositories for this example, one to promote from and one to promote to
2422
- For the repository to promote from, an example can be forked from here: https://github.com/akihikokuroda/promote-demo
2523
- For the repository to promote to, an example can be forked from here:
26-
https://github.com/akihikokuroda/gitops-test
24+
https://github.com/rhd-gitops-example/gitops-example-dev
25+
- You will also need to have the latest release of the Tekton CLI, which can be downloaded from here: https://github.com/tektoncd/cli
2726

2827
## Create Tekton Resources
2928

@@ -42,7 +41,7 @@ kubectl config set-context --current --namespace=<namespace>
4241
kubectl apply -f resources
4342
```
4443

45-
- Edit all files in the template folder to contain real values. Entries of the form `REPLACE_ME.x` must be replaced with the value you wish to use, i.e at occurences such as `REPLACE_ME.IMAGE_NAME`, `REPLACE_ME.GITHUB_ORG/REPLACE_ME.GITHUB_REPO` etc... There are eight instances to replace in this folder.
44+
- Edit both files in the template folder to contain real values. Entries of the form `REPLACE_ME.x` must be replaced with the value you wish to use, i.e at occurences such as `REPLACE_ME.IMAGE_NAME`, `REPLACE_ME.GITHUB_ORG/REPLACE_ME.GITHUB_REPO` etc... There are eight instances to replace in this folder.
4645

4746
- Apply the templates folder:
4847
```shell
@@ -56,33 +55,28 @@ kubectl create configmap promote-configmap --from-file=gitconfig
5655
```
5756
This will store your GitHub username and email address in key-value pairs that can be used in the PipelineRun.
5857

59-
- Edit `service-promote-pipeline-run.yaml` to contain the name of the repository you want to promote to
60-
6158
## Execute Pipeline
6259

63-
`service-promote-pipeline-run` is designed to build your microservice from its development repository and then promote the new configuration to a GitOps repository (representing a different environment, for example development, staging, test or production).
60+
The PipelineRun you will create is designed to build your microservice from its development repository and then promote the new configuration to a GitOps repository (representing a different environment, for example development, staging, test or production).
6461

65-
- Create `service-promote-pipeline-run`:
62+
- To create the PipelineRun, use:
6663
```shell
67-
kubectl create -f service-promote-pipeline-run.yaml
64+
tkn pipeline start service-promote-pipeline --resource git-source=git-app-repo --resource docker-image=docker-app-image--param commitID=v1 --param github-secret=promote-secret --param github-config=promote-configmap --param to=https://github.com/<github username>/<github repo>.git --workspace name=repo-space,claimName=repopvc,subPath=dir -s demo --showlog
6865
```
6966

70-
## Promote to Prod
71-
72-
You can use `promote-run.yaml` to run a subsequent promote from one GitOps repository to another (e.g staging to prod) after merging the pull request on your first GitOps repository. For this you will need a third repository, and for this you can clone: https://github.com/a-roberts/gitops-repo-testing
67+
- This creates a PipelineRun that executes the `service-promote-pipeline`, which will build the code and promote it to a repository you have specified
68+
- The logs will be outputted to your console, and you can also view its progress in the Tekton Dashboard.
7369

74-
- Edit `promote-run.yaml` to contain the URL of the repository you want to promote from, and the URL of the repository you want to promote to
70+
## Promote to Next Managed Environment
7571

76-
- Create the `promote-run` TaskRun:
77-
```shell
78-
kubectl create -f promote-run.yaml
79-
```
72+
Optionally, you can run a subsequent promote from one GitOps repository to another (e.g staging to prod) after merging the pull request on your first GitOps repository. For this you will need a third repository, and for this you can fork: https://github.com/rhd-gitops-example/gitops-example-staging
8073

81-
You can view the progress of your PipelineRun using:
74+
- To do this second promote, you will need to create a TaskRun that executes a task promoting from a testing repository to a production repository
75+
- To create the TaskRun, use:
8276
```shell
83-
kubectl get pod <name of pod>
77+
tkn task start promote --param github-secret=promote-secret--param from=https://github.com/<github username>/<github repo> --param from=https://github.com/<github username>/<github repo>.git --param github-config=promote-configmap --param service=service-a -s demo --showlog
8478
```
85-
Or alternatively view its progress in the Tekton Dashboard.
79+
This will start the TaskRun and output its logs, and you can also view its progress in the Tekton Dashboard.
8680

87-
The PipelineRun will clone the code from the inital repository locally, build it and promote it to the final repository. This will open a pull request which you will be able to view in the repository you chose to promote to.
81+
The TaskRun will clone the code from the initial repository locally, build it and promote it to the final repository. This will open a pull request which you will be able to view in the repository you chose to promote to.
8882

tekton-example/promote-run.yaml

Lines changed: 0 additions & 18 deletions
This file was deleted.

tekton-example/service-promote-pipeline-run.yaml

Lines changed: 0 additions & 30 deletions
This file was deleted.

tekton-example/templates/resources.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ metadata:
1919
spec:
2020
params:
2121
- name: url
22-
value: REPLACE_ME.DOCKER_IMAGE_NAME
22+
value: REPLACE_ME.DOCKER_USERNAME/REPLACE_ME.DOCKER_IMAGE_NAME
2323
type: image
2424

2525
---

0 commit comments

Comments
 (0)