Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update tekton101 for openshift #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 6 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
41 changes: 21 additions & 20 deletions docs/lab1/0_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -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=<us-south>
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=<advowork-labs>
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.
Expand All @@ -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 `<username>`.

```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=<us.icr.io>
$ export NAMESPACE=<username>

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 `<name>` with your first name.

```sh
NAME=<name>
```

For example,

```sh
$ NAME=oliver
$ ibmcloud cr namespace-add $NAMESPACE
```

## IBM Cloud Red Hat OpenShift Kubernetes Service (ROKS)
Expand All @@ -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

Expand All @@ -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 "<username>" 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
Expand Down
2 changes: 2 additions & 0 deletions docs/lab1/1_clone-git-repo.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
5 changes: 2 additions & 3 deletions docs/lab1/6_create-pipeline-run.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/<username>/picalc`. Run the following `sed` commands,

```bash
sed -i "s/<REGISTRY>/$REGISTRY_ROUTE/g" tekton/run/picalc-pipeline-run.yaml
sed -i "s/<NAMESPACE>/$NAMESPACE/g" tekton/run/picalc-pipeline-run.yaml
sed -i "s/<NAME>/$NAME/g" tekton/run/picalc-pipeline-run.yaml
sed -i "s/<NAME>/$NAMESPACE/g" tekton/run/picalc-pipeline-run.yaml

cat tekton/run/picalc-pipeline-run.yaml
```
Expand Down
15 changes: 5 additions & 10 deletions docs/lab1/7_run-the-pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <none> 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 <none> 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 <none> 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
```
Expand All @@ -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
Expand Down