Ocnotes 3
Ocnotes 3
types.
To get an overview of your project status, -> OC status
The output provides a concise summary of the current state of
your project.
OC help
You will get a comprehensive list of available commands
grouped by category.
To get an overview of another project status, followed by the
name of the project you are interested in.->OC status -n
For example, if you want detailed info about usage and options
openShift-console
for the create command, you can type
Oc create—help
If you are a cluster administrator and you want to display the
status for all namespaces, you can ad>OC status -A
This command is used for advanced cluster management
tasks to see the available subcommands for tasks
like upgrading the cluster.
Oc new-app->When it comes to deploying applications, the Managing nodes, configuring security policies, and performing
OC new app command is your go to. maintenance operations.::oc arm -h
This command allows you to create a new application by
specifying the source code location, such as
a git repository, local code on your machine, or even using
templates or Docker images
comes Details:
in handy.
• Creates or updates resources defined in the manifests.
• Works on a single file or an entire directory.
Example: Note:
oc apply -f ./manifests/ If the resource was originally created using oc new-app, you may see a warning when
applying changes.
Check Results:
For im[portingindividual resorce files by specifying the file path instead of a
oc get pods — verify replicas and pod states.
directory.
If we do the OC get pods command, we can see that we have two pod replicas
Oc apply -f ./test/service_account.yaml instead of one.
• oc describe provides:
o Docker image ID
! 2. What is a Container Image? o Image size
o Creation date
• Defines the application code, dependencies, and runtime environment. o Exposed ports
• Every pod is created from one or more container images. o Environment variables
o Repository source
• oc image extract:
o Extracts file system of the image.
! 3. Kubernetes and Image Management o You can explore configuration files, binaries, and app code locally.
• Another way to examine a container image is to use the OC image Extract
• Kubernetes itself doesn’t manage container images directly. command to download the image
• It relies on Docker registries or other external registries to store and distribute • contents to your local file system.
images. • Running the OC image extract command will extract the file system contents
of the specified image and
• send them to the target on your local machine once the extraction is
complete.
! 4. OpenShift Image Streams • Navigate to that directory and explore the images file system.
• Look for configuration files, application code, and other relevant artifacts to
understand how the
• OpenShift uses Image Streams instead of raw images.
• image is structured and what it contains.
• An Image Stream is:
• By combining these techniques, such as listing image streams, describing
o A sequence of pointers to one or more container images.
image and image stream details,
o Acts as an abstraction layer for easier image management.
• and extracting image contents for further inspection.
o Can be linked to deployments for automatic updates.
• Images can come from: • You can comprehensively understand the container images deployed in your
o Internal registry (built into OpenShift)
OpenShift cluster.
o External registries (e.g., [Link], Docker Hub)
• That concludes our lecture on locating and examining container images in
OpenShift.
• Please explore the container images in your cluster and apply the techniques ! 3. Creating a Project (CLI Method)
covered in this demo.
Step 1: Login to Cluster
o ✅oc login -u developer -p <password> [Link]
Step 2: Create a New Project
✅
oc new-project my-demo-project
! 8. Summary
• Creates a new project named my-demo-project.
• Use image streams for efficient image management in OpenShift. • Automatically switches the CLI context to the new project.
• Commands like oc get, oc describe, and oc image extract help in:
o Listing, ✅ Step 3: Verify the Project
o Inspecting, and oc projects
o Exploring container images.
• Combining these techniques gives a comprehensive view of how images are used • Lists all projects available to the logged-in user.
and structured in your OpenShift cluster. • The new project should appear in the list.
• A project in OpenShift is a logical unit that organizes and isolates resources within a
!
✅ 5. Viewing Project Resources
cluster.
• Each project contains: Get an Overview of All Resources
o Deployments oc get all
o Pods
o Services • Displays all resources in the current project (deployments, pods, services, etc.).
o Routes ✅
o ConfigMaps, etc. Describe Project Details
• Projects also enable access control, defining who can access and manage specific oc describe project my-demo-project
resources.
• Provides detailed information including:
o Metadata (labels, annotations)
o Resource quotas and limits
! 2. Purpose of Projects o Events and usage stats
oc projects
• The deleted project will no longer appear. Action Command
Deploy app oc new-app openshift/hello-openshift --name=myapp
# Note:
View resources oc get all
After deletion, the message
Describe project oc describe project my-demo-project
“You are not a member of any projects.” Delete project oc delete project my-demo-project
appears — this is normal for a developer user (not a cluster admin).
✅
! 10. Summary of Common Commands ! 3. Checking Cluster Status
Action Command Cluster Overview
oc status
Login to cluster oc login -u developer
Create project oc new-project my-demo-project • Gives a summary of:
List projects oc projects o Current project
o Services and deployments
o Recent events or warnings
! 6. Monitoring via Web Console
Access the Dashboard
✅
! 4. Node and Control Plane Health
1. Log in as kubeadmin.
✅ List All Nodes 2. Go to Home → Overview.
oc get nodes 3. Dashboard sections include:
# Note: On OpenShift Local (CRC), monitoring operators are not installed, so metrics may
not appear.
oc logs -f <pod_name>
! Lesson Notes: Viewing and Analyzing Logs in oc logs -f pod/<pod_name> --tail=10 (oc logs -f pod my-pod--tail=10)
Examples:
# Viewing Logs from the CLI
# Logs from master nodes
! The oc logs Command oc adm node-logs –role master
• The -f (follow) flag streams logs live as they’re generated. Useful Tip:
• Commonly used for watching builds and deployments in progress. Find container names here if a pod has multiple containers — you can then target container-
specific logs:
Examples:
oc logs -f <pod_name> -c <container_name>
# Follow logs for the most recent build
oc logs -f bc/<buildconfig_name>
# Follow logs for the latest deployment & ! Practical Example: Troubleshooting NGINX Deployment
oc logs -f deployment/<deployment-name>
Scenario:
" Viewing Specific Versions • Deploying an NGINX app requiring root privileges.
• OpenShift runs containers as non-root users by default (security best practice).
If you want logs from a specific version, specify the version number:
Steps:
# For a specific deployment version
oc logs -deployment/<deployment-name> -version=<version-number>
1. Login as developer user.
# For a specific build version
oc logs bc/<build-configname> --version=< version-number> 2. Create project:
3. oc new-project log-demo
For example, if you want to see the logs of the first deployment, you would use version equals one. 4. Deploy app:
5. oc new-app –-name=log-demo -–docker-image=nginx
6. Check pod status:
" Viewing Pod Logs 7. oc get pods
' Viewing Logs in the Web Console ) Lecture Notes: Assessing the Health of an OpenShift Cluster
! Steps: # Objective
1. Log into OpenShift Web Console as developer. Learn how to assess and monitor the health of an OpenShift cluster using CLI tools and built-
2. Navigate to your project (e.g., log-demo). in components like nodes, etcd, and operators.
3. Go to Project → Pods.
4. Click on the desired pod → open Logs tab.
• View logs per container (switch using dropdown). As an OpenShift Administrator, maintaining cluster health ensures:
• Filter or search logs.
• Download logs for offline analysis. • Application reliability
• Smooth resource utilization
• Early detection of issues
✅ Use oc logs for real-time or historical logs of builds, pods, or deployments. • Nodes
✅ Use oc adm node-logs for node-level diagnostics (admins only). • etcd (data store)
• Operators
✅ Use oc describe to view events, resource details, and container names.
• Version Compatibility
✅ The Web Console provides an easy graphical way to view and download logs.
✅ Always check logs when a pod enters CrashLoopBackOff or Error states.
✅ Logs are your first stop for troubleshooting and exam scenarios.
⚙ 2. Node Health
It's important to establish a baseline for etcd performance, and set up alerts to notify
you of any $ 7. Summary
deviations or anomalies.
Component Command Purpose
Nodes oc get nodes Check node status
Nodes oc adm top nodes Monitor CPU/memory usage
etcd oc rsh … etcdctl endpoint health Check etcd health
Back-off restarting container Pay attention to the exit codes and error messages to
identify the root cause of the issue.
For example, an event like failed to pull image indicates that the container image specified in
the
pod configuration could not be retrieved from the registry.
# Objective
Learn to identify, analyze, and troubleshoot common container, pod, and cluster-level issues + Issue 2: Exceeding Resource Limits
in OpenShift using logs, events, and commands.
• If CPU/memory limits are exceeded, container may throttle or terminate.
Possible causes:
, 3. Troubleshooting Pod Issues
• Application misconfiguration + Issue 1: Pod Stuck in Pending State
• Missing dependencies
• Resource limits
Possible causes:
• When a container crashes, your first instinct should be to examine the
container logs.
• Insufficient node resources
• You can do this by using the OC logs command followed by the pod and
• Taints/tolerations mismatch
container names.
• NodeSelector or affinity mismatch
•
Commands:
Troubleshooting steps:
oc describe pod <pod-name>
1. Check logs:
2. oc logs <pod-name> -c <container-name>
Check Events for:
→ Reveals application errors or missing files. • "0/1 nodes are available: insufficient CPU."
• "node(s) didn’t match node selector"
3. Describe pod for events:
4. oc describe pod <pod-name>
Solutions:
→ Check Events section for messages like:
• Adjust resource requests.
• Add more nodes. Commands:
• Fix nodeSelector or taint mismatch.
For example, you can use etcd CTL endpoint health to check the health of etcd
members and identify
any problematic nodes.
+ Issue 2: Pod Evicted or Terminated Repeatedly
Causes:
can use the etcd CTL command line tool.
• Node resource pressure
• Node failure 1. List etcd pods:
2. oc get pods -n openshift-etcd
Check events: 3. Check health:
4. oc rsh -n openshift-etcd <etcd-pod> etcdctl endpoint health --cluster
oc get events --field-selector 5. View logs:
[Link]=Pod,[Link]=<pod-name> 6. oc logs -n openshift-etcd <etcd-pod>
Look for: ( Tip: Monitor etcd metrics and set alerts for latency spikes.
• Evicted
• NodeLost
, b) Network Connectivity Issues
Fix:
Symptoms:
• Add cluster resources.
• Investigate node health. • Pods can't communicate with each other or external services.
Possible causes:
+ Issue 3: Pod Stuck in Terminating State • Misconfigured network policies
• Firewall restrictions
Causes: • Network plugin failure
Oc get pods
we'll create a new application using the OC new app command and specify a node ✅ Summary
selector
condition that requires the label node name equals CRC. • Use logs + describe + events for root-cause diagnosis.
• Monitor nodes, etcd, and network continuously.
• Understand pod lifecycle to troubleshoot effectively.
1. Create an application with node selector: • Practice real scenarios like Pending, CrashLoopBackOff, Evicted, and
2. oc run nginx –-image=bitnami/nginx -–overrides=’{“spec”: {“nodeSelector”: Terminating pods.
{“nodename”: crc”}}}’
3. oc new-app nginx --dry-run=client -o yaml > [Link]
The commands "oc get nodes", "oc adm top nodes", and "oc describe node" are all
useful for assessing the health of nodes in an OpenShift cluster. "oc get nodes"
Add in [Link]:
provides a general overview of node status, "oc adm top nodes" shows resource
spec:
usage, and "oc describe node" gives detailed information about a specific node.
template: The oc whoami --show-console command provides the URL directly, while "oc get
spec: routes -n openshift-console" lists the routes in the openshift-console namespace,
nodeSelector: which includes the route for accessing the web console.
nodeName: CRC
Then apply:
oc apply -f [Link]
) Lecture Notes: Using Product Documentation in
4. Check pod status:
5. oc get pods OpenShift
→ Pod shows Pending. " Objective
6. Describe pod for details: Learn how to effectively access, navigate, and utilize OpenShift product documentation to
7. oc describe pod <pod-name>
understand features, troubleshoot issues, and stay updated with new releases.
Event Output:
$ Lesson Takeaways
Issue Type Useful Commands Fix * 2. Accessing the Official Documentation
Container crash oc logs, oc describe pod Check logs, fix image/config
Primary Source:
Resource limit oc adm top pods Adjust limits
* [Link]
Pod pending oc describe pod Fix selector / resources
Pod evicted oc get events Add resources, check node • Central hub for Red Hat OpenShift Container Platform docs
etcd issues etcdctl endpoint health Monitor health, logs • Contains:
o Installation guides o Import existing codebase
o Configuration steps o Deploy from container image
o Administration procedures
o Developer workflows Example Topics Covered:
o Release notes
• YAML examples for configurations
Steps to Access: • Customizing sample manifests
• Environment variable setup
1. Visit [Link] • Common troubleshooting tips
2. Select your OpenShift version from the dropdown (OCP section)
3. Browse through the structured sidebar for relevant topics , Tip: Note down best practices and recommendations for smoother deployments.
⚙ 4. Example: Creating and Deploying an Application - 6. Best Practices When Using Documentation
$ Step 1: Create a New Project • Bookmark frequently used sections (installation, networking, security)
• Cross-check version-specific changes before applying commands
• Use examples and YAML snippets as templates
• Go to the Developer Activities section • Read release notes for feature updates and deprecations
• Locate Work with Projects → Open it in a new tab • Leverage search to quickly find command references
• Follow the guide to:
• Combine CLI help + official docs for complete understanding
o Create a new project (Web Console or CLI)
o Set access permissions
o View or delete projects
Example:
View file:
cat [Link]
identityProviders:
- name: local_auth
mappingMethod: claim $ Exam Tip (EX280)
type: HTPasswd
htpasswd: • HTPassword authentication is a frequent exam topic.
fileData:
name: my-htpass-secret
• Practice:
o Creating htpasswd file
4. Apply the configuration: o Configuring via CLI
oc replace -f [Link]
o Logging in and verifying users
5. Monitor authentication pods:
oc get pods -n openshift-authentication -w
oc get pods -n openshift-authentication
Once the pods are running, you can test logging in with one of the new users.
htpasswd -u [Link] bob pass123
6. Verify users:
oc get users
To verify the users, you can use the OC Get Users command.
Once you log in with an administrator account.
Identify the secret (e.g., htpass-secret). Pods should restart automatically when OAuth config changes.
* Summary Learn how to update or reset a user’s password in OpenShift when using the HTPassword
identity provider.
Step Action Command / Tool
1 Remove user from htpasswd file Edit file manually
2 Update OpenShift secret `oc create secret --dry-run $ Why Modify Passwords?
3 Delete user from cluster oc delete user <name>
As an OpenShift administrator, you may need to:
4 Delete user identity oc delete identity HTPasswd:<name>
5 Verify removal oc get users, oc get identity • Reset passwords for users who forgot them.
• Enforce password rotation for security.
• Update passwords due to compromised credentials.
+ Key Takeaways
2 Scenario
.
. Step-by-Step Procedure
Update Password in HTPassword File
Explanation:
/ [Link]
cat
After updating the file, replace the secret in the cluster so OpenShift uses the new password
file.
Check status:
1. Log out from your admin session in the OpenShift Web Console.
2. Select HTPassword on the login page.
3. Enter username alice and the new password. ! Creating a New Group
4. Successful login confirms the password update worked.
To create a new group, use the following command:
• Password modification in HTPassword is simple and secure. oc adm groups remove-users developers charlie
• No need to recreate users or identities.
• Always remember to update the secret and wait for OAuth to restart.
• Verify by logging in with the updated credentials. ! Assigning Roles to Groups
Assigning roles to groups allows you to grant permissions to all users in that group at once.
For instance, to assign the view role to the developers group in a project:
oc adm policy add-role-to-group view developers -n my-project
This grants the view role to all members of the developers group in the my-project That was an excellent and complete walkthrough of Role-Based Access Control (RBAC)
namespace. in OpenShift — it covers every important aspect that’s relevant for both EX280 exam prep
We’ll explore roles and permissions in more depth in the next lesson. and real-world OpenShift administration.
Here’s a structured summary + key takeaways from your transcript so you can use it as
notes or a study reference 3
! Default Virtual Groups in OpenShift
These virtual groups can be used to apply cluster-wide access [Link] poremission RBAC (Role-Based Access Control) manages who can do what within an OpenShift
cluster.
It links users or groups to roles, which define permissions through verbs (like get, list,
create, delete).
, Demo