Summary of "Red Hat Certified OpenShift Administrator Course 05 - Using Openshift CLI OC Client"
Summary of "Red Hat Certified OpenShift Administrator Course 05 - Using OpenShift CLI oc Client"
This video provides a detailed tutorial on using the OpenShift CLI client (oc) to manage and interact with an OpenShift cluster. It emphasizes the power and flexibility of the CLI for automation and cluster management compared to the web GUI.
Main Ideas and Concepts
- Introduction to OpenShift CLI (
oc): The CLI is a powerful tool to manage OpenShift clusters, enabling automation and execution of administrative tasks beyond what the GUI offers. - Downloading and Installing the
ocClient: - Logging into the OpenShift Cluster:
- Use
oc loginwith username, password, and cluster IP. - Switch between projects using
oc project <project-name>. - Get cluster info with
oc cluster-info. - Use
oc get --raw /apisto see API versions available in the cluster.
- Use
- Cluster Operators and Status:
- Use
oc get clusteroperatorsto check cluster operator status. - Healthy operators indicate a healthy cluster.
- Use
- Basic
ocCommands Overview:oc login- login to the cluster.oc new-project- create a new project.oc new-app- create an application.oc status- view current project status.oc project- switch projects.oc get- list resources.oc describe- detailed info about a resource.oc edit- edit live resources.oc label- add labels to resources.oc expose- expose services or pods.
- Working with Pods:
oc get podslists pods.- Use
-o wideto get detailed info like IP, node, endpoints. - Use
-o yamlor-o jsonto get pod details in YAML or JSON format. - Use
oc explain podto get schema and field explanations for pod definition files. - Modify pod definitions and apply changes using
oc apply -f <file>. - Create pods from YAML files and verify changes with
oc get pods.
- Namespaces and Resource Filtering:
- Use
-n <namespace>or--namespace=<namespace>to specify namespaces. - Use
oc get pods --all-namespacesto see pods across all namespaces. - Filter resources by labels using
oc get pods -l key=value. - Use selectors to filter resources by labels.
- Use
- Deleting Resources:
- Delete pods or other resources using
oc delete pod <pod-name>.
- Delete pods or other resources using
- Labels and Selectors:
- Labels can be added to pods or resources for identification.
- Use selectors to query resources based on labels.
- Resource Groups and Short Names:
- Resources belong to API groups (e.g., core group).
- Short names exist for resources (e.g.,
svcforservice) to simplify commands.
Detailed Methodology / Instructions
- Download and install
ocCLI: - Login to cluster:
oc login https://<cluster-ip> -u <username> -p <password> - Switch projects:
oc project <project-name> - Check cluster info:
oc cluster-info oc get clusteroperators - List pods and resources:
oc get pods oc get pods -o wide oc get pods -n <namespace> oc get pods --all-namespaces - View resource details:
oc describe pod <pod-name> oc get pod <pod-name> -o yaml oc get pod <pod-name> -o json - Explain resource fields:
oc explain pod
Category
Educational