├── .gitignore ├── .gitmodules ├── .workshop ├── build ├── jupyterhub_config.py ├── settings.sh ├── setup └── templates │ ├── clusterroles-session-rules.yaml │ ├── clusterroles-spawner-rules.yaml │ └── configmap-session-resources.yaml ├── Dockerfile ├── LICENSE ├── README.md ├── code ├── operator │ └── subscription.yaml ├── pipeline │ └── pipeline.yaml ├── resources │ └── persistent_volume_claim.yaml └── tasks │ ├── apply_manifest_task.yaml │ ├── hello.yaml │ └── update_deployment_task.yaml ├── docs ├── homeroom.png ├── jupyter-login.png ├── starting-up.png ├── workshop-console.png └── workshop-terminal.png └── workshop ├── content ├── 01install-op.adoc ├── 02serviceaccount.adoc ├── 03create-task.adoc ├── 04task-resource-def.adoc ├── 05create-pipeline.adoc ├── 06trigger-pipeline.adoc ├── 07verify-deployment.adoc ├── finish.adoc ├── images │ ├── application-deployed.png │ ├── console-import-yaml-1.png │ ├── console-import-yaml-2.png │ ├── copy-icon.png │ ├── deploy-pipeline-console.png │ ├── developer-view.png │ ├── explore-perspective-toggle.png │ ├── explore-topology-view.png │ ├── explore-webconsole1sc.png │ ├── explore-webconsole2.png │ ├── import-yaml.png │ ├── operator-install-1.png │ ├── operator-install-2.png │ ├── operator-install-3.png │ ├── operatorhub.png │ ├── pipeline-diagram.png │ ├── pipeline-overview.png │ ├── pipeline-resources-console.png │ ├── pipeline-run-progress.png │ ├── pipeline-visual.png │ ├── pipelinerun-logs-tab.png │ ├── pipelinerun-logs.png │ ├── pipelineruns-filters.png │ ├── pipelineruns-tab.png │ ├── request-information.png │ ├── task-logs.png │ ├── task-visual.png │ ├── tekton-architecture.svg │ ├── topology-view-deployed.png │ ├── topology-view.png │ ├── url-icon.png │ ├── web-console-developer.png │ ├── web-console-hub.png │ ├── web-console-login.png │ ├── web-console-logs-success.png │ ├── web-console-options.png │ ├── web-console-pr.png │ ├── web-console-project.png │ ├── web-console-settings.png │ └── web-console-tasks.png └── intro.adoc ├── modules.yaml └── workshop.yaml /.gitignore: -------------------------------------------------------------------------------- 1 | .kube 2 | .config 3 | .bash_history 4 | *.swp 5 | .DS_Store 6 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule ".workshop/scripts"] 2 | path = .workshop/scripts 3 | url = https://github.com/openshift-homeroom/spawner-scripts.git 4 | branch = stable/2.x 5 | -------------------------------------------------------------------------------- /.workshop/build: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This 'build' script is where you can add steps that should be run when 4 | # building the image for your custom workshop. 5 | 6 | # Move the workshop content to '/opt/app-root/workshop'. It could be left 7 | # at it's default location of '/opt/app-root/src/workshop', but by moving it, 8 | # it is out of view of the user doing the workshop and they aren't likely to 9 | # delete it by accident and break the display of the workshop content. 10 | 11 | mv workshop /opt/app-root/workshop 12 | 13 | # Also delete some of the other files from the top of the Git repository we 14 | # don't need for running the workshop. 15 | 16 | rm -f Dockerfile README.md LICENSE 17 | 18 | mv -f code/* . && rmdir code 19 | 20 | mkdir -p .bin && echo "export PATH=$HOME/.bin:$PATH" >> .bash_profile 21 | 22 | # Releases for Tekton CLI at: https://github.com/tektoncd/cli/releases 23 | TKN_CLI_VERSION=0.17.2 24 | curl -kL https://github.com/tektoncd/cli/releases/download/v${TKN_CLI_VERSION}/tkn_${TKN_CLI_VERSION}_Linux_x86_64.tar.gz -o /tmp/tkn.tar.gz && \ 25 | tar -xvzf /tmp/tkn.tar.gz -C /tmp && \ 26 | chmod 755 /tmp/tkn && \ 27 | mv /tmp/tkn .bin 28 | -------------------------------------------------------------------------------- /.workshop/jupyterhub_config.py: -------------------------------------------------------------------------------- 1 | os.environ["OPENSHIFT_PROJECT"] = "{username}" -------------------------------------------------------------------------------- /.workshop/settings.sh: -------------------------------------------------------------------------------- 1 | WORKSHOP_NAME=lab-tekton-pipelines 2 | WORKSHOP_IMAGE=quay.io/openshiftlabs/lab-tekton-pipelines:4.8 3 | WORKSHOP_TITLE="OpenShift Pipelines with Tekton" 4 | WORKSHOP_DESCRIPTION="Developing applications using OpenShift pipelines" 5 | CONSOLE_IMAGE=quay.io/openshift/origin-console:4.8 6 | RESOURCE_BUDGET=custom 7 | MAX_SESSION_AGE=7200 8 | IDLE_TIMEOUT=300 9 | SERVER_LIMIT=50 10 | SPAWNER_MODE=terminal-server 11 | OPENSHIFT_PROJECT="{username}" 12 | -------------------------------------------------------------------------------- /.workshop/setup: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This 'setup' script is where you can add steps that should be run each 4 | # time the container for the workshop is started. Note that if you are 5 | # using persistent storage with a workshop and make changes to files from 6 | # this script, or are deploying applications, your scripts must cope with 7 | # the steps having already been run. This is because this script will be 8 | # run a second time if the container were restarted for some reason. 9 | -------------------------------------------------------------------------------- /.workshop/templates/clusterroles-session-rules.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: template.openshift.io/v1 2 | kind: Template 3 | metadata: 4 | name: clusterroles-session-rules 5 | parameters: 6 | - name: NAME_PREFIX 7 | value: "" 8 | required: false 9 | - name: WORKSHOP_NAME 10 | value: "" 11 | required: true 12 | - name: SPAWNER_NAMESPACE 13 | value: "" 14 | required: true 15 | - name: SPAWNER_MODE 16 | value: "learning-portal" 17 | required: true 18 | objects: 19 | - apiVersion: authorization.openshift.io/v1 20 | kind: ClusterRole 21 | metadata: 22 | name: ${NAME_PREFIX}${WORKSHOP_NAME}-session-rules 23 | labels: 24 | app: ${NAME_PREFIX}${WORKSHOP_NAME} 25 | spawner: ${SPAWNER_MODE} 26 | class: spawner 27 | rules: 28 | - apiGroups: 29 | - "tekton.dev" 30 | resources: 31 | - clustertasks 32 | - pipelineresources 33 | - pipelines 34 | - pipelineruns 35 | - tasks 36 | - taskruns 37 | verbs: 38 | - get 39 | - list 40 | - watch 41 | - create 42 | - delete 43 | - patch 44 | - update 45 | - apiGroups: 46 | - "operator.tekton.dev" 47 | resources: 48 | - config 49 | verbs: 50 | - get 51 | - list 52 | - watch 53 | - create 54 | - delete 55 | - patch 56 | - update 57 | - apiGroups: 58 | - "" 59 | - security.openshift.io 60 | resources: 61 | - securitycontextconstraints 62 | verbs: 63 | - create 64 | - delete 65 | - deletecollection 66 | - get 67 | - list 68 | - patch 69 | - update 70 | - watch 71 | -------------------------------------------------------------------------------- /.workshop/templates/clusterroles-spawner-rules.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: template.openshift.io/v1 2 | kind: Template 3 | metadata: 4 | name: clusterroles-spawner-rules 5 | parameters: 6 | - name: NAME_PREFIX 7 | value: "" 8 | required: false 9 | - name: WORKSHOP_NAME 10 | value: "" 11 | required: true 12 | - name: SPAWNER_NAMESPACE 13 | value: "" 14 | required: true 15 | - name: SPAWNER_MODE 16 | value: "learning-portal" 17 | required: true 18 | objects: 19 | - apiVersion: authorization.openshift.io/v1 20 | kind: ClusterRole 21 | metadata: 22 | name: ${NAME_PREFIX}${WORKSHOP_NAME}-spawner-rules 23 | labels: 24 | app: ${NAME_PREFIX}${WORKSHOP_NAME} 25 | spawner: ${SPAWNER_MODE} 26 | class: spawner 27 | rules: 28 | - apiGroups: 29 | - "" 30 | - authorization.openshift.io 31 | - rbac.authorization.k8s.io 32 | resourceNames: 33 | - config.operator.tekton.dev-v1alpha1-admin 34 | - config.operator.tekton.dev-v1alpha1-crdview 35 | - config.operator.tekton.dev-v1alpha1-edit 36 | - config.operator.tekton.dev-v1alpha1-view 37 | - tekton-aggregate-edit 38 | - tekton-aggregate-view 39 | - tekton-aggregate-admin 40 | resources: 41 | - clusterroles 42 | verbs: 43 | - bind 44 | - apiGroups: 45 | - "" 46 | - authorization.openshift.io 47 | - rbac.authorization.k8s.io 48 | resources: 49 | - clusterroles 50 | verbs: 51 | - get 52 | - list 53 | - watch 54 | - create 55 | - delete 56 | - patch 57 | - update 58 | - apiGroups: 59 | - security.openshift.io 60 | resources: 61 | - securitycontextconstraints 62 | verbs: 63 | - use 64 | resourceNames: 65 | - privileged 66 | - apiGroups: 67 | - "" 68 | - extensions 69 | resources: 70 | - deployments 71 | verbs: 72 | - get 73 | -------------------------------------------------------------------------------- /.workshop/templates/configmap-session-resources.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: template.openshift.io/v1 2 | kind: Template 3 | metadata: 4 | name: configmap-session-resources 5 | parameters: 6 | - name: NAME_PREFIX 7 | value: "" 8 | required: false 9 | - name: WORKSHOP_NAME 10 | value: "" 11 | required: true 12 | - name: SPAWNER_NAMESPACE 13 | value: "" 14 | required: true 15 | - name: SPAWNER_MODE 16 | value: "learning-portal" 17 | required: true 18 | objects: 19 | - apiVersion: v1 20 | kind: ConfigMap 21 | metadata: 22 | name: ${NAME_PREFIX}${WORKSHOP_NAME}-session-resources 23 | labels: 24 | app: ${NAME_PREFIX}${WORKSHOP_NAME} 25 | spawner: ${SPAWNER_MODE} 26 | class: spawner 27 | data: 28 | extra_resources.yaml: |- 29 | kind: List 30 | apiVersion: v1 31 | items: 32 | - kind: ServiceAccount 33 | apiVersion: v1 34 | metadata: 35 | name: pipeline 36 | - kind: ClusterRole 37 | apiVersion: rbac.authorization.k8s.io/v1 38 | metadata: 39 | name: ${project_namespace}-pipelines 40 | rules: 41 | - apiGroups: 42 | - security.openshift.io 43 | resources: 44 | - securitycontextconstraints 45 | verbs: 46 | - use 47 | resourceNames: 48 | - privileged 49 | - kind: RoleBinding 50 | apiVersion: rbac.authorization.k8s.io/v1 51 | metadata: 52 | name: pipelines-privileged-scc 53 | subjects: 54 | - kind: ServiceAccount 55 | name: pipeline 56 | namespace: "${project_namespace}" 57 | roleRef: 58 | kind: ClusterRole 59 | apiGroup: rbac.authorization.k8s.io 60 | name: ${project_namespace}-pipelines 61 | - kind: RoleBinding 62 | apiVersion: rbac.authorization.k8s.io/v1 63 | metadata: 64 | name: pipelines-project-edit 65 | subjects: 66 | - kind: ServiceAccount 67 | name: pipeline 68 | namespace: "${project_namespace}" 69 | roleRef: 70 | kind: ClusterRole 71 | apiGroup: rbac.authorization.k8s.io 72 | name: edit 73 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM quay.io/openshifthomeroom/workshop-dashboard:5.0.1 2 | 3 | USER root 4 | 5 | COPY . /tmp/src 6 | 7 | RUN rm -rf /tmp/src/.git* && \ 8 | chown -R 1001 /tmp/src && \ 9 | chgrp -R 0 /tmp/src && \ 10 | chmod -R g+w /tmp/src 11 | 12 | ENV TERMINAL_TAB=split 13 | 14 | USER 1001 15 | 16 | RUN /usr/libexec/s2i/assemble 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Lab - OpenShift Pipelines with Tekton 2 | 3 | * [Overview](#overview) 4 | * [Deploying the Workshop](#deploying-the-workshop) 5 | * [Deploying on Red Hat Product Demo System](#deploying-on-red-hat-product-demo-system) 6 | * [Deploying to OpenShift](#deploying-to-openshift) 7 | * [Running the Workshop](#running-the-workshop) 8 | * [Deleting the Workshop](#deleting-the-workshop) 9 | * [Development](#development) 10 | 11 | ## Overview 12 | 13 | This workshop provides an introduction to OpenShift Pipelines with Tekton. 14 | Please check [releases](https://github.com/openshift-labs/lab-tekton-pipelines/releases) 15 | for the latest version of the workshop and also make sure to note if a version 16 | released has been deprecated. 17 | 18 | | | | 19 | --- | --- 20 | | Audience Experience Level | Intermediate | 21 | | Supported Number of Users | One per cluster [1] | 22 | | Average Time to Complete | 30 minutes | 23 | 24 | The workshop uses the HomeRoom workshop environment in the learning portal configuration. 25 | You will need to be a cluster admin in order to deploy it. 26 | 27 | When the URL for the workshop environment is accessed, a workshop session will be created on demand. 28 | 29 | ## Deploying the Workshop 30 | 31 | 32 | 33 | ### Deploying on Red Hat Product Demo System 34 | 35 | The workshop is found in the catalog under the *Workshops* folder and is named *OCP4 Pipelines Workshop*. 36 | 37 | Once the cluster is deployed, follow the directions in the next section to begin the workshop itself. 38 | 39 | 40 | #### Deploying on RHPDS with AgnosticD 41 | 42 | Login to the RHPDS cluster. 43 | 44 | ```bash 45 | oc login ... 46 | ``` 47 | 48 | Clone [AgnosticD](https://github.com/redhat-cop/agnosticd): 49 | 50 | ```bash 51 | git clone https://github.com/redhat-cop/agnosticd 52 | ``` 53 | 54 | Install dependencies such as Python headers (Python.h), on Fedora: 55 | 56 | ```bash 57 | sudo dnf install python3-dev 58 | ``` 59 | 60 | Setup Virtual Env: 61 | 62 | ```bash 63 | cd agnosticd/ansible 64 | python3 -mvenv ~/virtualenv/ansible2.9-python3.6-2021-01-22 65 | . ~/virtualenv/ansible2.9-python3.6-2021-01-22/bin/activate 66 | pip install -r https://raw.githubusercontent.com/redhat-cop/agnosticd/development/tools/virtualenvs/ansible2.9-python3.6-2021-01-22.txt 67 | ``` 68 | 69 | Run the playbooks: 70 | 71 | ```bash 72 | OCP_USERNAME="opentlc-mgr" 73 | GUID=sampleuser 74 | WORKSHOP_PROJECT="labs" 75 | WORKLOAD="ocp4-workload-homeroomlab-tekton-pipelines" 76 | TARGET_HOST=localhost 77 | 78 | ansible-playbook -c local -i ${TARGET_HOST}, configs/ocp-workloads/ocp-workload.yml \ 79 | -e ansible_python_interpreter=python \ 80 | -e ocp_workload=${WORKLOAD} \ 81 | -e guid=${GUID} \ 82 | -e project_name=${WORKSHOP_PROJECT} \ 83 | -e ocp_username=${OCP_USERNAME} \ 84 | -e ACTION="create" \ 85 | --extra-vars '{"num_users": 5}' 86 | ``` 87 | 88 | Access `labs` project and click to the Homeroom route. 89 | 90 | 91 | ### Deploying to OpenShift 92 | 93 | WARNING: Homeroom is EOL and not supported outside RHPDS. 94 | 95 | To deploy the workshop, first clone this Git repository to your own machine. Use the command: 96 | 97 | ``` 98 | git clone --recurse-submodules --branch 1.0 https://github.com/openshift-labs/lab-tekton-pipelines.git 99 | ``` 100 | 101 | The ``--recurse-submodules`` option ensures that Git submodules are checked out. If you forget to use this option, after having clone the repository, run: 102 | 103 | ``` 104 | git submodule update --recursive --remote 105 | ``` 106 | 107 | Next create a project in OpenShift into which the workshop is to be deployed. 108 | 109 | ``` 110 | oc new-project workshops 111 | ``` 112 | 113 | From within the top level of the Git repository, now run the command below. 114 | 115 | ``` 116 | .workshop/scripts/deploy-spawner.sh 117 | ``` 118 | 119 | The name of the pod used to start the workshop will be ``lab-tekton-pipelines-spawner``. 120 | 121 | ## Running the Workshop 122 | 123 | Access homeroom URL: 124 | 125 | ![Workshop Login](/docs/homeroom.png) 126 | 127 | Users will enter the following information: 128 | 129 | | Key | Value | 130 | | --- | ----- | 131 | | Username | userX (e.g. user1) | 132 | | Password | ``openshift`` | 133 | 134 | After logging in, the workshop takes a few seconds to start: 135 | 136 | ![Workshop Startup](/docs/starting-up.png) 137 | 138 | Once the workshop begins, users are presented with a two panel interface: 139 | 140 | ![Workshop Terminal](/docs/workshop-terminal.png) 141 | 142 | On the left are the instructions users will follow for the workshop. The workshop itself explains how to use the interface, but generally speaking users will follow the directions on the left, with navigation buttons appearing at the end of each section. Text that is highlighted with a yellow background may be clicked to have the operation automatically executed in the cluster on the right. 143 | 144 | By default, users are presented with the terminal, which contains (among other things) an authenticated ``oc`` client. 145 | 146 | 147 | 148 | ## Deleting the Workshop 149 | 150 | WARNING: Homeroom is EOL and not supported outside RHPDS. 151 | 152 | 153 | To delete the spawner and any active sessions, including projects, run: 154 | 155 | ``` 156 | ./.workshop/scripts/delete-spawner.sh 157 | ``` 158 | 159 | To delete the build configuration for the workshop image, run: 160 | 161 | ``` 162 | ./.workshop/scripts/delete-workshop.sh 163 | ``` 164 | 165 | To delete any global resources which may have been created, run: 166 | 167 | ``` 168 | ./.workshop/scripts/delete-resources.sh 169 | ``` 170 | 171 | ## Development 172 | 173 | WARNING: Homeroom is EOL and not supported outside RHPDS. 174 | 175 | 176 | The deployment created above will use an image from ``quay.io`` for this workshop based on the ``master`` branch of the repository. 177 | 178 | To make changes to the workshop content and test them, edit the files in the Git repository and then run: 179 | 180 | ``` 181 | ./.workshop/scripts/build-workshop.sh 182 | ``` 183 | 184 | This will replace the existing image used by the active deployment. 185 | 186 | If you are running an existing instance of the workshop, if you want to start over with a fresh project, first delete the project used for the session. 187 | 188 | ``` 189 | oc delete project $PROJECT_NAMESPACE 190 | ``` 191 | 192 | Then select "Restart Workshop" from the menu top right of the workshop environment dashboard. 193 | 194 | When you are happy with your changes, push them back to the remote Git repository. 195 | 196 | If you need to change the RBAC definitions, or what resources are created when a project is created, change the definitions in the ``templates`` directory. You can then re-run: 197 | 198 | ``` 199 | ./.workshop/scripts/deploy-spawner.sh 200 | ``` 201 | 202 | and it will update the active definitions. 203 | 204 | Note that if you do this, you will need to re-run: 205 | 206 | ``` 207 | ./.workshop/scripts/build-workshop.sh 208 | ``` 209 | 210 | to have any local content changes be used once again as it will revert back to using the image on ``quay.io``. 211 | -------------------------------------------------------------------------------- /code/operator/subscription.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: operators.coreos.com/v1alpha1 2 | kind: Subscription 3 | metadata: 4 | name: openshift-pipelines-operator 5 | namespace: openshift-operators 6 | spec: 7 | channel: ocp-4.6 8 | name: openshift-pipelines-operator-rh 9 | source: redhat-operators 10 | sourceNamespace: openshift-marketplace -------------------------------------------------------------------------------- /code/pipeline/pipeline.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: tekton.dev/v1beta1 2 | kind: Pipeline 3 | metadata: 4 | name: build-and-deploy 5 | spec: 6 | workspaces: 7 | - name: shared-workspace 8 | params: 9 | - name: deployment-name 10 | type: string 11 | description: name of the deployment to be patched 12 | - name: git-url 13 | type: string 14 | description: url of the git repo for the code of deployment 15 | - name: git-revision 16 | type: string 17 | description: revision to be used from repo of the code for deployment 18 | default: "master" 19 | - name: IMAGE 20 | type: string 21 | description: image to be build from the code 22 | tasks: 23 | - name: fetch-repository 24 | taskRef: 25 | name: git-clone 26 | kind: ClusterTask 27 | workspaces: 28 | - name: output 29 | workspace: shared-workspace 30 | params: 31 | - name: url 32 | value: $(params.git-url) 33 | - name: subdirectory 34 | value: "" 35 | - name: deleteExisting 36 | value: "true" 37 | - name: revision 38 | value: $(params.git-revision) 39 | - name: build-image 40 | taskRef: 41 | name: buildah 42 | kind: ClusterTask 43 | params: 44 | - name: TLSVERIFY 45 | value: "false" 46 | - name: IMAGE 47 | value: $(params.IMAGE) 48 | workspaces: 49 | - name: source 50 | workspace: shared-workspace 51 | runAfter: 52 | - fetch-repository 53 | - name: apply-manifests 54 | taskRef: 55 | name: apply-manifests 56 | workspaces: 57 | - name: source 58 | workspace: shared-workspace 59 | runAfter: 60 | - build-image 61 | - name: update-deployment 62 | taskRef: 63 | name: update-deployment 64 | params: 65 | - name: deployment 66 | value: $(params.deployment-name) 67 | - name: IMAGE 68 | value: $(params.IMAGE) 69 | runAfter: 70 | - apply-manifests -------------------------------------------------------------------------------- /code/resources/persistent_volume_claim.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: PersistentVolumeClaim 3 | metadata: 4 | name: source-pvc 5 | spec: 6 | accessModes: 7 | - ReadWriteOnce 8 | resources: 9 | requests: 10 | storage: 1Gi -------------------------------------------------------------------------------- /code/tasks/apply_manifest_task.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: tekton.dev/v1beta1 2 | kind: Task 3 | metadata: 4 | name: apply-manifests 5 | spec: 6 | workspaces: 7 | - name: source 8 | params: 9 | - name: manifest_dir 10 | description: The directory in source that contains yaml manifests 11 | type: string 12 | default: "k8s" 13 | steps: 14 | - name: apply 15 | image: quay.io/openshift/origin-cli:latest 16 | workingDir: /workspace/source 17 | command: ["/bin/bash", "-c"] 18 | args: 19 | - |- 20 | echo Applying manifests in $(inputs.params.manifest_dir) directory 21 | oc apply -f $(inputs.params.manifest_dir) 22 | echo ----------------------------------- -------------------------------------------------------------------------------- /code/tasks/hello.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: tekton.dev/v1beta1 2 | kind: Task 3 | metadata: 4 | name: hello 5 | spec: 6 | steps: 7 | - name: say-hello 8 | image: registry.access.redhat.com/ubi8/ubi 9 | command: 10 | - /bin/bash 11 | args: ['-c', 'echo Hello World'] -------------------------------------------------------------------------------- /code/tasks/update_deployment_task.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: tekton.dev/v1beta1 2 | kind: Task 3 | metadata: 4 | name: update-deployment 5 | spec: 6 | params: 7 | - name: deployment 8 | description: The name of the deployment patch the image 9 | type: string 10 | - name: IMAGE 11 | description: Location of image to be patched with 12 | type: string 13 | steps: 14 | - name: patch 15 | image: quay.io/openshift/origin-cli:latest 16 | command: ["/bin/bash", "-c"] 17 | args: 18 | - |- 19 | oc patch deployment $(inputs.params.deployment) --patch='{"spec":{"template":{"spec":{ 20 | "containers":[{ 21 | "name": "$(inputs.params.deployment)", 22 | "image":"$(inputs.params.IMAGE)" 23 | }] 24 | }}}}' -------------------------------------------------------------------------------- /docs/homeroom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/docs/homeroom.png -------------------------------------------------------------------------------- /docs/jupyter-login.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/docs/jupyter-login.png -------------------------------------------------------------------------------- /docs/starting-up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/docs/starting-up.png -------------------------------------------------------------------------------- /docs/workshop-console.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/docs/workshop-console.png -------------------------------------------------------------------------------- /docs/workshop-terminal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/docs/workshop-terminal.png -------------------------------------------------------------------------------- /workshop/content/01install-op.adoc: -------------------------------------------------------------------------------- 1 | OpenShift Pipelines is provided as an OpenShift add-on that can be installed via an operator that is available in the OpenShift OperatorHub. 2 | 3 | Operators may be installed into a single namespace and only monitor resources in that namespace, but the OpenShift Pipelines Operator installs globally on the cluster and monitors and manage pipelines for every single user in the cluster. 4 | 5 | To install the operator globally, you need to be a cluster administrator user. In this workshop environment, the operator has already been installed for you 6 | 7 | In this lab environment, you already have access to single project with your assigned user e.g. `userX`. 8 | 9 | You user is automatically logged to OpenShift with oc CLI: 10 | 11 | [source,bash,role=execute-1] 12 | ---- 13 | oc whoami 14 | ---- 15 | 16 | A Project has been already assigned to you to work with: 17 | 18 | [source,bash,role=execute-1] 19 | ---- 20 | oc project -q 21 | ---- 22 | 23 | 24 | == The Web Console 25 | 26 | OpenShift ships with a web-based console that will allow users to 27 | perform various tasks via a browser. 28 | 29 | To get a feel for how the web console works, click on this http://console-openshift-console.{{cluster_subdomain}}/k8s/cluster/projects[Web Console] link. 30 | 31 | On the login screen, enter your credentials: 32 | 33 | Username: `{{username}}` 34 | 35 | Password: `openshift` 36 | 37 | The first time you access the web console, you will most likely be in the Administrator perspective. You will be presented with the list of Projects that you can access, and you will see something that looks like the following image: 38 | 39 | image::images/explore-webconsole1sc.png[Web Console] 40 | 41 | Click on the project you see listed. When you click on it, you will be taken to the project details page, 42 | which will list some metrics and details about your project. There's nothing there now, but that will change as you progress through the lab. 43 | 44 | image::images/explore-webconsole2.png[Explore Project] 45 | 46 | At the top of the left navigation menu, you can toggle between the Administrator perspective and the Developer perspective. 47 | 48 | image::images/explore-perspective-toggle.png[Toggle Between Perspectives] 49 | 50 | Select *Developer* to switch to the Developer perspective. Once the Developer perspective loads, you should be in the *Topology* view. Right now, there are no applications or components to view, but once you begin working on the lab, you'll be able to visualize and interact with the components in your application here. 51 | 52 | image::images/explore-topology-view.png[Topology View] 53 | 54 | We will be using a mix of command line tooling and the web console for the labs. 55 | 56 | == Verify installation 57 | 58 | The OpenShift Pipelines Operator provides all its resources under a single API group: tekton.dev. You can see the new resources by running: 59 | 60 | [source,bash,role=execute-1] 61 | ---- 62 | oc api-resources --api-group=tekton.dev 63 | ---- 64 | 65 | === Verify user roles 66 | 67 | To validate that your user has the appropriate roles, you can use the `oc auth can-i` command to see whether you can create Kubernetes custom resources of the kind needed by the OpenShift Pipelines Operator. 68 | 69 | The custom resource you need to create an OpenShift Pipelines pipeline is a resource of the kind pipeline.tekton.dev in the tekton.dev API group. To check that you can create this, run: 70 | 71 | [source,bash,role=execute-1] 72 | ---- 73 | oc auth can-i create pipeline.tekton.dev 74 | ---- 75 | 76 | Or you can use the simplified version: 77 | 78 | [source,bash,role=execute-1] 79 | ---- 80 | oc auth can-i create Pipeline 81 | ---- 82 | 83 | When run, if the response is yes, you have the appropriate access. 84 | 85 | Verify that you can create the rest of the Tekton custom resources needed for this workshop by running the commands below. All of the commands should respond with yes. 86 | 87 | [source,bash,role=execute-1] 88 | ---- 89 | oc auth can-i create Task 90 | ---- 91 | 92 | [source,bash,role=execute-1] 93 | ---- 94 | oc auth can-i create PipelineResource 95 | ---- 96 | 97 | [source,bash,role=execute-1] 98 | ---- 99 | oc auth can-i create PipelineRun 100 | ---- 101 | 102 | Now that we have verified that you can create the required resources let's start the workshop. 103 | -------------------------------------------------------------------------------- /workshop/content/02serviceaccount.adoc: -------------------------------------------------------------------------------- 1 | In this workshop, the pipeline you create uses tools such as https://github.com/openshift/source-to-image[s2i] and https://buildah.io/[Buildah] to create a container image for an application and build the image. 2 | 3 | Building container images using build tools (such as s2i, Buildah and Kaniko) require privileged access to the cluster. OpenShift default security settings do not allow access to privileged containers unless correctly configured. 4 | 5 | This operator has created a `ServiceAccount` with the required permissions to run privileged pods for building images. The name of this service account is easy to remember. It is named _pipeline_. 6 | 7 | You can verify that the pipeline has been created by running the following command: 8 | 9 | [source,bash,role=execute] 10 | ---- 11 | oc get serviceaccount pipeline 12 | ---- 13 | 14 | In addition to privileged security context constraints (SCC), the _pipeline_ service account also has the edit role. This set of permissions allows _pipeline_ to push a container image to OpenShift's internal image registry. 15 | 16 | _pipeline_ is only able to push to a section of OpenShift's internal image registry that corresponds to your OpenShift project namespace. This namespacing helps to separate projects on an OpenShift cluster. 17 | 18 | The pipeline service account executes PipelineRuns on your behalf. You can see an explicit reference for a service account when you trigger a pipeline run later in this workshop. 19 | 20 | In the next section, you will set up the sample application on OpenShift that is deployed in this workshop. -------------------------------------------------------------------------------- /workshop/content/03create-task.adoc: -------------------------------------------------------------------------------- 1 | For this tutorial, you're going to create a simple application that involves a https://github.com/openshift-pipelines/vote-ui[frontend] and https://github.com/openshift-pipelines/vote-api[backend]. This application needs to deploy in a project (i.e. Kubernetes namespace). You can start working with your project: 2 | 3 | [source,bash,role=execute-1] 4 | ---- 5 | oc project 6 | ---- 7 | 8 | You can also deploy the same applications by applying the artifacts available in k8s directory of the respective repo. 9 | 10 | == Tasks 11 | 12 | A **Task** defines a series of `steps` that run in a desired order and complete a set amount of build work. Every `Task` runs as a Pod on your Kubernetes cluster with each `step` as its own container. For example, the following `Task` outputs "Hello World": 13 | 14 | [source,yaml,role=copypaste] 15 | ---- 16 | apiVersion: tekton.dev/v1beta1 17 | kind: Task 18 | metadata: 19 | name: hello 20 | spec: 21 | steps: 22 | - name: say-hello 23 | image: registry.access.redhat.com/ubi8/ubi 24 | command: 25 | - /bin/bash 26 | args: ['-c', 'echo Hello World'] 27 | ---- 28 | 29 | Apply this Task to your cluster just like any other Kubernetes object. Then run it using `tkn`, the CLI tool for Tekton. 30 | 31 | [source,bash,role=execute-1] 32 | ---- 33 | oc apply -f tasks/hello.yaml 34 | ---- 35 | 36 | [source,bash,role=execute-1] 37 | ---- 38 | tkn task start --showlog hello 39 | ---- 40 | 41 | The output will look similar to the following: 42 | 43 | [source,bash] 44 | ---- 45 | TaskRun started: hello-run-9cp8x 46 | Waiting for logs to be available... 47 | [say-hello] Hello World 48 | ---- 49 | 50 | In the next section, you will examine the task definitions that will be needed for our pipeline. -------------------------------------------------------------------------------- /workshop/content/04task-resource-def.adoc: -------------------------------------------------------------------------------- 1 | Tasks can also take parameters. This way, you can pass various flags to be used in this Task. These `params` can be instrumental in making your Tasks more generic and reusable across Pipelines. For example, a `Task` could apply a custom Kubernetes manifest, like the example below. This will be needed for deploying an image on OpenShift in our next section. In addition, we'll cover the `workspaces` during our `Pipeline` step. 2 | 3 | [source,yaml,role="copypaste"] 4 | ---- 5 | apiVersion: tekton.dev/v1beta1 6 | kind: Task 7 | metadata: 8 | name: apply-manifests 9 | spec: 10 | workspaces: 11 | - name: source 12 | params: 13 | - name: manifest_dir 14 | description: The directory in source that contains yaml manifests 15 | type: string 16 | default: "k8s" 17 | steps: 18 | - name: apply 19 | image: quay.io/openshift/origin-cli:latest 20 | workingDir: /workspace/source 21 | command: ["/bin/bash", "-c"] 22 | args: 23 | - |- 24 | echo Applying manifests in $(inputs.params.manifest_dir) directory 25 | oc apply -f $(inputs.params.manifest_dir) 26 | echo ----------------------------------- 27 | ---- 28 | 29 | Create the `apply-manifests` task: 30 | 31 | [source,bash,role="execute-1"] 32 | ---- 33 | oc create -f tasks/apply_manifest_task.yaml 34 | ---- 35 | 36 | We'll also create a `update-deployment` task, which can be seen with a `cat` command: 37 | 38 | [source,bash,role="execute-1"] 39 | ---- 40 | oc create -f tasks/update_deployment_task.yaml 41 | ---- 42 | 43 | Finally, we can create a PersistentVolumeClaim to provide the filesystem for our pipeline execution, explained more in the next step: 44 | 45 | [source,bash,role="execute-1"] 46 | ---- 47 | oc create -f resources/persistent_volume_claim.yaml 48 | ---- 49 | 50 | You can take a look at the tasks you created using the https://github.com/tektoncd/cli/releases[Tekton CLI]: 51 | 52 | [source,bash,role="execute-1"] 53 | ---- 54 | tkn task ls 55 | ---- 56 | 57 | You should see similar output to this: 58 | 59 | [source,bash] 60 | ---- 61 | NAME DESCRIPTION AGE 62 | apply-manifests 4 seconds ago 63 | hello 1 minute ago 64 | update-deployment 3 seconds ago 65 | ---- 66 | 67 | In the next section, you will create a pipeline that takes the source code of an application from GitHub and then builds and deploys it on OpenShift. -------------------------------------------------------------------------------- /workshop/content/05create-pipeline.adoc: -------------------------------------------------------------------------------- 1 | A `Pipeline` defines an ordered series of `Tasks` that you want to execute along with the corresponding inputs and outputs for each `Task`. In fact, tasks should do one single thing so you can reuse them across pipelines or even within a single pipeline. 2 | 3 | Below is an example definition of a `Pipeline`, created using the following diagram: 4 | 5 | image::images/pipeline-diagram.png[Web Console Developer] 6 | 7 | Below is a YAML file that represents the above pipeline: 8 | 9 | [source,yaml,role=copypaste] 10 | ---- 11 | apiVersion: tekton.dev/v1beta1 12 | kind: Pipeline 13 | metadata: 14 | name: build-and-deploy 15 | spec: 16 | workspaces: 17 | - name: shared-workspace 18 | params: 19 | - name: deployment-name 20 | type: string 21 | description: name of the deployment to be patched 22 | - name: git-url 23 | type: string 24 | description: url of the git repo for the code of deployment 25 | - name: git-revision 26 | type: string 27 | description: revision to be used from repo of the code for deployment 28 | default: "master" 29 | - name: IMAGE 30 | type: string 31 | description: image to be build from the code 32 | tasks: 33 | - name: fetch-repository 34 | taskRef: 35 | name: git-clone 36 | kind: ClusterTask 37 | workspaces: 38 | - name: output 39 | workspace: shared-workspace 40 | params: 41 | - name: url 42 | value: $(params.git-url) 43 | - name: subdirectory 44 | value: "" 45 | - name: deleteExisting 46 | value: "true" 47 | - name: revision 48 | value: $(params.git-revision) 49 | - name: build-image 50 | taskRef: 51 | name: buildah 52 | kind: ClusterTask 53 | params: 54 | - name: TLSVERIFY 55 | value: "false" 56 | - name: IMAGE 57 | value: $(params.IMAGE) 58 | workspaces: 59 | - name: source 60 | workspace: shared-workspace 61 | runAfter: 62 | - fetch-repository 63 | - name: apply-manifests 64 | taskRef: 65 | name: apply-manifests 66 | workspaces: 67 | - name: source 68 | workspace: shared-workspace 69 | runAfter: 70 | - build-image 71 | - name: update-deployment 72 | taskRef: 73 | name: update-deployment 74 | workspaces: 75 | - name: source 76 | workspace: shared-workspace 77 | params: 78 | - name: deployment 79 | value: $(params.deployment-name) 80 | - name: IMAGE 81 | value: $(params.IMAGE) 82 | runAfter: 83 | - apply-manifests 84 | ---- 85 | 86 | This pipeline helps you to build and deploy backend/frontend, by configuring the right resources to the pipeline. 87 | 88 | Pipeline Steps: 89 | 90 | 1. `fetch-repository` clones the source code of the application from a git repository by referring (`git-url` and `git-revision` param) 91 | 2. `build-image` builds the container image of the application using the `buildah` clustertask 92 | that uses https://buildah.io/[Buildah] to build the image 93 | 3. The application image is pushed to an image registry by referring (`image` param) 94 | 4. The new application image is deployed on OpenShift using the `apply-manifests` and `update-deployment` tasks 95 | 96 | You might have noticed that there are no references to the git repository or the image registry it will be pushed to in the pipeline. That's because pipeline in Tekton is designed to be generic and re-usable across environments and stages through the application's lifecycle. Pipelines abstract away the specifics of the git 97 | source repository and image to be produced as https://tekton.dev/docs/pipelines/resources[`PipelineResources`] or `Params`. When triggering a pipeline, you can provide different git repositories and image registries to be used during pipeline execution. 98 | 99 | The execution order of task is determined by dependencies that are defined between the tasks via inputs and outputs as well as explicit orders that are defined via `runAfter`. 100 | 101 | `workspaces` field allows you to specify one or more volumes that each Task in the Pipeline requires during execution. You specify one or more Workspaces in the `workspaces` field. 102 | 103 | Create the pipeline by running the following: 104 | 105 | [source,bash,role=execute-1] 106 | ---- 107 | oc create -f pipeline/pipeline.yaml 108 | ---- 109 | 110 | In the next section, you will focus on creating a trigger to execute the tasks specified in the pipeline. -------------------------------------------------------------------------------- /workshop/content/06trigger-pipeline.adoc: -------------------------------------------------------------------------------- 1 | Now that the pipeline is created, you can trigger it to execute the tasks specified in the pipeline. This is done by creating a `PipelineRun` via `tkn`. 2 | 3 | == Trigger a Pipeline via CLI 4 | 5 | Let's start a pipeline to build and deploy our backend application using `tkn`. By creating a `PipelineRun` with the name of our applied `Pipeline`, we can define various arguments to our command like `params` that will be used in the `Pipeline`. For example, we can apply a request for storage with a `persistentVolumeClaim`, as well as define a name for our `deployment`, `git-url` repository to be cloned, and `IMAGE` to be created. 6 | 7 | We'll first build and deploy our backend application using the following command, with the params already included for our specific demo: 8 | 9 | [source,bash,role=execute-1] 10 | ---- 11 | tkn pipeline start build-and-deploy -w name=shared-workspace,claimName=source-pvc -p deployment-name=pipelines-vote-api -p git-url=https://github.com/openshift/pipelines-vote-api.git -p IMAGE=image-registry.openshift-image-registry.svc:5000/{{project_namespace}}/vote-api --showlog 12 | ---- 13 | 14 | Similarly, start a pipeline to build and deploy the frontend application: 15 | 16 | [source,bash,role=execute-1] 17 | ---- 18 | tkn pipeline start build-and-deploy -w name=shared-workspace,claimName=source-pvc -p deployment-name=pipelines-vote-ui -p git-url=https://github.com/openshift/pipelines-vote-ui.git -p IMAGE=image-registry.openshift-image-registry.svc:5000/{{project_namespace}}/vote-ui --showlog 19 | ---- 20 | 21 | As soon as you start the `build-and-deploy` pipeline, a `PipelineRun` will be instantiated and pods will be created to execute the tasks that are defined in the pipeline. To display a list of Pipelines, use the following command: 22 | 23 | [source,bash,role=execute-1] 24 | ---- 25 | tkn pipeline ls 26 | ---- 27 | 28 | Again, notice the reusability of pipelines, and how one generic `Pipeline` can be triggered with various `params`. We've started the `build-and-deploy` pipeline, with relevant pipeline resources to deploy backend/frontend application using a single pipeline. Let's list our PipelineRuns: 29 | 30 | [source,bash,role=execute-1] 31 | ---- 32 | tkn pipelinerun ls 33 | ---- 34 | 35 | After a few minutes, the pipeline should finish successfully! 36 | 37 | [source,bash,role=execute-1] 38 | ---- 39 | tkn pipelinerun ls 40 | ---- 41 | 42 | == Access Pipeline via Web Console 43 | 44 | To view the `PipelineRun` visually, visit the **Pipelines** section of the **Developer Perspective** from left side menu: 45 | 46 | image::images/web-console-developer.png[Web Console Pipelines] 47 | 48 | From here, you can see the details of our `Pipeline`, including the YAML file we've applied, the `PipelineRun`, input custom `params`, logs and more: 49 | 50 | image::images/pipeline-run-progress.png[Pipeline View] 51 | 52 | Congrats! Your `Pipeline` has successfully ran, and the final step will provide instructions on how to access the deployed image. -------------------------------------------------------------------------------- /workshop/content/07verify-deployment.adoc: -------------------------------------------------------------------------------- 1 | To verify a successful deployment for our application, head back out to the web console by clicking on the Console at the center top of the workshop in your browser. 2 | 3 | Click on the Topology tab on the left side of the web console. You should see something similar to what is shown in the screenshot below: 4 | 5 | image::images/application-deployed.png[Web Console Deployed] 6 | 7 | The Topology view of the OpenShift web console helps to show what is deployed out to your OpenShift project visually. As mentioned earlier, the dark blue lining around the _ui_ circle means that a container has started up and running the _api_ application. By clicking on the arrow icon as shown below, you can open the URL for _ui_ in a new tab and see the application running. 8 | 9 | image::images/url-icon.png[Web Console URL Icon] 10 | 11 | After clicking on the icon, you should see the application running in a new tab. 12 | 13 | == Accessing application via CLI 14 | 15 | In addition, you can get the route of the application by executing the following command to access the application. 16 | 17 | [source,bash,role=execute-1] 18 | ---- 19 | oc get route pipelines-vote-ui --template='http://{{.spec.host}}' 20 | ---- 21 | 22 | Congratulations! You have successfully deployed your first application using OpenShift Pipelines. -------------------------------------------------------------------------------- /workshop/content/finish.adoc: -------------------------------------------------------------------------------- 1 | == Summary 2 | 3 | In this workshop, you have worked with OpenShift Pipelines and learned about underlying Tekton concepts. OpenShift Pipelines provides CI/CD solutions for addressing the fundamentals of CI/CD (i.e., automation of building, testing, and deploying application components) but also offers modern solutions around addressing scale, server maintenance, and making all parts of the CI/CD process highly reusable for any number of application development tasks. 4 | 5 | We hope you have found this workshop helpful in learning about OpenShift Pipelines and would love any feedback you have on ways to make it better! Feel free to open issues in this workshop’s https://github.com/openshift-labs/lab-tekton-pipelines[GitHub repository], but also reach out to your workshop leaders to share any thoughts on how we can make this a better experience. 6 | 7 | To learn more about OpenShift Pipelines and Tekton, the resources below can provide information on everything from getting started to more advanced concepts. 8 | 9 | OpenShift Pipelines Webpage: https://cloud.redhat.com/learn/topics/ci-cd 10 | 11 | OpenShift Pipelines Documentation: https://openshift.github.io/pipelines-docs/docs/index.html 12 | 13 | Tekton Pipelines GitHub: https://github.com/tektoncd/pipeline 14 | 15 | Tekton CLI GitHub: https://github.com/tektoncd/cli 16 | 17 | Tekton project website: https://tekton.dev/ 18 | 19 | Read more in the OpenShift blog announcement for OpenShift Pipelines: https://blog.openshift.com/cloud-native-ci-cd-with-openshift-pipelines/ 20 | 21 | For examples of OpenShift Pipelines tasks, visit the openshift/pipelines-catalog GitHub: https://github.com/openshift/pipelines-catalog 22 | 23 | For examples of Tekton pipelines and tasks, visit the tektoncd/catalog GitHub repository: https://github.com/tektoncd/catalog 24 | 25 | For more Tekton workshops, join DevNation Deep Dives: https://developers.redhat.com/devnation/deep-dive/tekton 26 | 27 | To rerun an OpenShift Pipelines tutorial on your own, check out the openshift/pipelines-tutorial GitHub repository: https://github.com/openshift/pipelines-tutorial 28 | -------------------------------------------------------------------------------- /workshop/content/images/application-deployed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/workshop/content/images/application-deployed.png -------------------------------------------------------------------------------- /workshop/content/images/console-import-yaml-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/workshop/content/images/console-import-yaml-1.png -------------------------------------------------------------------------------- /workshop/content/images/console-import-yaml-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/workshop/content/images/console-import-yaml-2.png -------------------------------------------------------------------------------- /workshop/content/images/copy-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/workshop/content/images/copy-icon.png -------------------------------------------------------------------------------- /workshop/content/images/deploy-pipeline-console.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/workshop/content/images/deploy-pipeline-console.png -------------------------------------------------------------------------------- /workshop/content/images/developer-view.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/workshop/content/images/developer-view.png -------------------------------------------------------------------------------- /workshop/content/images/explore-perspective-toggle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/workshop/content/images/explore-perspective-toggle.png -------------------------------------------------------------------------------- /workshop/content/images/explore-topology-view.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/workshop/content/images/explore-topology-view.png -------------------------------------------------------------------------------- /workshop/content/images/explore-webconsole1sc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/workshop/content/images/explore-webconsole1sc.png -------------------------------------------------------------------------------- /workshop/content/images/explore-webconsole2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/workshop/content/images/explore-webconsole2.png -------------------------------------------------------------------------------- /workshop/content/images/import-yaml.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/workshop/content/images/import-yaml.png -------------------------------------------------------------------------------- /workshop/content/images/operator-install-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/workshop/content/images/operator-install-1.png -------------------------------------------------------------------------------- /workshop/content/images/operator-install-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/workshop/content/images/operator-install-2.png -------------------------------------------------------------------------------- /workshop/content/images/operator-install-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/workshop/content/images/operator-install-3.png -------------------------------------------------------------------------------- /workshop/content/images/operatorhub.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/workshop/content/images/operatorhub.png -------------------------------------------------------------------------------- /workshop/content/images/pipeline-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/workshop/content/images/pipeline-diagram.png -------------------------------------------------------------------------------- /workshop/content/images/pipeline-overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/workshop/content/images/pipeline-overview.png -------------------------------------------------------------------------------- /workshop/content/images/pipeline-resources-console.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/workshop/content/images/pipeline-resources-console.png -------------------------------------------------------------------------------- /workshop/content/images/pipeline-run-progress.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/workshop/content/images/pipeline-run-progress.png -------------------------------------------------------------------------------- /workshop/content/images/pipeline-visual.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/workshop/content/images/pipeline-visual.png -------------------------------------------------------------------------------- /workshop/content/images/pipelinerun-logs-tab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/workshop/content/images/pipelinerun-logs-tab.png -------------------------------------------------------------------------------- /workshop/content/images/pipelinerun-logs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/workshop/content/images/pipelinerun-logs.png -------------------------------------------------------------------------------- /workshop/content/images/pipelineruns-filters.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/workshop/content/images/pipelineruns-filters.png -------------------------------------------------------------------------------- /workshop/content/images/pipelineruns-tab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/workshop/content/images/pipelineruns-tab.png -------------------------------------------------------------------------------- /workshop/content/images/request-information.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/workshop/content/images/request-information.png -------------------------------------------------------------------------------- /workshop/content/images/task-logs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/workshop/content/images/task-logs.png -------------------------------------------------------------------------------- /workshop/content/images/task-visual.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/workshop/content/images/task-visual.png -------------------------------------------------------------------------------- /workshop/content/images/tekton-architecture.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /workshop/content/images/topology-view-deployed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/workshop/content/images/topology-view-deployed.png -------------------------------------------------------------------------------- /workshop/content/images/topology-view.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/workshop/content/images/topology-view.png -------------------------------------------------------------------------------- /workshop/content/images/url-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/workshop/content/images/url-icon.png -------------------------------------------------------------------------------- /workshop/content/images/web-console-developer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/workshop/content/images/web-console-developer.png -------------------------------------------------------------------------------- /workshop/content/images/web-console-hub.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/workshop/content/images/web-console-hub.png -------------------------------------------------------------------------------- /workshop/content/images/web-console-login.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/workshop/content/images/web-console-login.png -------------------------------------------------------------------------------- /workshop/content/images/web-console-logs-success.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/workshop/content/images/web-console-logs-success.png -------------------------------------------------------------------------------- /workshop/content/images/web-console-options.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/workshop/content/images/web-console-options.png -------------------------------------------------------------------------------- /workshop/content/images/web-console-pr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/workshop/content/images/web-console-pr.png -------------------------------------------------------------------------------- /workshop/content/images/web-console-project.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/workshop/content/images/web-console-project.png -------------------------------------------------------------------------------- /workshop/content/images/web-console-settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/workshop/content/images/web-console-settings.png -------------------------------------------------------------------------------- /workshop/content/images/web-console-tasks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openshift-labs/lab-tekton-pipelines/1d728280d72ccfa3237957593655cf6aa48b18a5/workshop/content/images/web-console-tasks.png -------------------------------------------------------------------------------- /workshop/content/intro.adoc: -------------------------------------------------------------------------------- 1 | In this self-paced tutorial, you will learn how to use OpenShift Pipelines to automate the deployment of your applications. 2 | 3 | In this tutorial, you will: 4 | 5 | * Learn about the OpenShift Pipelines Operator 6 | * Create a Hello World `Task` 7 | * Install task resource definitions 8 | * Create a Tekton `Pipeline` 9 | * Trigger the created pipeline to finish your application deployment. 10 | 11 | ## Getting started 12 | 13 | OpenShift Pipelines is a cloud-native, continuous integration and delivery (CI/CD) solution for building pipelines using https://tekton.dev[Tekton]. Tekton is a flexible, Kubernetes-native, open-source CI/CD framework that enables automating deployments across multiple platforms (e.g. Kubernetes, serverless, VMs, and so forth) by abstracting away the underlying details. 14 | 15 | OpenShift Pipelines features: 16 | 17 | * Standard CI/CD pipeline definition based on Tekton 18 | * Build container images with tools such as https://docs.openshift.com/container-platform/latest/builds/understanding-image-builds.html#build-strategy-s2i_understanding-image-builds[Source-to-Image (S2I)] and https://buildah.io/[Buildah] 19 | * Deploy applications to multiple platforms such as Kubernetes, serverless, and VMs 20 | * Easy to extend and integrate with existing tools 21 | * Scale pipelines on-demand 22 | * Portable across any Kubernetes platform 23 | * Designed for microservices and decentralized teams 24 | * Integrated with the OpenShift Developer Console 25 | 26 | ## Tekton CRDs 27 | 28 | Tekton defines some https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/[Kubernetes custom resources] as building blocks to standardize pipeline concepts and provide terminology that is consistent across CI/CD solutions. These custom resources are an extension of the Kubernetes API that lets users create and interact with these objects using the OpenShift CLI (`oc`), `kubectl`, and other Kubernetes tools. 29 | 30 | The custom resources needed to define a pipeline are listed below: 31 | 32 | * `Task`: a reusable, loosely coupled number of steps that perform a specific task (e.g. building a container image) 33 | * `Pipeline`: the definition of the pipeline and the `Tasks` that it should perform 34 | * `TaskRun`: the execution and result of running an instance of a task 35 | * `PipelineRun`: the execution and result of running an instance of a pipeline, which includes a number of `TaskRuns` 36 | 37 | For further details on pipeline concepts, refer to the https://github.com/tektoncd/pipeline/tree/master/docs#learn-more[Tekton documentation] that provides an excellent guide for understanding various parameters and attributes available for defining pipelines. 38 | 39 | In the following sections, you will go through each of the above steps to define and invoke a pipeline. Let's get started! -------------------------------------------------------------------------------- /workshop/modules.yaml: -------------------------------------------------------------------------------- 1 | config: 2 | google_tracking_id: UA-135921114-10 3 | template_engine: liquid.js 4 | 5 | modules: 6 | intro: 7 | name: Workshop Introduction 8 | 01install-op: 9 | name: Review OpenShift Pipelines Operator Installation 10 | 02serviceaccount: 11 | name: Pipeline Service Account 12 | 03create-task: 13 | name: Create Tasks 14 | 04task-resource-def: 15 | name: Task Resource Definitions 16 | 05create-pipeline: 17 | name: Create a Pipeline 18 | 06trigger-pipeline: 19 | name: Trigger a Pipeline 20 | 07verify-deployment: 21 | name: Verify Deployment 22 | finish: 23 | name: Workshop Summary 24 | exit_sign: Finish Workshop 25 | -------------------------------------------------------------------------------- /workshop/workshop.yaml: -------------------------------------------------------------------------------- 1 | name: OpenShift Pipelines with Tekton 2 | 3 | modules: 4 | activate: 5 | - intro 6 | - 01install-op 7 | - 02serviceaccount 8 | - 03create-task 9 | - 04task-resource-def 10 | - 05create-pipeline 11 | - 06trigger-pipeline 12 | - 07verify-deployment 13 | - finish 14 | --------------------------------------------------------------------------------