Obsolete ⇒ go to https://github.com/marcredhat/crcdemos/blob/master/crc_agnosticd_opendatahub_on_rhel81.adoc
Draft lab guide showing how to set up CodeReady Containers, deploy apps and Tekton Pipelines, configure persistent storage and more
Red Hat CodeReady Containers brings a minimal OpenShift 4.1 or newer cluster to your local computer (see https://code-ready.github.io/crc/)
The instructions below cover
-
installing Red Hat CodeReady Containers on a physical RHEL 7.6 server and
-
configuring SSH tunneling / port forwarding to access the OpenShift console from your laptop.
[root@dell-r730-019 ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.6 (Maipo)
su -c 'yum install qemu-kvm libvirt NetworkManager'
sudo systemctl start libvirtd
sudo systemctl enable libvirtd
cd /home/marc
tar -xzf go1.12.9.linux-amd64.tar.gz
Add to .bashrc:
export GOROOT=/home/marc/go export GOPATH=/home/marc/work export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
source .bashrc
su marc
cd /home/marc
cd crc
make
Set the memory available to CRC according to what you have on your physical server
I’m on a physical server with around 100G of memory so I allocate 80G to CRC as follows:
[marc@dell-r730-019 ansible]$ crc config set memory 81920
[marc@dell-r730-019 crc]$ crc setup
INFO Caching oc binary INFO Setting up virtualization INFO Setting up KVM INFO Installing libvirt service and dependencies INFO Adding user to libvirt group INFO Enabling libvirt INFO Starting libvirt service INFO Installing crc-driver-libvirt INFO Removing older system-wide crc-driver-libvirt INFO Setting up libvirt 'crc' network INFO Starting libvirt 'crc' network INFO Writing Network Manager config for crc INFO Writing dnsmasq config for crc INFO Unpacking bundle from the CRC binary WARN CRC bundle is not embedded in the binary, see 'crc help' for more details.
Download from https://github.com/code-ready/crc/releases
(crc_libvirt_4.1.9.crcbundle in my case)
You’ll need your pull secret from https://cloud.redhat.com/openshift/install/metal/user-provisioned
[marc@dell-r730-019 crc]$ crc start -b crc_libvirt_4.1.9.crcbundle
INFO Checking if oc binary is cached INFO Checking if Virtualization is enabled INFO Checking if KVM is enabled INFO Checking if libvirt is installed INFO Checking if user is part of libvirt group INFO Checking if libvirt is enabled INFO Checking if libvirt daemon is running INFO Checking if crc-driver-libvirt is installed INFO Checking if libvirt 'crc' network is available INFO Checking if libvirt 'crc' network is active INFO Checking if /etc/NetworkManager/conf.d/crc-nm-dnsmasq.conf exists INFO Checking if /etc/NetworkManager/dnsmasq.d/crc.conf exists INFO Checking if CRC bundle is cached in '$HOME/.cr INFO Creating VM ... INFO Verifying validity of the cluster certificates ... INFO Check internal and public dns query ... INFO Copying kubeconfig file to instance dir ... INFO Adding user's pull secret and cluster ID ... INFO Starting OpenShift cluster ... [waiting 3m] INFO To access the cluster using 'oc', run 'eval $(crc oc-env) && oc login -u kubeadmin -p <password> https://api.crc.testing:6443' INFO Access the OpenShift web-console here: https://console-openshift-console.apps-crc.testing INFO Login to the console with user: kubeadmin, password: <password> CodeReady Containers instance is running
cd /home/marc/crc
eval $(crc oc-env) && oc login -u kubeadmin -p <password> https://api.crc.testing:6443
On your laptop, /etc/hosts example:
127.0.0.1 localhost console-openshift-console.apps-crc.testing oauth-openshift.apps-crc.testing
sudo ssh marc@dell-r730-019…. -L 443:console-openshift-console.apps-crc.testing:443
You can now access the OpenShift console from your laptop at https://console-openshift-console.apps-crc.testing
oc new-project app-management
oc new-app quay.io/thoraxe/mapit
oc expose service mapit
On your laptop, add mapit-app-management.apps-crc.testing to /etc/hosts.
Example: 127.0.0.1 localhost marc.rhel8 console-openshift-console.apps-crc.testing oauth-openshift.apps-crc.testing mapit-app-management.apps-crc.testing
On your laptop, sudo ssh marc@dell-r730-019… -L 80:mapit-app-management.apps-crc.testing:80
On your laptop, browse to http://mapit-app-management.apps-crc.testing
set volume dc/mapit --add --name=mapit-storage -t pvc --claim-mode=ReadWriteOnce --claim-size=1Gi --claim-name=mapit-storage --mount-path=/app-storage
oc rsh mapit-… cat /app-storage/hello.txt
Now, to verify that persistent storage really works, delete your pod:
oc delete pod mapit-… && oc get pod
After some time, your new pod will be ready and running. Find its name, and again check the file:
oc rsh mapit… cat /app-storage/hello.txt
Install Tekton CLI; ensure you get the latest release.
wget https://github.com/tektoncd/cli/releases/download/v0.2.2/tkn_0.2.2_Linux_x86_64.tar.gz tar -xvzf tkn_0.2.2_Linux_x86_64.tar.gz sudo cp ./tkn /usr/local/bin/
cd /home/marc/crc
eval $(crc oc-env) && oc login -u kubeadmin -p <password> https://api.crc.testing:6443
oc new-project tekton-pipelines
oc adm policy add-scc-to-user anyuid -z tekton-pipelines-controller
oc apply --filename https://storage.googleapis.com/tekton-releases/latest/release.yaml
You should see:
[marc@dell-r730-019 crc]$ oc get pods
NAME READY STATUS RESTARTS AGE tekton-pipelines-controller-55c6b5b9f6-hcxb2 1/1 Running 0 26s tekton-pipelines-webhook-6794d5bcc8-bqcc5 1/1 Running 0 26s
(fork of https://github.com/siamaksade/openshift-pipelines-examples with minor fix for siamaksade/pipelines-examples#1)
cd openshift-pipelines-examples
Follow the instructions at https://github.com/marcredhat/openshift-pipelines-examples
You should see:
[marc@dell-r730-019 openshift-pipelines-examples]$ oc project
Using project "pipeline-demo" on server "https://api.crc.testing:6443"
[marc@dell-r730-019 openshift-pipelines-examples]$ oc get pods
NAME READY STATUS RESTARTS AGE mapit-build-pipelinerun-jgbtj-build-app-lnfbh-pod-5cdefc 0/5 Completed 0 3m21s mapit-build-pipelinerun-jgbtj-build-image-tbsd5-pod-415e23 0/6 Completed 0 2m16s mapit-deploy-pipelinerun-bwxgr-analyse-code-sxw9n-pod-2bd948 0/4 Completed 0 2m9s mapit-deploy-pipelinerun-bwxgr-build-app-kvpxt-pod-0ed8c1 0/5 Completed 0 3m11s mapit-deploy-pipelinerun-bwxgr-build-image-8d6ss-pod-06cd2a 0/6 Completed 0 99s mapit-deploy-pipelinerun-bwxgr-deploy-t7jwb-pod-a1000a 0/1 Completed 0 39s mapit-spring-1-deploy 1/1 Running 0 26s mapit-spring-1-m56sl 1/1 Running 0 16s
[marc@dell-r730-019 openshift-pipelines-examples]$ oc describe pipelinerun
Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Succeeded 2m45s pipeline-controller All Tasks have completed executing
[marc@dell-r730-019 openshift-pipelines-examples]$ tkn task ls
NAME AGE buildah 10 minutes ago mvn-build 8 minutes ago openshift-client 10 minutes ago static-analysis 8 minutes ago
"oc get ev" comes in handy if you want to see the various steps in detail.
[marc@dell-r730-019 openshift-pipelines-examples]$ oc get route
NAME HOST/PORT PATH SERVICES PORT TERMINATION WILDCARD mapit-spring mapit-spring-pipeline-demo.apps-crc.testing mapit-spring 8080-tcp None
On your laptop, add mapit-spring-pipeline-demo.apps-crc.testing to /etc/hosts.
Example: 127.0.0.1 localhost marc.rhel8 console-openshift-console.apps-crc.testing oauth-openshift.apps-crc.testing mapit-app-management.apps-crc.testing mapit-spring-pipeline-demo.apps-crc.testing
On your laptop, sudo ssh marc@dell-r730-019… -L 80:mapit-spring-pipeline-demo.apps-crc.testing:80
On your laptop, browse to http://mapit-spring-pipeline-demo.apps-crc.testing