Deploying an application to OpenShift
Prerequisites
-
You have installed OpenShift Pipelines using the OpenShift Pipeline Operator listed in the OpenShift OperatorHub. Once installed, it is applicable to the entire cluster.
-
You have installed the Tekton CLI
-
You have installed the CodeReady Containers (CRC) - a recommended solution for quick deployment of OpenShift clusters.
Procedure
-
Create a local CRC virtual machine:
$ crc start
If you use a hosted hypervisor, see the CRC documentation. crc start
output contains user login and password needed for logging into the cluster. -
Add the cached
oc
binary to your PATH:-
Run the crc oc-env command to print the command needed to add the cached oc binary to your PATH:
$ crc oc-env
-
Run the printed command.
-
-
Log into the OpenShift cluster with the provided login and password:
$ oc login -u <login> -p <password> https://api.crc.testing:6443
-
Create a project for the sample application:
$ oc new-project pipelines-tutorial
-
Building container images using build tools such as S2I, Buildah, or Kaniko, require privileged containers to access the cluster. The default security settings in OpenShift do not allow privileged containers. Create a service account for running
Pipeline
s and enable it to run privileged pods for building container images:$ oc create serviceaccount pipeline $ oc adm policy add-scc-to-user privileged -z pipeline $ oc adm policy add-role-to-user edit -z pipeline
-
Create the Kubernetes objects for deploying the PetClinic application on OpenShift:
$ oc create -f https://raw.githubusercontent.com/openshift/pipelines-tutorial/master/resources/petclinic.yaml
-
Navigate to Home → Projects → Status in the OpenShift Web Console to verify the deployment. The deployment at this stage is not complete. The
Pipeline
you create in the next steps builds the container images for the PetClinic application and completes the deployment.