GitHunt

= Istio and Knative Tutorial Pipelines

The https://tekton.dev[Tekton Pipelines] that can be used to deploy:

== Pre-req

An OpenShift4 cluster with following components:

== Create Tutorial Project in OpenShift

[source,bash]

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

[source,bash]

oc new-app sonatype/nexus

== Tasks

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

[source,bash]

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

[source,bash]

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

[source,bash]

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

== Common

[source,bash]

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

[source,bash]

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
[source,bash]

get the running pipeline id

tkn pipelinerun ls

get logs of the pipeline via

tkn pipelinerun logs -a -f

== Preference

[source,bash]

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

[source,bash]

get the running pipeline id

tkn pipelinerun ls

get logs of the pipeline via

tkn pipelinerun logs -a -f

== Recommendation

=== Version 1

==== Vanilla OpenShift/Kubernetes Deployment

[source,bash]

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

[source,bash]

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

[source,bash]

get the running pipeline id

tkn pipelinerun ls

get logs of the pipeline via

tkn pipelinerun logs -a -f

=== Version 2

==== Vanilla OpenShift/Kubernetes Deployment

[source,bash]

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

[source,bash]

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

[source,bash]

get the running pipeline id

tkn pipelinerun ls

get logs of the pipeline via

tkn pipelinerun logs -a -f

=== Knative

[source,bash]

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

Watch the logs of pipeline run using the command

[source,bash]

get the running pipeline id

tkn pipelinerun ls

get logs of the pipeline via

tkn pipelinerun logs -a -f

== Cleanup

  • Delete all pipeline runs
    [source,bash]

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

  • Delete all pipelines
    [source,bash]

oc delete -f pipelines-commons/pipeline-deploy.yaml

  • Delete applications
    [source,bash]

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

Languages

Java91.8%Dockerfile8.2%

Contributors

Created July 14, 2019
Updated August 19, 2022
redhat-developer-demos/tutorials-pipelines | GitHunt