Skip to content

Kubernetes & OpenShift: OpenShift

OpenShift commands from the Kubernetes & OpenShift folder.

Index
5 items

OpenShift: Log in with a token

Safe

Authenticate oc using the token from 'Copy login command' in the web console.

oc login --token=<token> --server=<api-url>
What each part does
  1. oc loginlog in to an OpenShift cluster
  2. --token=<token>API token (web console: your name > Copy login command)
  3. --server=<api-url>API server URL, e.g. https://api.cluster.example.com:6443

Also known as: oc login · Unauthorized · ocp login

OpenShift: Switch project

Safe

Change the default project (namespace). Run oc projects to list them.

oc project <project>
What each part does
  1. oc projectswitch the current project (namespace); with no argument, show the current one
  2. <project>project name

Also known as: oc project · namespace

OpenShift: Follow build logs

Safe

Stream the logs of the latest build of a BuildConfig.

oc logs -f bc/<build-config>
What each part does
  1. oc logs -ffollow logs
  2. bc/<build-config>the latest build of this BuildConfig

Also known as: build logs · s2i

OpenShift: Start a build and follow it

Safe

Trigger a new build and stream its log until it finishes.

oc start-build <build-config> --follow
What each part does
  1. oc start-build <build-config>start a new build from a BuildConfig
  2. --followstream its logs until it finishes

Also known as: oc start-build

OpenShift: Debug a crashing pod with a shell

Safe

Starts a copy of the pod with a shell instead of its entrypoint, so you can poke around.

oc debug pod/<pod>
What each part does
  1. oc debugstart a copy of the pod with the command replaced by a shell, so it doesn't crash
  2. pod/<pod>the pod to copy (also works with deployment/<name> or node/<name>)

My note oc debug node/<node> gives a root shell on a node (chroot /host).

Also known as: CrashLoopBackOff · oc debug

My DevOps Playbook by Angelo John Calleja

New runbook

GitHub not connected

Saving is handled by the site: the GitHub token is stored in Cloudflare, not in your browser. Enter the editor password (the EDITOR_PASSWORD secret) to unlock saving in this browser.

Saving commits to gelogrammer/My_DevOps_Playbook. Create a fine-grained token with access to only this repo andContents: Read and write, then paste it here. It is stored only in this browser.

src/content/docs/…