OpenShift - CLI Operations

OpenShift CLI is capable of performing all basic and advance 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 'adm' subcommand.
Following table lists the basic OC commands.
Types
An introduction to concepts and type
Login
Log in to a server
new-project
Request a new project
new-app
Create a new application
Status
Show an overview of the current project
Project
Switch to another project
Projects
Display existing projects
Explain
Documentation of resources
Cluster
Start and stop OpenShift cluster
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 login -- 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.
Following table lists the build and deploy commands.
Rollout
Manage a Kubernetes deployment or OpenShift deploy
Deploy
View, start, cancel, or retry a deployment
Rollback
Revert part of an application back to the previous state
new-build
Create a new build configuration
start-build
Start a new build
cancel-build
Cancel running, pending, or new builds
import-image
Imports images from a Docker registry
Tag
Tag the existing images into image streams
Following table lists the application management commands.
Get
Display one or many resources
Describe
Show details of a specific resource or a group of resources
Edit
Edit a resource on the server
Set
Commands that help set specific features on objects
Label
Update the labels on a resource
Annotate
Update the annotations on a resource
Expose
Expose a replicated application as a service or route
Delete
Delete one or more resources
Scale
Change the number of pods in a deployment
Autoscale
Autoscale a deployment config, deployment, replication, Controller or replica set
Secrets
Manage secrets
Serviceaccounts
Manage service accounts in your project
Following table lists the troubleshooting and debugging commands.
logs
Print the logs for a resource
Rsh
Start a shell session in a pod
Rsync
Copy files between the local filesystem and a pod
port-forward
Forward one or more local ports to a pod
Debug
Launch a new instance of a pod for debugging
Exec
Execute a command in a container
Procy
Run a proxy to the Kubernetes API server
Attach
Attach to a running container
Run
Run a particular image on the cluster
Cp
Copy files and directories to and from containers
Following table lists the advanced commands.
adm
Tools for managing a cluster
create
Create a resource by filename or stdin
replace
Replace a resource by filename or stdin
apply
Apply a configuration to a resource by filename or stdin
patch
Update field(s) of a resource using strategic merge patch
process
Process a template into list of resources
export
Export resources so they can be used elsewhere
extract
Extract secrets or config maps to disk
idle
Idle scalable resources
observe
Observe changes to the resources and react to them (experimental)
policy
Manage authorization policy
auth
Inspect authorization
convert
Convert config files between different API versions
import
Commands that import applications
Following table lists the setting commands.
Logout
End the current server session
Config
Change the configuration files for the client
Whoami
Return information about the current session
Completion
Output shell completion code for the specified shell (bash or zsh)

    70 Lectures 
     4 hours 

 Cloud Passion

    19 Lectures 
     1 hours 

 Pranjal Srivastava

    26 Lectures 
     1.5 hours 

 Pranjal Srivastava
 Print
 Add Notes
 Bookmark this page