OpenShift – CLI Operations

OpenShift - CLI Operations

OpenShift CLI Operations is capable of performing all basic and advanced configuration, management, addition, and deployment of applications.

We can perform different kinds of operations using OC commands. This client helps you develop, build, deploy, and run your applications on any OpenShift or Kubernetes compatible platform. It also includes the administrative commands for managing a cluster under the ‘arm’s subcommand.

Basic Commands Of OpenShift CLI Operations

The following table lists the basic OC commands.

Sr.No.Commands & Description
1types introduction to concepts and type
2log in log in to a server
3new-project request a new project
4new-app Create a new application
5Status Show an overview of the current project
6Project Switch to another project
7Projects Display existing projects
8Explain Documentation of resources
9Cluster Start and stop OpenShift cluster

Login

Log in to your server and save the login for subsequent use. First-time users of the client should run this command to connect to a server, establish an authenticated session, and save a connection to the configuration file. The default configuration will be saved to your home directory under “.kube/config”.

The information required to log in — like username and password, a session token, or the server details can be provided through flags. If not provided, the command will prompt for user input as needed.

Usage

oc login [URL] [options]

Example

# Log in interactively
oc login

# Log in to the given server with the given certificate authority file
oc login localhost:8443 --certificate-authority = /path/to/cert.crt

# Log in to the given server with the given credentials (will not prompt interactively)
oc login localhost:8443 --username = myuser --password=mypass

Options โˆ’

-p, –password = “ โˆ’ Password, will prompt if not provided

-u, –username = “ โˆ’ Username, will prompt if not provided

–certificate-authority = “ โˆ’ Path to a cert. file for the certificate authority

–insecure-skip-tls-verify = false โˆ’ If true, the server’s certificate will not be checked for validity. This will make your HTTPS connections insecure

–token = “ โˆ’ Bearer token for authentication to the API server

To get the complete details regarding any command, use the oc <Command Name> –help command.

Build and Deploy Commands

The following table lists the build and deploys commands.

Sr.No.Commands & Description
1RolloutManage a Kubernetes deployment or OpenShift deploy
2Deploy View, start, cancel, or retry a deployment
3Rollback Revert part of an application back to the previous state
4new-build Create a new build configuration
5start-build Start a new build
6cancel-build Cancel running, pending, or new builds
7import-image Imports images from a Docker registry
8Tag the existing images into image streams

Application Management Commands

The following table lists the application management commands.

Sr.No.Commands & Description
1GetDisplay one or many resources
2Describe Show details of a specific resource or a group of resources
3Edit a resource on the server
4set commands that help set specific features on objects
5Labe update the labels on a resource
6AnnotateUpdate the annotations on a resource
7ExposeExpose a replicated application as a service or route
8DeleteDelete one or more resources
9ScaleChange the number of pods in a deployment
10AutoscaleAutoscale a deployment config, deployment, replication, Controller or replica set
11SecretsManage secrets
12ServiceaccountsManage service accounts in your project

Troubleshooting and Debugging Commands

The following table lists the troubleshooting and debugging commands.

Sr.No.Commands & Description
1logsPrint the logs for a resource
2Rsh Start a shell session in a pod
3RsyncCopy files between the local filesystem and a pod
4port-forward forward one or more local ports to a pod
5DebugLaunch a new instance of a pod for debugging
6ExecExecute a command in a container
7Proxy Run a proxy to the Kubernetes API server
9AttachAttach to a running container
10Run a particular image on the cluster
11Cp Copy files and directories to and from containers

Advanced Commands

The following table lists the advanced commands.

Sr.No.Commands & Description
1admTools for managing a cluster
2create create a resource by filename or stdin
3replace a resource by filename or stdin
4apply a configuration to a resource by filename or stdin
5patch update field(s) of a resource using strategic merge patch
6process a template into list of resources
7export resources so they can be used elsewhere
8extractExtract secrets or config maps to disk
9idleIdle scalable resources
10observe changes to the resources and react to them (experimental)
11policyManage authorization policy
12auto inspect authorization
13convert config files between different API versions
14import commands that import applications

Setting Commands

The following table lists the set commands.

Sr.No.Commands & Description
1LogoutEnd the current server session
2ConfigChange the configuration files for the client
3WhoamiReturn information about the current session
4CompletionOutput shell completion code for the specified shell (bash or zsh)

Next Topic – Click Here

This Post Has One Comment

Leave a Reply