📅  最后修改于: 2020-10-31 13:54:15             🧑  作者: Mango
OpenShift CLI能够执行应用程序的所有基本和高级配置,管理,添加和部署。
我们可以使用OC命令执行各种操作。该客户端可帮助您在任何OpenShift或Kubernetes兼容平台上开发,构建,部署和运行应用程序。它还在“ adm”子命令下包括用于管理集群的管理命令。
下表列出了基本的OC命令。
Sr.No. | Commands & Description |
---|---|
1 |
Types An introduction to concepts and type |
2 |
Login Log in to a server |
3 |
new-project Request a new project |
4 |
new-app Create a new application |
5 |
Status Show an overview of the current project |
6 |
Project Switch to another project |
7 |
Projects Display existing projects |
8 |
Explain Documentation of resources |
9 |
Cluster Start and stop OpenShift cluster |
登录到您的服务器并保存登录以备后用。客户端的首次用户应运行此命令以连接到服务器,建立经过身份验证的会话,并保存与配置文件的连接。默认配置将保存到您的主目录下的“ .kube / config”下。
登录所需的信息(例如用户名和密码,会话令牌或服务器详细信息)可以通过标志提供。如果未提供,该命令将根据需要提示用户输入。
用法
oc login [URL] [options]
例
# 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
选项-
-p, –password =“ -密码,如果未提供,将提示
-u, –username =“ -用户名,如果未提供,将提示
–certificate-authority =“ -证书颁发机构的证书文件路径
–insecure-skip-tls-verify = false-如果为true,将不检查服务器证书的有效性。这将使您的HTTPS连接不安全
–token =“ -用于对API服务器进行身份验证的承载令牌
要获取有关任何命令的完整详细信息,请使用oc <命令名称> –help命令。
下表列出了构建和部署命令。
Sr.No. | Commands & Description |
---|---|
1 |
Rollout Manage a Kubernetes deployment or OpenShift deploy |
2 |
Deploy View, start, cancel, or retry a deployment |
3 |
Rollback Revert part of an application back to the previous state |
4 |
new-build Create a new build configuration |
5 |
start-build Start a new build |
6 |
cancel-build Cancel running, pending, or new builds |
7 |
import-image Imports images from a Docker registry |
8 |
Tag Tag the existing images into image streams |
下表列出了应用程序管理命令。
Sr.No. | Commands & Description |
---|---|
1 |
Get Display one or many resources |
2 |
Describe Show details of a specific resource or a group of resources |
3 |
Edit Edit a resource on the server |
4 |
Set Commands that help set specific features on objects |
5 |
Label Update the labels on a resource |
6 |
Annotate Update the annotations on a resource |
7 |
Expose Expose a replicated application as a service or route |
8 |
Delete Delete one or more resources |
9 |
Scale Change the number of pods in a deployment |
10 |
Autoscale Autoscale a deployment config, deployment, replication, Controller or replica set |
11 |
Secrets Manage secrets |
12 |
Serviceaccounts Manage service accounts in your project |
下表列出了故障排除和调试命令。
Sr.No. | Commands & Description |
---|---|
1 |
logs Print the logs for a resource |
2 |
Rsh Start a shell session in a pod |
3 |
Rsync Copy files between the local filesystem and a pod |
4 |
port-forward Forward one or more local ports to a pod |
5 |
Debug Launch a new instance of a pod for debugging |
6 |
Exec Execute a command in a container |
7 |
Procy Run a proxy to the Kubernetes API server |
9 |
Attach Attach to a running container |
10 |
Run Run a particular image on the cluster |
11 |
Cp Copy files and directories to and from containers |
下表列出了高级命令。
Sr.No. | Commands & Description |
---|---|
1 |
adm Tools for managing a cluster |
2 |
create Create a resource by filename or stdin |
3 |
replace Replace a resource by filename or stdin |
4 |
apply Apply a configuration to a resource by filename or stdin |
5 |
patch Update field(s) of a resource using strategic merge patch |
6 |
process Process a template into list of resources |
7 |
export Export resources so they can be used elsewhere |
8 |
extract Extract secrets or config maps to disk |
9 |
idle Idle scalable resources |
10 |
observe Observe changes to the resources and react to them (experimental) |
11 |
policy Manage authorization policy |
12 |
auth Inspect authorization |
13 |
convert Convert config files between different API versions |
14 |
import Commands that import applications |
下表列出了设置命令。
Sr.No. | Commands & Description |
---|---|
1 |
Logout End the current server session |
2 |
Config Change the configuration files for the client |
3 |
Whoami Return information about the current session |
4 |
Completion Output shell completion code for the specified shell (bash or zsh) |