-
Notifications
You must be signed in to change notification settings - Fork 0
OpenShift 3 Client
To install OpenShift client:
$ dnf install origin-clients
To get the client login command:
- Login to OpenShift console (e.g. https://manage.openshift.com).
- Click Open Web Console.
- On the upper right of the page, click your name.
- Click Copy Login Command.
$ oc login <URL> --token=<hidden>
Alternatively, to authenticate with username and password, remove the token from the login command, then execute it:
$ oc login <URL>
To verify the status, execute the following command:
$ oc status
To list projects:
$ oc projects
To create a new project:
$ oc new-project <name>
To delete a project:
$ oc delete project <name>
To create secret:
$ mkdir <dir> $ echo -n "<value>" > <dir>/<key> $ oc secrets new <name> <dir>
Make sure the values do not contain EOL characters.
To list storage:
$ oc get pvc
To list mounted storage:
$ oc volume dc --all
To mount a storage:
$ oc volume dc/<deployment> --add --name=<name> --type=persistentVolumeClaim --claim-name=<name> --mount-path=<path>
To unmount a storage:
$ oc volume dc/<deployment> --remove --name=<name>
See also:
To list application's image streams:
$ oc get is
To show image stream details:
$ oc describe is/<name>
To list OpenShift's image streams:
$ oc get is -n openshift
To pull PHP 5.6 container image to the local system for use with OpenShift:
$ oc import-image my-rhscl/php-56-rhel7 --from=registry.access.redhat.com/rhscl/php-56-rhel7 --confirm
See also:
To list build configurations:
$ oc get bc
To create a new build:
$ oc start-build <name> --follow
To list builds:
$ oc get builds
To list OpenShift's application templates:
$ oc get templates -n openshift
To show template details:
$ oc describe templates/<name> -n openshift
To export a template:
$ oc get templates/<name> -n openshift -o yaml > template.yaml
To list available image streams/templates that can be used to create an application:
$ oc new-app --list
To create a new application with image stream:
$ oc new-app <image stream>:<tag>~<git URL>#<branch>
To list the environment variables:
$ oc env dc/<name> --list
To list deployment configurations:
$ oc get dc
To show deployment configuration details:
$ oc describe dc/<name>
To deploy the latest build:
$ oc rollout latest <name>
To configure the replica:
$ oc scale dc <name> --replicas=<number of pods>
To list all pods:
$ oc get pods
To list pods for a particular deployment config:
$ oc get pods -l deploymentconfig=<name>
To show pod details:
$ oc describe pods/<name>
To delete a pod (a new one will be created automatically):
$ oc delete pods/<name>
See also:
To list services:
$ oc get svc
To create a service:
$ oc expose dc/<deployment> --name=<name> --port=<port>
To show service details:
$ oc describe svc/<name>
To delete a service:
$ oc delete svc/<name>
See also:
To list routes:
$ oc get routes
To create a route:
$ oc expose svc/<service> --name=<name> --hostname <hostname>
To show route details:
$ oc describe routes/<name>
To delete route:
$ oc delete routes/<name>
See also:
See OpenShift 3 SSL.
To start a remote shell:
$ oc rsh <pod>
To upload a file into a pod:
$ oc cp <source path> <pod>:<destination path>
To upload a folder into a pod:
$ oc rsync <source dir> <pod>:<destination dir> --no-perms
To download a file/folder from a pod:
$ oc rsync <pod>:<source file/folder> <destination dir> --no-perms
See also:
To forward MySQL port:
$ oc port-forward <mysql pod> 3306 Forwarding from 127.0.0.1:3306 -> 3306 Forwarding from [::1]:3306 -> 3306
Connect with MySQL client as follows:
$ mysql -h 127.0.0.1 -u root -p
To remove an application:
$ oc delete routes/<name> $ oc delete svc/<name> $ oc delete is/<name> $ oc delete dc/<name> $ oc delete bc/<name>