diff --git a/.gitignore b/.gitignore index 7486ca0..61ab597 100644 --- a/.gitignore +++ b/.gitignore @@ -50,5 +50,9 @@ staging-gh-pages triggers/tekton-greeter app.ini demo +work +temp +tmp -docker-secrets \ No newline at end of file +docker-secrets +bin/knative.installed \ No newline at end of file diff --git a/bin/cleanup.sh b/bin/cleanup.sh index f1fad40..415550b 100755 --- a/bin/cleanup.sh +++ b/bin/cleanup.sh @@ -1,10 +1,15 @@ #!/bin/bash +NS=${1:-tektontutorial} + kubectl delete pods --field-selector=status.phase=Succeeded kubectl delete pods --field-selector=status.phase=Failed -kubectl delete -n tektontutorial tasks --all -kubectl delete -n tektontutorial tr --all -kubectl delete -n tektontutorial pipelines --all -kubectl delete -n tektontutorial pr --all -kubectl delete -n tektontutorial pipelineresources +kubectl delete -n "$NS" pipeline --all +kubectl delete -n "$NS" pr --all +kubectl delete -n "$NS" tr --all +kubectl delete -n "$NS" deploy,svc demo-greeter 2>/dev/null +kubectl delete -n "$NS" httpproxy demo-greeter 2>/dev/null +kubectl delete -n "$NS" deploy,svc greeter 2>/dev/null +kubectl delete -n "$NS" httpproxy greeter 2>/dev/null +kubectl delete -n "$NS" ksvc greeter 2>/dev/null diff --git a/bin/enable_knative.sh b/bin/enable_knative.sh index 9b61f27..1fa8559 100755 --- a/bin/enable_knative.sh +++ b/bin/enable_knative.sh @@ -1,14 +1,18 @@ #!/bin/bash set -eu -set -o pipefail +set -o errexit -knative_version=${KNATIVE_VERSION:-v0.16.0} -knative_serving_version=${KNATIVE_SERVING_VERSION:-v0.16.0} +CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -################################### -# Ingress -################################### +knative_version=${KNATIVE_VERSION:-v0.17.0} +knative_serving_version=${KNATIVE_SERVING_VERSION:-v0.17.0} + +############################################################# +# +# Setup Ingress +# +############################################################# kubectl apply -f https://projectcontour.io/quickstart/contour.yaml @@ -19,20 +23,20 @@ kubectl rollout status ds envoy -n projectcontour ###################################### kubectl apply \ - --filename https://github.com/knative/serving/releases/download/$knative_serving_version/serving-crds.yaml + --filename "https://github.com/knative/serving/releases/download/$knative_serving_version/serving-crds.yaml " kubectl apply \ --filename \ - https://github.com/knative/serving/releases/download/$knative_serving_version/serving-core.yaml + "https://github.com/knative/serving/releases/download/$knative_serving_version/serving-core.yaml" kubectl rollout status deploy controller -n knative-serving kubectl rollout status deploy activator -n knative-serving kubectl apply \ --filename \ - https://github.com/knative/net-kourier/releases/download/$knative_version/kourier.yaml + "https://github.com/knative/net-kourier/releases/download/$knative_version/kourier.yaml" -kubectl rollout status deploy 3scale-kourier-control -n kourier-system +kubectl rollout status deploy 3scale-kourier-control -n knative-serving kubectl rollout status deploy 3scale-kourier-gateway -n kourier-system kubectl patch configmap/config-network \ @@ -41,26 +45,35 @@ kubectl patch configmap/config-network \ -p '{"data":{"ingress.class":"kourier.ingress.networking.knative.dev"}}' cat < ---- +The successful `Pipeline` run would have created a Kubernetes deployment and service called `greeter`: + +[.console-input] +[source,bash,subs="+macros,attributes+"] +---- +kubectl get deploy,svc -n {tutorial-namespace} -l=app=greeter +---- + +[.console-output] +[source,bash] +---- +NAME READY UP-TO-DATE AVAILABLE AGE +deployment.apps/greeter 1/1 1 1 9m31s + +NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE +service/greeter NodePort 10.96.251.232 8080:31918/TCP 9m31s +---- + [#tekton-test-pipeline] == Invoke Service Get the service URL, +[tabs] +==== +Minikube:: ++ +-- + [.console-input] [source,bash,subs="+macros,attributes+"] ---- -SVC_URL=$(minikube -p {tutorial-namespace} -n {tutorial-namespace} service greeter --url) +SVC_URL=$(minikube -p {tutorial-namespace} -n {chapter-namespace} greeter --url) ---- - -[NOTE] -==== +-- +OpenShift:: ++ +-- In OpenShift you can use the routes like: [.console-input] [source,bash,subs="+macros,attributes+"] @@ -224,6 +247,7 @@ In OpenShift you can use the routes like: oc expose svc greeter SVC_URL=$(oc get routes greeter -o yaml | yq r - 'spec.url.host' ) ---- +-- ==== Run the service, @@ -239,7 +263,7 @@ The `http` command should return a response containing a line similar to **Meeow [#tekton-pipeline-cleanup] == Cleanup -Delete the pipeline service account and its related permissions: +Clean the completed/failed Task and Pipeline run pods [.console-input] [source,bash,subs="+macros,attributes+"] diff --git a/documentation/modules/ROOT/pages/_partials/_private_reg_repos.adoc b/documentation/modules/ROOT/pages/_partials/_private_reg_repos.adoc index c9afaa9..e0c60be 100644 --- a/documentation/modules/ROOT/pages/_partials/_private_reg_repos.adoc +++ b/documentation/modules/ROOT/pages/_partials/_private_reg_repos.adoc @@ -166,7 +166,7 @@ metadata: namespace: {chapter-namespace} secrets: #- name: github-pat-secret# -- name: build-bot-token-8nl2v +- name: github-bot-token-9p2wg ---- [#tekton-create-clone-pipeline] diff --git a/documentation/modules/ROOT/pages/_partials/_setup.adoc b/documentation/modules/ROOT/pages/_partials/_setup.adoc index f526f3f..862f01f 100644 --- a/documentation/modules/ROOT/pages/_partials/_setup.adoc +++ b/documentation/modules/ROOT/pages/_partials/_setup.adoc @@ -17,6 +17,11 @@ The following CLI tools are required for running the exercises in this tutorial. | `dnf install docker` | https://docs.docker.com/docker-for-windows/install[Docker for Windows] +| `Minikube` +| https://minikube.sigs.k8s.io/docs/start/ +| https://minikube.sigs.k8s.io/docs/start/ +| https://minikube.sigs.k8s.io/docs/start/ + | `kubectl` | https://kubernetes.io/docs/tasks/tools/install-kubectl/[Install] | https://kubernetes.io/docs/tasks/tools/install-kubectl/[Install] @@ -27,10 +32,10 @@ The following CLI tools are required for running the exercises in this tutorial. | https://github.com/wercker/stern/releases/download/1.6.0/stern_linux_amd64[Download] | https://github.com/wercker/stern/releases/download/1.11.0/stern_windows_amd64.exe[Download] -| https://github.com/mikefarah/yq[yq] -| brew install yq -| brew install yq -| choco install yq +| https://github.com/mikefarah/yq[yqv3.x] +| brew install yq@3 +| brew install yq@3 +| choco install yq@3 | https://httpie.org/[httpie] | `brew install httpie` diff --git a/documentation/modules/ROOT/pages/_partials/_tasks.adoc b/documentation/modules/ROOT/pages/_partials/_tasks.adoc index d6d21a1..170c4d8 100644 --- a/documentation/modules/ROOT/pages/_partials/_tasks.adoc +++ b/documentation/modules/ROOT/pages/_partials/_tasks.adoc @@ -103,7 +103,15 @@ Namespace: tektontutorial ⚓ Params NAME TYPE DESCRIPTION DEFAULT VALUE - ∙ contextDir string The context directo... apps/greeter/java/quarkus + ∙ contextDir string The context directo... quarkus + +📝 Results + + No results + +📂 Workspaces + + No workspaces đŸĻļ Steps @@ -142,12 +150,12 @@ tkn task start source-lister \ [NOTE] ==== -The command might ask your to confirm any default values, in this task we have a parameter called `contextDir` which has a default value ``, so when starting the command the Tekton CLI will ask you confirm the same, like: +The command might ask your to confirm any default values, in this task we have a parameter called `contextDir` which has a default value `quarkus`, so when starting the command the Tekton CLI will ask you confirm the same, like: [.console-output] [source,bash] ---- -? Value for param `contextDir` of type `string`? (Default is `apps/greeter/java/quarkus`) (apps/greeter/java/quarkus) +? Value for param `contextDir` of type `string`? (Default is `quarkus`) ---- Be sure press kbd:[Enter] to start the TaskRun after providing inputs to the prompts. @@ -159,7 +167,7 @@ The command should show an output like: [.console-output] [source,bash] ---- -? Value for param `contextDir` of type `string`? (Default is `apps/greeter/java/quarkus`) apps/greeter/java/quarkus +? Value for param `contextDir` of type `string`? (Default is `quarkus`) TaskRun started: source-lister-run-nbpvz Waiting for logs to be available... [git-source-git-source-qtp5j] {"level":"info","ts":1595743350.5350783,"caller":"git/git.go:105","msg":"Successfully cloned https://github.com/redhat-scholars/tekton-tutorial @ master in path /workspace/source"} @@ -239,7 +247,7 @@ Logs starting with **[ls-build-sources]** are from the container that is respons [[tekton-task-list-ws]] == Know the workspace directory -In the example above, there is a log which shows the `git clone` command that cloned the application sources to the `/workspace/source` directory. The *workspace* directory is where your Task/Pipeline sources/build atrifacts will be cloned and generated. The `source` sub-path under is the directory where Tekton cloned the applicaiton sources. It is usually the name of the resources --> inputs --> Resource of type Git. +In the example above, there is a log which shows the `git clone` command that cloned the application sources to the `/workspace/source` directory. The *workspace* directory is where your Task/Pipeline sources/build artifacts will be cloned and generated. The `source` is a sub-path, under which Tekton cloned the application sources. It is usually the name of the resources -> inputs -> Resource of type *Git*. [[tekton-task-clustertask]] == Cluster Task @@ -269,7 +277,7 @@ tkn task ls No Tasks found ---- -The reason that there are no Tasks found us that, we have not created any ClusterTask yet. If the Task is not a ClusterTask type then we will not be able to run the Task in namespaces where its not installed. Try running our `source-lister` task from within `clustertask-demo`: +The reason that there are no Tasks found us that, we have not created any `ClusterTask` yet. If the `Task` is not of a `ClusterTask` type then we will not be able to run the Task in namespaces other than where it was deployed. Try running our `source-lister` task from within `clustertask-demo`: [.console-input] [source,bash] @@ -282,8 +290,6 @@ The command should fail with following output: [.console-output] [source,bash] ---- -# shifting to clustertask-demo -Context "tektontutorial" modified. Error: Task name source-lister does not exist in namespace clustertask-demo ---- @@ -359,6 +365,14 @@ Name: echoer No params +📝 Results + + No results + +📂 Workspaces + + No workspaces + đŸĻļ Steps ∙ unnamed-0 @@ -402,6 +416,12 @@ Let us now shift back to `{tutorial-namespace}` and run the `echoer` task again: kubectl config set-context --current --namespace={tutorial-namespace} ---- +[.console-output] +[source,bash] +---- +Context "tektontutorial" modified. +---- + [.console-input] [source,bash,subs="+macros,+attributes"] ---- @@ -421,18 +441,26 @@ The command should produce an identical output as shown in <> will finally deploy all these three steps together as one single `build-app` task. +3. As part of the last step(`build-push`) the built linux container image will be pushed to the container registry. + +The following section explains the three Task `Steps`. The <> will finally deploy all these three steps together as one single `build-app` task. [[task-parameters]] -=== Step :: Task Inputs and Outputs +=== Task Inputs and Outputs .link:{github-repo}/{tasks-repo}/build-app-task.yaml[task inputs and outputs^] [source,yaml,subs="+macros,attributes+"] ---- @@ -473,7 +501,7 @@ For Task inputs and outputs - we will use the xref:pipeline-resources.adoc#tkn-s ==== [[build-sources]] -=== Step 1 :: Build Application Sources +=== Step#1 - Build Application Sources .link:{github-repo}/{tasks-repo}/build-app-task.yaml#L32-L43[step-build-sources^] [source,yaml,subs="+macros,attributes+"] ---- @@ -499,7 +527,7 @@ For Task inputs and outputs - we will use the xref:pipeline-resources.adoc#tkn-s <.> The environment variables that will be set within the step container [[build-linux-image]] -=== Step 2 :: Build Application Linux Container Image +=== Step#2 - Build Application Linux Container Image .link:{github-repo}/{tasks-repo}/build-app-task.yaml#L44-L62[step-build-image^] [source,yaml,subs="+macros,attributes+"] @@ -527,7 +555,7 @@ For Task inputs and outputs - we will use the xref:pipeline-resources.adoc#tkn-s <.> The buildah tool saves the built linux container layers in the local file system at `/var/lib/containers`, which can then be used in other <> or to push the image to remote registry. [[push-linux-image]] -=== Step 3:: Push Application Linux Container Image +=== Step#3 - Push Application Linux Container Image .link:{github-repo}/{tasks-repo}/build-app-task.yaml#L63-L78[step-build-image^] [source,yaml,subs="+macros,attributes+"] @@ -722,10 +750,7 @@ Minikube:: [.console-input] [source,bash,subs="+macros,attributes+"] ---- -kubectl run demo-greeter -n {tutorial-namespace} \ - --generator='run-pod/v1' \ - --image='example.com/rhdevelopers/tekton-tutorial-greeter' && \ -kubectl expose pod demo-greeter -n {tutorial-namespace} --port 8080 --type=NodePort +kubectl apply -n {tutorial-namespace} -f $TUTORIAL_HOME/kubernetes/demo-greeter.yaml ---- Wait for the `demo-greeter` to be up and running: @@ -743,7 +768,6 @@ Lets try checking the application: ---- SVC_URL=$(minikube -p {tutorial-namespace} -n {tutorial-namespace} service demo-greeter --url) ---- - -- OpenShift:: + @@ -897,8 +921,7 @@ NOTE: The Task steps can override the stepTemplate values. [.console-input] [source,bash,subs="+macros,attributes+"] ---- -kubectl delete pod -n {tutorial-namespace} demo-greeter -kubectl delete svc -n {tutorial-namespace} demo-greeter +kubectl delete -n {tutorial-namespace} -f $TUTORIAL_HOME/kubernetes/demo-greeter.yaml ---- Clean all completed and failed pods diff --git a/documentation/modules/ROOT/pages/_partials/_triggers.adoc b/documentation/modules/ROOT/pages/_partials/_triggers.adoc index 64c3313..05d1e26 100644 --- a/documentation/modules/ROOT/pages/_partials/_triggers.adoc +++ b/documentation/modules/ROOT/pages/_partials/_triggers.adoc @@ -186,7 +186,9 @@ A successfull initializations should show an output like: [init-gitea] Repository Clone url http://gitea.192.168.64.7.nip.io/gitea/tekton-tutorial-greeter.git ---- -You should now be able to open the *Repository Clone url* from the output above and view the repository content. +You should now be able to open the http://$GITEA_HOME/tekton-tutorial-greeter.git and check the repository sources, that we will use as part of this chapter's exercises. + +NOTE: Gitea admin user is *gitea* and password *gitea*. [#install-tekton-triggers] == Install Triggers @@ -275,7 +277,7 @@ tekton-greeter-trigger-template 1 minute ago Minikube:: + -- -NOTE: by default the greeter pipeline's default image tag that it builds to is the example.com addon registry for minikube. Hence, no further updates to the TriggerTemplate is necessary +NOTE: by default the greeter pipeline's default image tag that it builds to is the `example.com/tekton-tutorial/greeter`. Hence, no further updates to the TriggerTemplate is necessary -- OpenShift:: + @@ -388,19 +390,22 @@ NAME AGE gitea-webhook 4 seconds ago ---- -Each EventListener will have a service named `el-` exposed automatically for sources to send events to Triggers. +Wait for the `gitea-webhook` event listener pod to be running, each EventListener will have a service named `el-` exposed automatically for sources to send events to Triggers. [.console-input] [source,bash,subs="+macros,+attributes"] ---- -kubectl get svc -n {chapter-namespace} -leventlistener=gitea-webhook +kubectl get pods,svc -n {chapter-namespace} -leventlistener=gitea-webhook ---- [.console-output] [source,bash,subs="+quotes"] ---- -NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE -#el-gitea-webhook ClusterIP 10.97.199.207 8080/TCP 51s# +NAME READY STATUS RESTARTS AGE +pod/el-gitea-webhook-848875db8f-25r2r 1/1 Running 0 58s + +NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE +#service/el-gitea-webhook ClusterIP 10.96.121.97 8080/TCP 58s# ---- === Create Event Listener Ingress @@ -418,7 +423,7 @@ Minikube:: export EL_WEBHOOK_HOST="$(kubectl get svc -n {chapter-namespace} el-gitea-webhook -o yaml \ | yq r - 'metadata.name').$(minikube ip).nip.io" export EL_WEBHOOK_LISTENER_PORT="$(kubectl get svc -n {chapter-namespace} el-gitea-webhook -o yaml \ - | yq r - 'spec.ports.(name==http-listener).port')" + | yq r - 'spec.ports.(name==listener).port')" ---- [.console-input] @@ -546,12 +551,12 @@ el-gitea-webhook-88bc89db-ld6jz event-listener {"level":"info","logger":"eventli === Clone and Edit the source -Using your favorite IDE clone the repo `tekton-greeter` from Gitea using the <>. +Using your favorite IDE clone the repo `tekton-greeter` from Gitea: [.console-input] [source,bash,subs="+macros,+attributes"] ---- -git clone +git clone http://gitea.$(minikube -p {tutorial-namespace} ip).nip.io/gitea/tekton-tutorial-greeter.git ---- Open the `tekton-tutorial-greeter` in your IDE and edit the Java file: diff --git a/documentation/modules/ROOT/pages/_partials/_workspaces.adoc b/documentation/modules/ROOT/pages/_partials/_workspaces.adoc index 0c69de6..3e721bc 100644 --- a/documentation/modules/ROOT/pages/_partials/_workspaces.adoc +++ b/documentation/modules/ROOT/pages/_partials/_workspaces.adoc @@ -95,6 +95,7 @@ tkn task start git-clone \ --namespace={chapter-namespace} \ --param url={tutorial-apps-repo} \ --param revision={tutorial-apps-revision} \ + --param deleteExisting=true \ --workspace name=output,claimName=tekton-tutorial-sources \ --use-param-defaults \#<.> --showlog @@ -126,8 +127,6 @@ kubectl create -n {chapter-namespace} -f git-clone-taskrun.yaml -- ==== -include::ROOT:partial$logs-view.adoc[tags='tr'] - It will take few minutes for the TaskRun to start. [NOTE] @@ -139,6 +138,8 @@ Watch the status of the Task run using: ---- tkn tr ls ---- + +include::ROOT:partial$logs-view.adoc[tags='tr'] ==== You can also check the PVC is bound, as the git-clone-task output workspace is bound to it: @@ -498,7 +499,7 @@ We need to create the Service Account(SA) that is authorized to Knative Service [source,bash,subs="+macros,+attributes"] ---- curl -sSL \ - https://raw.githubusercontent.com/tektoncd/catalog/master/task/kn/0.1/kn-deployer.yaml \ + https://raw.githubusercontent.com/tektoncd/catalog/master/task/kn/0.1/support/kn-deployer.yaml \ | yq w - -d0 metadata.namespace {chapter-namespace} \ | yq w - -d2 subjects.[0].namespace {chapter-namespace} \ | kubectl apply -f - @@ -543,8 +544,6 @@ kubectl:: ---- include::ROOT:example$greeter-app-deploy-run.yaml[] ---- -<.> The service account to be used with the PipelineRun -<.> The Pipeline workspaces mapping [.console-input] [source,bash,subs="+macros,+attributes"] @@ -578,11 +577,11 @@ The command should show an output like : Name: greeter Namespace: {chapter-namespace} Age: 21s -#URL: http://greeter.{chapter-namespace}.127.0.0.1.nip.io# +#URL: http://greeter.{chapter-namespace}.192.168.64.7.nip.io# Revisions: 100% @latest (greeter-ttyqz-1) [1] (21s) - Image: kind-registry:5000/rhdevelopers/tekton-tutorial-greeter@sha256:79b8a50a6ef29dbc0df5220de5aea13b8b38b7c4cd407ad074968de8cfbd41b6 (at 79b8a5) + Image: example.com/tekton-tutorial/greeter@sha256:79b8a50a6ef29dbc0df5220de5aea13b8b38b7c4cd407ad074968de8cfbd41b6 (at 79b8a5) Conditions: OK TYPE AGE REASON @@ -615,18 +614,17 @@ A successfull pipeline deployment should show an output like: [.console-output] [source,text,subs="+quotes"] ---- -*Meeow from Tekton đŸ˜ē !! 🚀* +*Tekton đŸ˜ē rocks 🚀* ---- [#tekton-ws-cleanup] == Cleanup +IMPORTANT: Leave the namespace, nexus, pvc, confimaps created as part of this chapter, as we will be reusing them in next chapter. + [.console-input] [source,bash,subs="+macros,attributes+"] ---- -kubectl delete -n {chapter-namespace} pipeline --all -kubectl delete -n {chapter-namespace} pr --all -kubectl delete -n {chapter-namespace} tr --all +$TUTORIAL_HOME/bin/cleanup.sh {chapter-namespace} ---- -IMPORTANT: Leave the namespace, nexus, pvc, confimaps created as part of this chapter, as we will be reusing them in next chapter. diff --git a/documentation/modules/ROOT/pages/_partials/kind-setup.adoc b/documentation/modules/ROOT/pages/_partials/kind-setup.adoc new file mode 100644 index 0000000..654447c --- /dev/null +++ b/documentation/modules/ROOT/pages/_partials/kind-setup.adoc @@ -0,0 +1,106 @@ +[#start-kind] +**Configure and Start KinD** + +Before installing Tekton and its components, we need to create a Kubernetes Cluster. Download https://kind.sigs.k8s.io/docs/user/quick-start/[KinD] and add it to your path. + +[.console-input] +[source,bash,subs="+macros,+attributes"] +---- +$TUTORIAL_HOME/bin/start-kind.sh +---- + +.KinD starting +[.console-output] +[source,bash,subs="+macros,+attributes"] +---- +::group:: Install KinD +Creating cluster "tektontutorial" ... + ✓ Ensuring node image (kindest/node:v1.19.1) đŸ–ŧ + ✓ Preparing nodes đŸ“Ļ đŸ“Ļ + ✓ Writing configuration 📜 + ✓ Starting control-plane 🕹ī¸ + ✓ Installing CNI 🔌 + ✓ Installing StorageClass 💾 + ✓ Joining worker nodes 🚜 +Set kubectl context to "kind-tektontutorial" +You can now use your cluster with: + +kubectl cluster-info --context kind-tektontutorial + +Have a nice day! 👋 +node/tektontutorial-control-plane annotated +node/tektontutorial-worker annotated +node/tektontutorial-worker labeled +::endgroup:: +::group:: Setup container registry +65a9f0d33f8c896da5fcbdeca928a4bf63362c1b49b887c426e62997fc2c9d9f +::endgroup:: +::group:: Install Contour Ingress +namespace/projectcontour created +serviceaccount/contour created +serviceaccount/envoy created +configmap/contour created +customresourcedefinition.apiextensions.k8s.io/extensionservices.projectcontour.io created +customresourcedefinition.apiextensions.k8s.io/httpproxies.projectcontour.io created +customresourcedefinition.apiextensions.k8s.io/tlscertificatedelegations.projectcontour.io created +serviceaccount/contour-certgen created +rolebinding.rbac.authorization.k8s.io/contour created +role.rbac.authorization.k8s.io/contour-certgen created +job.batch/contour-certgen-v1.11.0 created +clusterrolebinding.rbac.authorization.k8s.io/contour created +clusterrole.rbac.authorization.k8s.io/contour created +service/contour created +service/envoy created +deployment.apps/contour created +daemonset.apps/envoy created +daemon set "envoy" successfully rolled out +::endgroup:: +---- + +[#deploy-tekton] +*Deploy Tekton Pipelines* + +To deploy the Tekton pipelines: + +[.console-input] +[source,bash,subs="+macros,attributes+"] +---- +kubectl apply --filename \ +https://github.com/tektoncd/pipeline/releases/download/{tekton-version}/release.notags.yaml +---- + +[NOTE] +====== +It will take few mins for the Tekton pipeline components to be installed, you an watch the status using the command: + +[.console-input] +[source,bash,subs="+macros,attributes+"] +---- +watch kubectl get pods -n tekton-pipelines +---- + +You can use kbd:[Ctrl+c] to terminate the watch +====== + +A successful deployment of Tekton pipelines will show the following pods: + +[.console-output] +[source,bash] +----- +NAME READY STATUS AGE +tekton-pipelines-controller-849ccccd7f-gc6dp 1/1 Running 85s +tekton-pipelines-webhook-75bc7666c-9crwq 1/1 Running 85s +----- + +include::partial$tekton-cli.adoc[] +**Configuring Kubernetes namespace** + +All the tutorial exercises will be deployed in namespace called `{tutorial-namespace}`: + +[.console-input] +[source,bash,subs="+macros,+attributes"] +---- +kubectl create namespace {tutorial-namespace} &&\ +kubectl config set-context --current --namespace={tutorial-namespace} +---- + diff --git a/documentation/modules/ROOT/pages/_partials/minikube-setup.adoc b/documentation/modules/ROOT/pages/_partials/minikube-setup.adoc index cb4ffe0..43f4ac7 100644 --- a/documentation/modules/ROOT/pages/_partials/minikube-setup.adoc +++ b/documentation/modules/ROOT/pages/_partials/minikube-setup.adoc @@ -18,48 +18,45 @@ $TUTORIAL_HOME/bin/start-minikube.sh ❌ profile "{tutorial-namespace}" not found ✅ Created a new profile : {tutorial-namespace} ✅ minikube profile was successfully set to {tutorial-namespace} -😄 [{tutorial-namespace}] minikube v1.12.1 on Darwin 10.15.6 +😄 [{tutorial-namespace}] minikube {minikube-version} on Darwin 10.15.6 ✨ Automatically selected the hyperkit driver 👍 Starting control plane node {tutorial-namespace} in cluster {tutorial-namespace} đŸ”Ĩ Creating hyperkit VM (CPUs=4, Memory=8192MB, Disk=51200MB) ... -đŸŗ Preparing Kubernetes v1.18.3 on Docker 19.03.12 ... +đŸŗ Preparing Kubernetes `kubernetes-version` on Docker 20.10.0 ... 🔎 Verifying Kubernetes components... 🌟 Enabled addons: default-storageclass, storage-provisioner -🏄 Done! kubectl is now configured to use "{tutorial-namespace}" +🏄 Done! kubectl is now configured to use "{tutorial-namespace} and "default" namespace by default" +✅ minikube profile was successfully set to {tutorial-namespace} ---- -Switch to the new minikube profile *{tutorial-namespace}*, so that all your commands gets executed in the right context: +**Enable Internal Container Registry and Registry Aliases** + +To enable pushing and pulling container images from local internal minikube registry, we will deploy the minikube https://github.com/kubernetes/minikube/tree/master/deploy/addons/registry[registry] addon: [.console-input] [source,bash,subs="+macros,+attributes"] ---- -minikube profile {tutorial-namespace} +minikube addons enable registry ---- [.console-output] [source,bash,subs="+macros,+attributes"] ---- -✅ minikube profile was successfully set to {tutorial-namespace} +🔎 Verifying registry addon... +🌟 The 'registry' addon is enabled ---- -**Deploy Registry Helper** - -To enable pushing and pulling container images from local internal minikube registry, we will deploy the minikube https://github.com/kubernetes/minikube/tree/master/deploy/addons/registry-aliases[registry-aliases] addon: - [.console-input] [source,bash,subs="+macros,+attributes"] ---- -minikube addons enable registry && minikube addons enable registry-aliases +minikube addons enable registry-aliases ---- [.console-output] [source,bash,subs="+macros,+attributes"] ---- -🔎 Verifying registry addon... -🌟 The 'registry' addon is enabled 🌟 The 'registry-aliases' addon is enabled ---- - The registry-aliases addon should allow you to build local container images with names like: - example.com/foo/bar @@ -78,7 +75,7 @@ To deploy the Tekton pipelines: [source,bash,subs="+macros,attributes+"] ---- kubectl apply --filename \ -https://github.com/tektoncd/pipeline/releases/download/{tekton-version}/release.yaml +https://github.com/tektoncd/pipeline/releases/download/{tekton-version}/release.notags.yaml ---- [NOTE] diff --git a/documentation/modules/ROOT/pages/_partials/namespace-prep.adoc b/documentation/modules/ROOT/pages/_partials/namespace-prep.adoc index 4fef6ec..ed13f72 100644 --- a/documentation/modules/ROOT/pages/_partials/namespace-prep.adoc +++ b/documentation/modules/ROOT/pages/_partials/namespace-prep.adoc @@ -101,7 +101,13 @@ The nexus maven repository could be opened using the url: [.console-input] [source,bash,subs="+macros,+attributes"] ---- -$(minikube service nexus -n {chapter-namespace}) +minikube -p {tutorial-namespace} service nexus -n {chapter-namespace} --url +---- + +[.console-output] +[source,bash] +---- +http://192.168.64.27:30102 ---- -- OpenShift:: @@ -207,16 +213,16 @@ Before we create our pipeline ensure that the kubernetes cluster has a default s ifndef::openshift[] [tabs] ==== -Kubernetes:: +Minikube:: + -- -In minkube cluster it should show an output like: +In minikube cluster it should show an output like: [.console-output] [source,subs="+quotes"] ----- NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE -standard (#default#) k8s.io/minikube-hostpath Delete Immediate false 9h +standard (default) k8s.io/minikube-hostpath Delete Immediate false 44m ----- -- OpenShift:: diff --git a/documentation/modules/ROOT/pages/_partials/prereq-cli.adoc b/documentation/modules/ROOT/pages/_partials/prereq-cli.adoc index 24bba0d..e3b70f0 100644 --- a/documentation/modules/ROOT/pages/_partials/prereq-cli.adoc +++ b/documentation/modules/ROOT/pages/_partials/prereq-cli.adoc @@ -3,19 +3,10 @@ The following checks ensure that each chapter exercises are done with the right [tabs] ==== -Kubernetes:: +Minikube:: + -- -* Set your local docker to use minikube docker daemon - -[.console-input] -[source,bash,subs="+macros,+attributes"] ----- -eval $(minikube docker-env) &&\ -minikube profile {tutorial-namespace} ----- - -* Kubernetes should be v1.18+ +* Kubernetes should be v1.19+ [.console-input] [source,bash,subs="+macros,+attributes"] @@ -26,17 +17,17 @@ kubectl version --short The output should be like [.console-output] -[source,bash] +[source,bash,subs="+macros,+attributes"] ---- -Client Version: v1.18.6 -Server Version: v1.18.3 +Client Version: {kubernetes-version} +Server Version: {kubernetes-version} ---- -- OpenShift:: + -- -* OpenShift CLI should be v4.3+ +* OpenShift CLI should be {openshift-version} [.console-input] [source,bash,subs="+macros,+attributes"] @@ -47,14 +38,14 @@ oc version The output should be like [.console-output] -[source,bash] +[source,bash,subs="+macros,+attributes"] ---- -Client Version: 4.5.3 -Server Version: 4.5.3 -Kubernetes Version: v1.18.3 +Client Version: {kubernetes-version} +Server Version: {openshift-version} +Kubernetes Version: {kubernetes-version} ---- -* Make sure to be on `tektontutorial` OpenShift project +* Make sure to be on `{tutorial-namespace}` OpenShift project [.console-input] [source,bash,subs="+macros,+attributes"] diff --git a/documentation/modules/ROOT/pages/_partials/tekton-api.adoc b/documentation/modules/ROOT/pages/_partials/tekton-api.adoc index 12de7dc..083e110 100644 --- a/documentation/modules/ROOT/pages/_partials/tekton-api.adoc +++ b/documentation/modules/ROOT/pages/_partials/tekton-api.adoc @@ -17,6 +17,7 @@ conditions tekton.dev true Condition pipelineresources tekton.dev true PipelineResource pipelineruns pr,prs tekton.dev true PipelineRun pipelines tekton.dev true Pipeline +runs tekton.dev true Run taskruns tr,trs tekton.dev true TaskRun tasks tekton.dev true Task ---- diff --git a/documentation/modules/ROOT/pages/_partials/tekton-cli.adoc b/documentation/modules/ROOT/pages/_partials/tekton-cli.adoc index 90693ab..a4ad7dc 100644 --- a/documentation/modules/ROOT/pages/_partials/tekton-cli.adoc +++ b/documentation/modules/ROOT/pages/_partials/tekton-cli.adoc @@ -28,7 +28,6 @@ ifndef::openshift[] ---- Client version: {tekton-cli-version} Pipeline version: {tekton-version} -Triggers version: unknown ---- NOTE: Since Tekton Triggers is not installed, the version is shown as unknown diff --git a/documentation/modules/ROOT/pages/pipeline-resources.adoc b/documentation/modules/ROOT/pages/pipeline-resources.adoc index 91895d4..a07f720 100644 --- a/documentation/modules/ROOT/pages/pipeline-resources.adoc +++ b/documentation/modules/ROOT/pages/pipeline-resources.adoc @@ -3,5 +3,4 @@ include::master@tekton-tutorial:ROOT:partial$_attributes.adoc[] :k8s-resource: build-resources.yaml :chapter-namespace: tektontutorial -include::master@tekton-tutorial:ROOT:partial$_pipeline_resources.adoc[] - +include::master@tekton-tutorial:ROOT:partial$_pipeline_resources.adoc[] \ No newline at end of file diff --git a/install/utils/nexus.yaml b/install/utils/nexus.yaml index 4933ea1..0fb1924 100644 --- a/install/utils/nexus.yaml +++ b/install/utils/nexus.yaml @@ -52,3 +52,17 @@ spec: volumes: - name: nexus-data emptyDir: {} +# --- +# apiVersion: projectcontour.io/v1 +# kind: HTTPProxy +# metadata: +# name: nexus +# spec: +# virtualhost: +# fqdn: nexus.127.0.0.1.nip.io +# routes: +# - conditions: +# - prefix: / +# services: +# - name: nexus +# port: 8081 \ No newline at end of file diff --git a/kubernetes/demo-greeter.yaml b/kubernetes/demo-greeter.yaml new file mode 100644 index 0000000..bd768f0 --- /dev/null +++ b/kubernetes/demo-greeter.yaml @@ -0,0 +1,31 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: demo-greeter +spec: + selector: + app: demo-greeter + ports: + - port: 8080 + targetPort: 8080 + type: NodePort +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: demo-greeter +spec: + selector: + matchLabels: + app: demo-greeter + template: + metadata: + labels: + app: demo-greeter + spec: + containers: + - name: demo-greeter + image: example.com/rhdevelopers/tekton-tutorial-greeter + ports: + - containerPort: 8080 diff --git a/kubernetes/http-proxy.yaml b/kubernetes/http-proxy.yaml new file mode 100644 index 0000000..10ea1c3 --- /dev/null +++ b/kubernetes/http-proxy.yaml @@ -0,0 +1,14 @@ +--- +apiVersion: projectcontour.io/v1 +kind: HTTPProxy +metadata: + name: greeter +spec: + virtualhost: + fqdn: greeter.127.0.0.1.nip.io + routes: + - conditions: + - prefix: / + services: + - name: greeter + port: 8080 \ No newline at end of file diff --git a/resources/build-resources.yaml b/resources/build-resources.yaml index 94cb634..1fcc5b0 100644 --- a/resources/build-resources.yaml +++ b/resources/build-resources.yaml @@ -8,7 +8,7 @@ spec: - name: url value: https://github.com/redhat-scholars/tekton-tutorial-greeter - name: revision - value: staging + value: master --- apiVersion: tekton.dev/v1alpha1 kind: PipelineResource @@ -18,7 +18,7 @@ spec: type: image params: - name: url - # use internal registry + # use minikube internal registry value: example.com/rhdevelopers/tekton-tutorial-greeter - # if you are on OpenShift uncomment the line below + # if you are on OpenShift, use OpenShift interal registry #value: "image-registry.openshift-image-registry.svc:5000/tektontutorial/greeter" diff --git a/staging.yml b/staging.yml index d855993..a34e1c3 100644 --- a/staging.yml +++ b/staging.yml @@ -17,12 +17,15 @@ asciidoc: kubernetes-version: v1.18.2 release-version: master page-pagination: true - tekton-version: v0.14.3 - triggers-version: v0.6.1 - kn-version: v0.16.0 - tekton-cli-version: 0.12.0 + tekton-version: v0.19.0 + triggers-version: v0.10.2 + kn-version: v0.17.3 + tekton-cli-version: 0.15.0 cli: kubectl openshift-version: 4.6 + kind-version: v0.9.0 + minikube-version: v1.16.0 + tutorial-apps-revision: master extensions: - ./lib/remote-include-processor.js - ./lib/tab-block.js diff --git a/triggers/greeter-trigger-template.yaml b/triggers/greeter-trigger-template.yaml index e7b3912..e0e1c49 100644 --- a/triggers/greeter-trigger-template.yaml +++ b/triggers/greeter-trigger-template.yaml @@ -23,15 +23,15 @@ spec: name: greeter-app-deploy params: - name: github-repo-url - value: '$(params.gitrepositoryurl)' + value: '$(tt.params.gitrepositoryurl)' - name: github-repo-revision - value: '$(params.gitrevision)' + value: '$(tt.params.gitrevision)' - name: context-dir # must be either 'quarkus' or 'springboot' value: quarkus - name: image-name # For OpenShift builds, this should be patched to point to a suitable image stream for the project - value: example.org/tekton-tutorial/greeter + value: example.com/tekton-tutorial/greeter workspaces: - name: maven-settings configmap: diff --git a/triggers/rbac/kustomization.yaml b/triggers/rbac/kustomization.yaml index cc2b640..5da3190 100644 --- a/triggers/rbac/kustomization.yaml +++ b/triggers/rbac/kustomization.yaml @@ -8,7 +8,8 @@ resources: - serviceaccount.yaml # ROLES - app-deployer.yaml - - tekton-triggers-admin.yaml + - tekton-triggers-role-minimal.yaml + - tekton-triggers-clusterrole-minimal.yaml - tekton-triggers-webhook.yaml #ROLE Bindings - role-bindings.yaml diff --git a/triggers/rbac/role-bindings.yaml b/triggers/rbac/role-bindings.yaml index 3593fc2..2581cc0 100644 --- a/triggers/rbac/role-bindings.yaml +++ b/triggers/rbac/role-bindings.yaml @@ -15,10 +15,10 @@ subjects: apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: - name: tekton-triggers-createwebhook-binding + name: tt-createwebhook-binding roleRef: kind: Role - name: tekton-triggers-createwebhook + name: tt-createwebhook apiGroup: rbac.authorization.k8s.io subjects: - kind: ServiceAccount @@ -28,10 +28,23 @@ subjects: apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: - name: tekton-triggers-admin-binding + name: tt-minimal-binding roleRef: kind: Role - name: tekton-triggers-admin + name: tt-minimal + apiGroup: rbac.authorization.k8s.io +subjects: + - kind: ServiceAccount + name: pipeline + namespace: default +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: tt-clusterrole-minimal-binding +roleRef: + kind: ClusterRole + name: tt-clusterrole-minimal apiGroup: rbac.authorization.k8s.io subjects: - kind: ServiceAccount diff --git a/triggers/rbac/tekton-triggers-admin.yaml b/triggers/rbac/tekton-triggers-admin.yaml deleted file mode 100644 index d992220..0000000 --- a/triggers/rbac/tekton-triggers-admin.yaml +++ /dev/null @@ -1,29 +0,0 @@ ---- -kind: Role -apiVersion: rbac.authorization.k8s.io/v1 -metadata: - name: tekton-triggers-admin -rules: - - apiGroups: - - triggers.tekton.dev - resources: - - eventlisteners - - triggerbindings - - triggertemplates - verbs: - - get - - apiGroups: - - tekton.dev - resources: - - pipelineruns - - pipelineresources - verbs: - - create - - apiGroups: - - '' - resources: - - configmaps - verbs: - - get - - list - - watch diff --git a/triggers/rbac/tekton-triggers-clusterrole-minimal.yaml b/triggers/rbac/tekton-triggers-clusterrole-minimal.yaml new file mode 100644 index 0000000..c1d483a --- /dev/null +++ b/triggers/rbac/tekton-triggers-clusterrole-minimal.yaml @@ -0,0 +1,9 @@ +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: tt-clusterrole-minimal +rules: + # EventListeners need to be able to fetch any clustertriggerbindings +- apiGroups: ["triggers.tekton.dev"] + resources: ["clustertriggerbindings"] + verbs: ["get", "list", "watch"] \ No newline at end of file diff --git a/triggers/rbac/tekton-triggers-role-minimal.yaml b/triggers/rbac/tekton-triggers-role-minimal.yaml new file mode 100644 index 0000000..fe2cfc9 --- /dev/null +++ b/triggers/rbac/tekton-triggers-role-minimal.yaml @@ -0,0 +1,26 @@ +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: tt-minimal +rules: +# EventListeners need to be able to fetch all namespaced resources +- apiGroups: ["triggers.tekton.dev"] + resources: ["eventlisteners", "triggerbindings", "triggertemplates", "triggers"] + verbs: ["get", "list", "watch"] +- apiGroups: [""] + # secrets are only needed for GitHub/GitLab interceptors + # configmaps is needed for updating logging config + resources: ["configmaps", "secrets"] + verbs: ["get", "list", "watch"] + # Permissions to create resources in associated TriggerTemplates +- apiGroups: ["tekton.dev"] + resources: ["pipelineruns", "pipelineresources", "taskruns"] + verbs: ["create"] +- apiGroups: [""] + resources: ["serviceaccounts"] + verbs: ["impersonate"] +- apiGroups: ["policy"] + resources: ["podsecuritypolicies"] + resourceNames: ["tekton-triggers"] + verbs: ["use"] \ No newline at end of file diff --git a/triggers/rbac/tekton-triggers-webhook.yaml b/triggers/rbac/tekton-triggers-webhook.yaml index c34d184..f9e75cf 100644 --- a/triggers/rbac/tekton-triggers-webhook.yaml +++ b/triggers/rbac/tekton-triggers-webhook.yaml @@ -2,7 +2,7 @@ kind: Role apiVersion: rbac.authorization.k8s.io/v1 metadata: - name: tekton-triggers-createwebhook + name: tt-createwebhook namespace: tektontutorial rules: - apiGroups: