Hands-on Labs with Red Hat Code Ready Container:
Reference: Red Hat CRC reference (How to do)
Hands On Labs:
1. Learn and experiment HTPasswd Lab
2. Deploy your nginx operator Lab
3. Deploy Jenkins Operators Lab
4. Deploy OpenShift Compliance Opeator Lab
5. Explore OpenShift Admin Console
6. Top 100 OpenShift CLI commands Lab
What can you do with CRC?
- Installation and Setup
- Create a Simple Web Application
- Container Basics
- Multi-Container Applications
- Persistent Storage
- Networking in Code Ready Containers
- Resource Management
- Scaling Applications
- Service Discovery
- Security Practices
- Continuous Integration and Deployment
- Rolling Updates
- Fault Tolerance
- Monitoring and Logging
- Customizing Base Images
- Secrets and Configuration Management
- Integration with External Services
- Load Balancing
- Container Orchestration
- CI/CD Integration with Jenkins
- Database Containers
- Ingress Controllers
- Health Checks
- Container Image Vulnerability Scanning
- Distributed Tracing
- Serverless Containers
- Multi-Environment Deployment
- GitOps Practices
- Automated Testing in Containers
- Explore Operator Framework
CRC Specific Commands:
openshift-crc-hands-on-labsCRC Specific Commands:
crc setup – Set up the hypervisor and install the necessary components.
crc start – Start the CodeReady Containers virtual machine.
crc stop – Stop the CodeReady Containers virtual machine.
crc delete – Delete the CodeReady Containers virtual machine.
crc status – Display the status of the CRC VM.
crc config set cpus 4 – Set the number of CPUs for CRC VM.
crc config set memory 8192 – Set the memory allocation for CRC VM.
crc config view – View the current configuration settings.
crc console – Open the OpenShift web console in the default browser.
crc oc-env – Display command to set up the oc environment.
OpenShift CLI (oc) Commands:
oc login -u developer – Log in as a developer.
oc login -u kubeadmin – Log in as the admin user.
oc new-project myproject – Create a new project.
oc get projects – List all projects.
oc project myproject – Switch to a specific project.
oc get pods – Get all pods in the current namespace.
oc create -f pod.yaml – Create a resource from a YAML file.
oc apply -f deployment.yaml – Apply a configuration to a resource.
oc delete pod mypod – Delete a specific pod.
oc scale –replicas=3 deployment/myapp – Scale a deployment.
Working with Applications
oc new-app –docker-image=myimage – Create a new app from a Docker image.
oc expose svc/myapp – Expose a service as a route.
oc get routes – Get all the routes.
oc logs pod/mypod – Get logs for a specific pod.
oc exec -it mypod — bash – Execute a command in a container.
oc set env deployment/myapp ENV_VAR=value – Set an environment variable for a deployment.
oc rollout status deployment/myapp – Watch the status of the latest rollout.
oc rollout history deployment/myapp – Check the history of rollouts.
oc rollout undo deployment/myapp – Rollback to the previous deployment.
oc describe pod/mypod – Describe detailed information about a pod.
Resource Management
oc get svc – Get all services.
oc get deployments – Get all deployments.
oc get rs – Get all ReplicaSets.
oc get nodes – Get all nodes.
oc get namespaces – Get all namespaces.
oc get events – Get events in the current namespace.
oc label pods mypod key=value – Add a label to a pod.
oc annotate pods mypod key=value – Add an annotation to a pod.
oc edit pod mypod – Edit a pod configuration.
oc patch pod mypod -p ‘{“metadata”:{“labels”:{“key”:”value”}}}’ – Patch a pod.
Networking and Security
oc get networkpolicy – List all network policies.
oc create serviceaccount mysa – Create a new service account.
oc policy add-role-to-user edit user1 – Add a role to a user.
oc adm policy add-scc-to-user privileged -z mysa – Add SCC to a service account.
oc get secrets – List all secrets.
oc create secret generic mysecret –from-literal=key1=value1 – Create a new secret.
oc secrets link default mysecret –for=pull – Link secrets to a service account.
oc adm top pods – Show metrics for pods.
oc adm top nodes – Show metrics for nodes.
oc adm node-logs node1 – Get logs from a specific node.
Advanced Operations
oc adm drain node1 – Prepare a node for maintenance.
oc adm uncordon node1 – Mark node as schedulable.
oc adm manage-node node1 –list-pods – List pods on a specific node.
oc adm manage-node node1 –evacuate – Evacuate pods
Hands On Labs:
1. Setting Up CodeReady Containers
- Objective: Install and configure CRC on your local machine.
- Steps:
- Download CRC for your operating system from the Red Hat OpenShift website.
- Unpack the downloaded file.
- Run the
crc setup
command. - Start the cluster with
crc start
. - Access the OpenShift console using the URL and credentials provided by
crc console
.
2. Deploying Your First Application
- Objective: Deploy a sample application on the CRC cluster.
- Steps:
- Access the OpenShift console.
- Create a new project.
- Select “From Catalog” and choose a sample application.
- Follow the wizard to deploy the application.
- Access the application using the route URL provided.
3. Exploring the Command Line Interface (CLI)
- Objective: Use the OpenShift CLI (oc) to interact with your CRC cluster.
- Steps:
- Install the
oc
CLI tool. - Use
oc login
to authenticate. - Explore various commands like
oc get pods
,oc describe
, etc. - Create and delete resources using the CLI.
- Install the
4. Container Image Management
- Objective: Learn to manage container images in CRC.
- Steps:
- Pull an image from a registry using
oc
. - Tag and push the image to the OpenShift integrated registry.
- Deploy an application using the new image.
- Monitor the deployment process.
- Pull an image from a registry using
5. Configuring Persistent Storage
- Objective: Understand persistent storage in CRC.
- Steps:
- Create a Persistent Volume Claim (PVC).
- Attach the PVC to an application.
- Test data persistence by restarting the application.
- Explore data retention after pod deletion.
Leave a Reply