Skip to content

redhat-developer-demos/tutorials-pipelines

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Istio and Knative Tutorial Pipelines

The Tekton Pipelines that can be used to deploy:

Pre-req

An OpenShift4 cluster with following components:

Create Tutorial Project in OpenShift

oc new-project tutorial && \
! oc create serviceaccount pipeline && \
oc adm policy add-scc-to-user privileged -z pipeline && \
oc adm policy add-role-to-user edit -z pipeline && \
oc adm policy add-scc-to-user privileged -z default && \
oc adm policy add-scc-to-user anyuid -z default && \
oc create -f https://raw.githubusercontent.com/redhat-developer-demos/tutorials-pipelines/pipelines-common/pipeline-role-sa.yaml
 -n tutorial && \
oc policy add-role-to-user pipeline-roles -z pipeline --role-namespace=tutorial

Deploy Nexus(Optional)

To make maven builds faster, we will deploy Sonatype Nexus

oc new-app sonatype/nexus

Tasks

Create the following Tekton tasks which will be used in the Pipelines

oc create -n tutorial \
  -f https://raw.githubusercontent.com/tektoncd/catalog/master/kn/kn.yaml

oc create -n tutorial \
-f https://raw.githubusercontent.com/tektoncd/catalog/master/openshift-client/openshift-client-task.yaml

oc create -n tutorial \
  -f https://raw.githubusercontent.com/redhat-developer-demos/knative-tutorial/master/06-pipelines/build-app-task.yaml

Check the tasks created

tkn task ls
NAME                AGE
NAME               AGE
build-app          3 seconds ago
kn                 5 seconds ago
openshift-client   4 seconds ago

Application Deployment

Download the sources

git clone https://github.com/redhat-developer-demos/tutorials-pipelines
cd tutorials-pipelines

Common

oc create -f pipelines-common/resources.yaml \
  -f pipelines-common/pipeline-deploy.yaml \ #(1)
  -f pipelines-common/pipeline-kn-deploy.yaml #(2)
  1. Pipeline used for vanilla Kubernetes/OpenShift deployment

  2. Pipeline used for serverless (knative) deployment

Customer

# create customer deployment config
oc create -f customer/app.yaml

# start the customer deploy pipeline
tkn pipeline start rhd-tutorial-deploy \
 --param="applicationSrcDir=customer" \
 --param="deploymentConfig=customer" \
 --param="mavenMirrorUrl=http://nexus:8081/nexus/content/groups/public" \
 --resource="app-git=git-source" \
 --resource="app-image=customer-openshift-image" \
 --serviceaccount='pipeline'

Watch the logs of pipeline run using the command

# get the running pipeline id
tkn pipelinerun ls
# get logs of the pipeline via
tkn pipelinerun logs -a -f <id-from-previous-command>

Preference

# create preference deployment config
oc create -f preference/app.yaml

# start preference deployment pipeline
tkn pipeline start rhd-tutorial-deploy \
 --param="applicationSrcDir=preference" \
 --param="deploymentConfig=preference" \
 --param="mavenMirrorUrl=http://nexus:8081/nexus/content/groups/public" \
 --resource="app-git=git-source" \
 --resource="app-image=preference-openshift-image" \
 --serviceaccount='pipeline'

Watch the logs of pipeline run using the command

# get the running pipeline id
tkn pipelinerun ls
# get logs of the pipeline via
tkn pipelinerun logs -a -f <id-from-previous-command>

Recommendation

Version 1

Vanilla OpenShift/Kubernetes Deployment

oc create -f recommendation/app-v1.yaml

tkn pipeline start rhd-tutorial-deploy \
 --param="applicationSrcDir=recommendation" \
 --param="deploymentConfig=recommendation" \
 --param="mavenMirrorUrl=http://nexus:8081/nexus/content/groups/public" \
 --resource="app-git=git-source" \
 --resource="app-image=recommendation-openshift-image-v1" \
 --serviceaccount='pipeline'

Knative Service Deployment

tkn pipeline start rhd-tutorial-kn-deploy \
 --param="applicationSrcDir=recommendation" \
 --param="mavenMirrorUrl=http://nexus:8081/nexus/content/groups/public" \
 --resource="app-git=git-source" \
 --resource="app-image=recommendation-openshift-image-v1" \
 --serviceaccount='pipeline'

Watch the logs of pipeline run using the command

# get the running pipeline id
tkn pipelinerun ls
# get logs of the pipeline via
tkn pipelinerun logs -a -f <id-from-previous-command>

Version 2

Vanilla OpenShift/Kubernetes Deployment

oc create -f recommendation/app-v2.yaml

tkn pipeline start rhd-tutorial-deploy \
 --param="applicationSrcDir=recommendation" \
 --param="deploymentConfig=recommendation" \
 --param="mavenMirrorUrl=http://nexus:8081/nexus/content/groups/public" \
 --resource="app-git=git-source-v2" \
 --resource="app-image=recommendation-openshift-image-v2" \
 --serviceaccount='pipeline'

Knative Service Deployment

tkn pipeline start rhd-tutorial-kn-deploy \
 --param="applicationSrcDir=recommendation" \
 --param="mavenMirrorUrl=http://nexus.rhd-workshop-infra:8081/nexus/content/groups/public" \
 --resource="app-git=git-source-v2" \
 --resource="app-image=recommendation-openshift-image-v2" \
 --serviceaccount='pipeline'

Watch the logs of pipeline run using the command

# get the running pipeline id
tkn pipelinerun ls
# get logs of the pipeline via
tkn pipelinerun logs -a -f <id-from-previous-command>

Knative

oc create -f greeter/pipeline-deploy.yaml \
  -f greeter/pipeline-run.yaml

Watch the logs of pipeline run using the command

# get the running pipeline id
tkn pipelinerun ls
# get logs of the pipeline via
tkn pipelinerun logs -a -f <id-from-previous-command>

Cleanup

  • Delete all pipeline runs

tkn pipelinerun ls | awk 'NR>1{print $1}' | xargs oc delete pipelinerun
  • Delete all pipelines

oc delete -f pipelines-commons/pipeline-deploy.yaml
  • Delete applications

oc delete -f recommendation/app-v1.yaml \
  -f recommendation/app-v2.yaml \
  -f preference/app.yaml \
  -f customer/app.yaml