Install Openshift CRC on your Laptop/Desktop/Workstation – RHEL8/RockyLinux8

0 / 113
Install openshift CRC on computer
Red Hat OpenShift is the Kubernetes platform from Red Hat, and it’s designed for the hybrid cloud. Red Hat CodeReady Containers (CRC) provides a minimal, preconfigured OpenShift 4 cluster on a laptop or desktop machine for development and testing purposes. CRC is delivered as a platform inside of the VM.


Red Hat OpenShift and Kubernetes are both container orchestration software, but Red Hat OpenShift is packaged as a downstream enterprise open source platform—meaning it’s undergone additional testing and contains additional features not available from the Kubernetes open source project.

Red Hat OpenShift and Kubernetes both manage groups of containers called clusters. Each cluster has 2 parts: a control plane and worker nodes. Containers run in the worker nodes, each of which has its own Linux operating system. The control plane maintains the cluster’s overall state while worker nodes do the actual computing work.

Pre-requisites:



  • 4 physical CPU cores

  • 9 GB of free memory

  • 35 GB of storage space

  • Pull secret



We will need “pull secret” when we start crc.

You can get pull secret from –

https://cloud.redhat.com/



No alt text provided for this image

Select Openshift > Clusters

No alt text provided for this image

Installation steps :

$ wget https://developers.redhat.com/content-gateway/rest/mirror/pub/openshift-v4/clients/crc/latest/crc-linux-amd64.tar.xz

$ tar xvf crc-linux-amd64.tar.xz

$ sudo cp crc /usr/local/bin/

$ crc setup

$ crc start -> when prompted enter pull secret

$ crc oc-env

$ export PATH="/home/prayag/.crc/bin/oc:$PATH"

$ echo 'export PATH="/home/prayag/.crc/bin/oc:$PATH"' >> .bashrc 

$ oc get all

$ oc get nodes

$ oc login -u kubeadmin -p 6EWtq-5qXX3-Sm3i8-Kr6Gq https://api.crc.testing:6443

$ oc login -u developer https://api.crc.testing:6443

Procedure: 

Download Openshift CRC

[prayag@localhost ~]$ wget https://developers.redhat.com/content-gateway/rest/mirror/pub/openshift-v4/clients/crc/latest/crc-linux-amd64.tar.xz

Extract crc

[prayag@localhost ~]$ tar xvf crc-linux-amd64.tar.zx

crc-linux-2.2.2-amd64/
crc-linux-2.2.2-amd64/LICENSE
crc-linux-2.2.2-amd64/crc

Copy crc binary to /usr/local/bin

[prayag@localhost ~]$ cd crc-linux-2.2.2-amd64

[prayag@localhost crc-linux-2.2.2-amd64]$ sudo cp crc /usr/local/bin/

[prayag@localhost crc-linux-2.2.2-amd64]$ cd

[prayag@localhost ~]$ which crc

/usr/local/bin/crc/

Get crc version

[prayag@localhost ~]$ crc version

CRC version: 2.2.2+f1e1d3e
OpenShift version: 4.10.9
Podman version: 3.4.4

[prayag@localhost ~]$ which crc

/usr/local/bin/crc

Run crc setup

[prayag@localhost ~]$ crc setup

CRC is constantly improving and we would like to know more about usage (more details at https://developers.redhat.com/article/tool-data-collection)

Your preference can be changed manually if desired using 'crc config set consent-telemetry <yes/no>'

Would you like to contribute anonymous usage statistics? [y/N]: y

Thanks for helping us! You can disable telemetry with the command 'crc config set consent-telemetry no'.

INFO Using bundle path /home/prayag/.crc/cache/crc_libvirt_4.10.9_amd64.crcbundle

INFO Checking if running as non-root              

INFO Checking if running inside WSL2              

INFO Checking if crc-admin-helper executable is cached

INFO Caching crc-admin-helper executable          

INFO Using root access: Changing ownership of /home/prayag/.crc/bin/crc-admin-helper-linux

INFO Using root access: Setting suid for /home/prayag/.crc/bin/crc-admin-helper-linux

INFO Checking for obsolete admin-helper executable

INFO Checking if running on a supported CPU architecture

INFO Checking minimum RAM requirements            

INFO Checking if crc executable symlink exists    

INFO Creating symlink for crc executable          

INFO Checking if Virtualization is enabled        

INFO Checking if KVM is enabled                  

INFO Checking if libvirt is installed            

INFO Installing libvirt service and dependencies  

INFO Using root access: Installing virtualization packages

INFO Checking if user is part of libvirt group    

INFO Adding user to libvirt group                

INFO Using root access: Adding user to the libvirt group

INFO Checking if active user/process is currently part of the libvirt group

INFO Checking if libvirt daemon is running        

INFO Checking if a supported libvirt version is installed

INFO Checking if crc-driver-libvirt is installed  

INFO Installing crc-driver-libvirt                

INFO Checking if systemd-networkd is running      

INFO Checking if NetworkManager is installed      

INFO Checking if NetworkManager service is running

INFO Checking if /etc/NetworkManager/conf.d/crc-nm-dnsmasq.conf exists

INFO Writing Network Manager config for crc      

INFO Using root access: Writing NetworkManager configuration to /etc/NetworkManager/conf.d/crc-nm-dnsmasq.conf

INFO Using root access: Changing permissions for /etc/NetworkManager/conf.d/crc-nm-dnsmasq.conf to 644  

INFO Using root access: Executing systemctl daemon-reload command

INFO Using root access: Executing systemctl reload NetworkManager

INFO Checking if /etc/NetworkManager/dnsmasq.d/crc.conf exists

INFO Writing dnsmasq config for crc              

INFO Using root access: Writing NetworkManager configuration to /etc/NetworkManager/dnsmasq.d/crc.conf

INFO Using root access: Changing permissions for /etc/NetworkManager/dnsmasq.d/crc.conf to 644  

INFO Using root access: Executing systemctl daemon-reload command

INFO Using root access: Executing systemctl reload NetworkManager

INFO Checking if libvirt 'crc' network is available

INFO Setting up libvirt 'crc' network            

INFO Checking if libvirt 'crc' network is active  

INFO Starting libvirt 'crc' network              

INFO Checking if CRC bundle is extracted in '$HOME/.crc'

INFO Checking if /home/prayag/.crc/cache/crc_libvirt_4.10.9_amd64.crcbundle exists

INFO Getting bundle for the CRC executable        

INFO Downloading crc_libvirt_4.10.9_amd64.crcbundle

3.15 GiB / 3.15 GiB [-----------------------------------------------------------------------------------------------------------------------------] 100.00% 10.31 MiB p/s

INFO Uncompressing /home/prayag/.crc/cache/crc_libvirt_4.10.9_amd64.crcbundle

crc.qcow2: 12.93 GiB / 12.93 GiB [------------------------------------------------------------------------------------------------------------------------------] 100.00%

oc: 117.14 MiB / 117.14 MiB [-----------------------------------------------------------------------------------------------------------------------------------] 100.00%

Your system is correctly setup for using CRC. Use 'crc start' to start the instance

Start CRC and when prompted enter pull secret

[prayag@localhost ~]$ crc start

INFO Checking if running as non-root              

INFO Checking if running inside WSL2              

INFO Checking if crc-admin-helper executable is cached

INFO Checking for obsolete admin-helper executable

INFO Checking if running on a supported CPU architecture

INFO Checking minimum RAM requirements            

INFO Checking if crc executable symlink exists    

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 active user/process is currently part of the libvirt group

INFO Checking if libvirt daemon is running        

INFO Checking if a supported libvirt version is installed

INFO Checking if crc-driver-libvirt is installed  

INFO Checking if systemd-networkd is running      

INFO Checking if NetworkManager is installed      

INFO Checking if NetworkManager service is running

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 libvirt 'crc' network is available

INFO Checking if libvirt 'crc' network is active  

INFO Loading bundle: crc_libvirt_4.10.9_amd64...  

CRC requires a pull secret to download content from Red Hat.

You can copy it from the Pull Secret section of https://cloud.redhat.com/openshift/create/local.

? Please enter the pull secret ******************************************************************************************************************************************

WARN Cannot add pull secret to keyring: failed to unlock correct collection '/org/freedesktop/secrets/aliases/default'

INFO Creating CRC VM for OpenShift 4.10.9...      

INFO Generating new SSH Key pair...              

INFO Generating new password for the kubeadmin user

INFO Starting CRC VM for OpenShift 4.10.9...      

INFO CRC instance is running with IP 192.168.130.11

INFO CRC VM is running                            

INFO Updating authorized keys...                  

INFO Check internal and public DNS query...      

INFO Check DNS query from host...                

INFO Verifying validity of the kubelet certificates...

INFO Starting OpenShift kubelet service          

INFO Waiting for kube-apiserver availability... [takes around 2min]

INFO Adding user's pull secret to the cluster...  

INFO Updating SSH key to machine config resource...

INFO Waiting for user's pull secret part of instance disk...

INFO Changing the password for the kubeadmin user

INFO Updating cluster ID...                      

INFO Updating root CA cert to admin-kubeconfig-client-ca configmap...

INFO Starting OpenShift cluster... [waiting for the cluster to stabilize]

[INFO 4 operators are progressing: image-registry, network, openshift-controller-manager, service-ca

INFO 2 operators are progressing: image-registry, openshift-controller-manager

INFO Operator openshift-controller-manager is progressing

INFO Operator openshift-controller-manager is progressing

INFO Operator openshift-controller-manager is progressing

INFO Operator openshift-controller-manager is progressing

INFO Operator openshift-controller-manager is progressing

INFO All operators are available. Ensuring stability...

INFO Operators are stable (2/3)...                

INFO Operators are stable (3/3)...                

INFO Adding crc-admin and crc-developer contexts to kubeconfig...

Started the OpenShift cluster.

The server is accessible via web console at:

  https://console-openshift-console.apps-crc.testing

 Log in as administrator:

  Username: kubeadmin

  Password: 6EWtq-5qXX3-Sm3i8-Kr6Gq

Log in as user:

  Username: developer

  Password: developer

 Use the 'oc' command line interface:

  $ eval $(crc oc-env)

  $ oc login -u developer https://api.crc.testing:6443t

Set oc path

[prayag@localhost ~]$ crc oc-env

export PATH="/home/prayag/.crc/bin/oc:$PATH"

# Run this command to configure your shell:

# eval $(crc oc-env)

[prayag@localhost ~]$  'export PATH="/home/prayag/.crc/bin/oc:$PATH"

[prayag@localhost ~]$ echo 'export PATH="/home/prayag/.crc/bin/oc:$PATH"' >> .bashrc 

[prayag@localhost ~]$ which oc

~/.crc/bin/oc/oc

Login as kubeadmin

[prayag@localhost ~]$ oc login -u kubeadmin -p 6EWtq-5qXX3-Sm3i8-Kr6Gq https://api.crc.testing:644

[prayag@localhost ~]$ oc get all

NAME                 TYPE           CLUSTER-IP   EXTERNAL-IP                            PORT(S)   AGE

service/kubernetes   ClusterIP      10.217.4.1   <none>                                 443/TCP   15d

service/openshift    ExternalName   <none>       kubernetes.default.svc.cluster.local   <none>    15d

[prayag@localhost ~]$ oc get nodes

NAME                 STATUS   ROLES           AGE   VERSION

crc-gh9wd-master-0   Ready    master,worker   15d   v1.23.5+9ce5071

[prayag@localhost ~]$ oc get nodes -o wide

NAME                 STATUS   ROLES           AGE   VERSION           INTERNAL-IP      EXTERNAL-IP   OS-IMAGE                                                        KERNEL-VERSION                 CONTAINER-RUNTIME

crc-gh9wd-master-0   Ready    master,worker   15d   v1.23.5+9ce5071   192.168.126.11   <none>        Red Hat Enterprise Linux CoreOS 410.84.202204050541-0 (Ootpa)   4.18.0-305.40.2.el8_4.x86_64   cri-o://1.23.2-4.rhaos4.10.git9ef73d4.el8

[prayag@localhost ~]$ 3

Login as developer

[prayag@localhost ~]$ oc login -u developer https://api.crc.testing:6443
Logged into "https://api.crc.testing:6443" as "developer" using existing credentials.


You don't have any projects. You can try to create a new project, by running


    oc new-project <projectname>


[prayag@localhost ~]$

Create new project and new app

[prayag@localhost ~]$ oc new-project web-app
Now using project "web-app" on server "https://api.crc.testing:6443".


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/e2e-test-images/agnhost:2.33 -- /agnhost serve-hostname


[prayag@localhost ~]$ oc new-app --template=openshift/nginx-example --name=nginx-app --param=NAME=nginx-app
warning: Cannot find git. Ensure that it is installed and in your path. Git is required to work with git repositories.
--> Deploying template "openshift/nginx-example" for "openshift/nginx-example" to project web-app


     Nginx HTTP server and a reverse proxy
     ---------
     An example Nginx HTTP server and a reverse proxy (nginx) application that serves static content. For more information about using this template, including OpenShift considerations, see https://github.com/sclorg/nginx-ex/blob/master/README.md.


     The following service(s) have been created in your project: nginx-app.
     
     For more information about using this template, including OpenShift considerations, see https://github.com/sclorg/nginx-ex/blob/master/README.md.


     * With parameters:
        * Name=nginx-app
        * Namespace=openshift
        * NGINX Version=1.20-el8
        * Memory Limit=512Mi
        * Git Repository URL=https://github.com/sclorg/nginx-ex.git
        * Git Reference=
        * Context Directory=
        * Application Hostname=
        * GitHub Webhook Secret=dgayUGGJpLFpGutnfQy8xT3uLJhdwdvvH81uHxHY # generated
        * Generic Webhook Secret=pYQHjlkD6TSFgUHnxYAIfmt7Nk34ojbtkYXygnQd # generated


--> Creating resources ...
    service "nginx-app" created
    route.route.openshift.io "nginx-app" created
    imagestream.image.openshift.io "nginx-app" created
    buildconfig.build.openshift.io "nginx-app" created
    deploymentconfig.apps.openshift.io "nginx-app" created
--> Success
    Access your application via route 'nginx-app-web-app.apps-crc.testing' 
    Build scheduled, use 'oc logs -f buildconfig/nginx-app' to track its progress.
    Run 'oc status' to view your app.
[prayag@localhost ~]$ oc status
In project web-app on server https://api.crc.testing:6443


http://nginx-app-web-app.apps-crc.testing (svc/nginx-app)
  dc/nginx-app deploys istag/nginx-app:latest <-
    bc/nginx-app source builds https://github.com/sclorg/nginx-ex.git on openshift/nginx:1.20-el8 
      not built yet
    deployment #1 waiting on image or update

Get service and route details

[prayag@localhost ~]$ oc get svc
NAME        TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)    AGE
nginx-app   ClusterIP   10.217.5.137   <none>        8080/TCP   39s

[prayag@localhost ~]$ oc get route nginx-app
NAME        HOST/PORT                            PATH   SERVICES    PORT    TERMINATION   WILDCARD
nginx-app   nginx-app-web-app.apps-crc.testing          nginx-app   <all>  
 
              None
[prayag@localhost ~]$ curl nginx-app-web-app.apps-crc.testing
<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1">


    <style type="text/css">
      body {
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
        line-height: 1.66666667;
        font-size: 16px;
        color: #333;
        background-color: #fff;
        margin: 2em 1em;
      }
      h1 {
        font-size: 28px;
        font-weight: 400;
      }
      p {
        margin: 0 0 10px;
      }
      .alert.alert-info {
        background-color: #F0F0F0;
        margin-top: 30px;
        padding: 30px;
      }
      .alert p {
        padding-left: 35px;
      }
      ul {
        padding-left: 51px;
        position: relative;
      }
      li {
        font-size: 14px;
        margin-bottom: 1em;
      }
      p.info {
        position: relative;
        font-size: 20px;
      }
      p.info:before, p.info:after {
        content: "";
        left: 0;
        position: absolute;
        top: 0;
      }
      p.info:before {
        background: #0066CC;
        border-radius: 16px;
        color: #fff;
        content: "i";
        font: bold 16px/24px serif;
        height: 24px;
        left: 0px;
        text-align: center;
        top: 4px;
        width: 24px;
      }


      @media (min-width: 768px) {
        body {
          margin: 6em;
        }
      }
    </style>
  </head>
  <body>
    <div>
      <h1>Application is not available</h1>
      <p>The application is currently not serving requests at this endpoint. It may not have been started or is still starting.</p>


      <div class="alert alert-info">
        <p class="info">
          Possible reasons you are seeing this page:
        </p>
        <ul>
          <li>
            <strong>The host doesn't exist.</strong>
            Make sure the hostname was typed correctly and that a route matching this hostname exists.
          </li>
          <li>
            <strong>The host exists, but doesn't have a matching path.</strong>
            Check if the URL path was typed correctly and that the route was created using the desired path.
          </li>
          <li>
            <strong>Route and path matches, but all pods are down.</strong>
            Make sure that the resources exposed by this route (pods, services, deployment configs, etc) have at least one pod running.
          </li>
        </ul>
      </div>
    </div>
  </body>
</html>
[prayag@localhost ~]$

I hope you found this article to be useful in some way. I’ll be back with some more interesting new DevOps articles soon.

Comments

comments


***Linux, Cloud & Devops Architect & Technical Content Writer*** I am a Linux Enthusiast and Supporter/Promoter of Open Source Technology with over 12+ years of experience in Linux, Cloud and Devops. I am A Technical Content writer for various sites like : Hostbread & Golibrary

Related Posts