diff --git a/.gitignore b/.gitignore index f513c31..de58c9e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ docs/lab1/5_create-service-account copy.md docs/tmp1.md +docs/extra/ tekton_pipeline_roadmap.png tekton_pipeline_roadmap_matt_rutkowski.png tekton_pipeline_roadmap_tekton_and_security.png diff --git a/docs/README.md b/docs/README.md index 89c3e34..043dfc2 100644 --- a/docs/README.md +++ b/docs/README.md @@ -14,6 +14,12 @@ Tekton is an open source project to configure and run CI/CD pipelines within a O | 5. Scan Running Containers in OpenShift | lab5 (coming soon) | | 6. Governance, Risk and Compliance (GRC) using Security and Compliance Center (SCC) | lab6 (coming soon) | +### Extra + +| Module | Description | +| ----------- | ------------------------------------ | +| Extra 1: Create a Basic Pipeline using Tekton on Kubernetes | [extra1](extra/lab1/1_clone-git-repo.md) | + ## Introduction In this learning path you learn: diff --git a/docs/lab1/0_setup.md b/docs/lab1/0_setup.md index 504685d..07f5f19 100644 --- a/docs/lab1/0_setup.md +++ b/docs/lab1/0_setup.md @@ -24,10 +24,19 @@ In your IBM Cloud account, open a new instance of [IBM Cloud Shell](https://clou Target the same region as your OpenShift cluster. In this tutorial, I am using a cluster in the region `us-south`. ```bash -REGION=us-south +export REGION= ibmcloud target -r $REGION ``` +## Target a Resource Group + +Target the same resource group as your OpenShift cluster. In this tutorial, I am using a cluster in the resource group `advowork-labs`. + +```bash +export RESOURCE_GROUP= +ibmcloud target -r $RESOURCE_GROUP +``` + ## Git repository containing Tekton resources Clone the source code for this workshop to your client terminal in order to edit some of the yaml files before applying them to your cluster. Change into the directory containing the resources. @@ -54,27 +63,19 @@ Registry API endpoint https://us.icr.io/api OK ``` -Create environment variables for the registry route and a namespace in your registry. Both variables will be used in the rest of the workshop. Create the registry namespace. +Create environment variables for the registry route and a namespace in your registry. Both variables will be used in the rest of the workshop. You can use an existing namespace or create a new registry namespace. + +Since everybody in the lab will be pushing to the same namespace in the registry, we need a way to differentiate each other's images. Add a username to the image tag. In the following command, substitute ``. ```bash $ ibmcloud cr namespace-list Listing namespaces for account 'IBM Client Developer Advocacy' in registry 'us.icr.io'... ... -REGISTRY_ROUTE=us.icr.io -NAMESPACE=advowork -``` +$ export REGISTRY_ROUTE= +$ export NAMESPACE= -Since everybody in the lab will be pushing to the same namespace in the registry, we need a way to differentiate each other's images. We can do this by adding your name to the image tag. In the following command, substitute `` with your first name. - -```sh -NAME= -``` - -For example, - -```sh -$ NAME=oliver +$ ibmcloud cr namespace-add $NAMESPACE ``` ## IBM Cloud Red Hat OpenShift Kubernetes Service (ROKS) @@ -85,7 +86,7 @@ Connect to your OpenShift cluster from the terminal using the login command from oc login --token=sha256~ZBMKw9VAayhdnyANaHvjJeXDiGwA7Fsr5gtLKj3-ehE --server=https://d107-f.us-south.containers.cloud.ibm.com:30271 ``` -If you need to retrieve the login command, follow [these instructions](https://ibm.github.io/workshop-setup/ROKS/). +If you need to retrieve the login command or if you need an alternative method to login, follow [these instructions](https://ibm.github.io/workshop-setup/ROKS/). ## OpenShift Pipelines @@ -110,19 +111,19 @@ Optional: You can also install OpenShift Pipelines through the OpenShift Console Create a new project or namespace, you can use the same name as for the container registry, though they are not related. ```bash -$ oc new-project tekton101lab +$ oc new-project $NAMESPACE -Now using project "tekton101lab" on server "https://d107-f.us-south.containers.cloud.ibm.com:30271". +Now using project "" on server "https://d107-f.us-south.containers.cloud.ibm.com:30271". You can add applications to this project with the 'new-app' command. For example, try: oc new-app rails-postgresql-example to build a new example application in Ruby. Or use kubectl to deploy a simple Kubernetes application: kubectl create deployment hello-node --image=k8s.gcr.io/serve_hostname ``` -Or change the current project to `tekton101lab`, +Or change the current project, ```bash -oc project tekton101lab +oc project $NAMESPACE ``` ## Next diff --git a/docs/lab1/1_clone-git-repo.md b/docs/lab1/1_clone-git-repo.md index f18affa..3f0fb6d 100644 --- a/docs/lab1/1_clone-git-repo.md +++ b/docs/lab1/1_clone-git-repo.md @@ -169,9 +169,11 @@ Though the task has been defined and is available from the Tekton Hub, you still ```bash $ oc apply -f https://raw.githubusercontent.com/tektoncd/catalog/main/task/git-clone/0.3/git-clone.yaml + task.tekton.dev/git-clone created $ oc get tasks + NAME AGE git-clone 3m9s ``` diff --git a/docs/lab1/6_create-pipeline-run.md b/docs/lab1/6_create-pipeline-run.md index b582d7b..f64d8f0 100644 --- a/docs/lab1/6_create-pipeline-run.md +++ b/docs/lab1/6_create-pipeline-run.md @@ -41,15 +41,14 @@ Check the values for `REGISTRY_ROUTE` and `NAMESPACE` are set. ```bash echo $REGISTRY_ROUTE echo $NAMESPACE -echo $NAME ``` -This should set the `imageUrl` to `us.icr.io/tekton101lab/picalc`. Run the following `sed` commands, +This should set the `imageUrl` to `us.icr.io//picalc`. Run the following `sed` commands, ```bash sed -i "s//$REGISTRY_ROUTE/g" tekton/run/picalc-pipeline-run.yaml sed -i "s//$NAMESPACE/g" tekton/run/picalc-pipeline-run.yaml -sed -i "s//$NAME/g" tekton/run/picalc-pipeline-run.yaml +sed -i "s//$NAMESPACE/g" tekton/run/picalc-pipeline-run.yaml cat tekton/run/picalc-pipeline-run.yaml ``` diff --git a/docs/lab1/7_run-the-pipeline.md b/docs/lab1/7_run-the-pipeline.md index 8e5d6d9..60ee85d 100644 --- a/docs/lab1/7_run-the-pipeline.md +++ b/docs/lab1/7_run-the-pipeline.md @@ -38,17 +38,12 @@ First display the nodes and choose one of the node's external IP addresses. Then display the service to get its NodePort. ```bash -$ kubectl get nodes -o wide -NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME -10.221.22.11 Ready 7d23h v1.16.8+IKS 10.221.22.11 150.238.236.26 Ubuntu 18.04.4 LTS 4.15.0-96-generic containerd://1.3.3 -10.221.22.49 Ready 7d23h v1.16.8+IKS 10.221.22.49 150.238.236.21 Ubuntu 18.04.4 LTS 4.15.0-96-generic containerd://1.3.3 +EXTERNAL_IP=$(oc get nodes -o wide -o json | jq -r '.items[0].status.addresses | .[] | select( .type=="ExternalIP" ) | .address ') +echo $EXTERNAL_IP -$ kubectl get svc picalc -NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE -picalc NodePort 172.21.199.71 8080:30925/TCP 9m +NODE_PORT=$(oc get svc picalc -n $NAMESPACE --output json | jq -r '.spec.ports[0].nodePort' ) +echo $NODE_PORT -$ EXTERNAL_IP=150.238.236.26 -$ NODE_PORT=30925 $ curl $EXTERNAL_IP:$NODE_PORT?iterations=20000000 3.1415926036 ``` @@ -60,7 +55,7 @@ Edit the PipelineRun yaml and change the gitUrl parameter to a non-existent Git Then create a new PipelineRun and describe it after letting it run for a minute or two. ```bash -$ kubectl create -f tekton/picalc-pipeline-run.yaml +$ oc create -f tekton/run/picalc-pipeline-run.yaml pipelinerun.tekton.dev/picalc-pr-sk7md created $ tkn pipelinerun describe picalc-pr-sk7md