OpenShift Cheatsheet: Difference between revisions

From Linuxwiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:

Here some helpful OpenShift commands which work (at least) since version >= 4.11
Here some helpful OpenShift commands which work (at least) since version >= 4.11


Line 56: Line 57:
Change from IPI -> UPI not possible
Change from IPI -> UPI not possible


{| class="wikitable"
csv cluster service version
|-
dc deploymentconfig
| csv || cluster service version
ds deploymentsetting
|-
ip installplan
| dc || deploymentconfig
mcp machineconfigpool
|-
pv persistent volume
| ds || deploymentsetting
sa service account
|-
scc security context constraints
| ip ||installplan
svc service
|-
| mcp || machineconfigpool
|-
| pv || persistent volume
|-
| sa || service account
|-
| scc || security context constraints
|-
| svc || service
|}

Revision as of 21:23, 22 August 2023

Here some helpful OpenShift commands which work (at least) since version >= 4.11

How to get a token: https://oauth-openshift.apps.ocp.example.com/oauth/token/display

You might need it for login or automatization.

Switch namespace:

$ oc project <namespace>

quit namespace:

$ oc project -n default

Get all resources:

$ oc get all

Get status of all nodes:

$ oc get nodes

Show Uptime:

$ oc get machines -A

Sort Events by time:

$ oc get events --sort-by=metadata.creationTimestamp

Information gathering: https://docs.openshift.com/container-platform/4.12/cli_reference/openshift_cli/administrator-cli-commands.html#oc-adm-inspect (evtl. secrets löschen!)

List alerts:

$ oc -n openshift-monitoring exec -ti alertmanager-main-0 -c alertmanager -- amtool alert --alertmanager.url=http://localhost:9093 -o extended

https://cloud.redhat.com/blog/how-to-use-amtool-to-manage-red-hat-advanced-cluster-management-for-kubernetes-alerts

Patch resource:

$ oc patch installplan install-defgh -n openshift-operators-redhat --type merge  --patch '{"spec":{"approved":true}}'

Liveness/Readiness Probes of all pods in certain timestamp:

$ oc adm node-logs --role worker -u kubelet | egrep -E 'Liveness|Readiness' | grep "Aug 21 11:22"


Useful terms:

IPI Installer-provisioned infrastructure cluster
Cluster installed by install command; user must only provide some information (which platform, cluster name, network, storage, ...)

UPI User provisioned infrastructure cluster

  • DNS and Loadbalancing must already be there
  • Installation manually, download ova file (in case of vSphere)
  • master created manually
  • workers recommended
  • *no* keepalived

Advantages:
IPI: installation more simple, using preconfigured features
UPI: more flexibility, no loadbalancer outage during update

Change from IPI -> UPI not possible

csv cluster service version
dc deploymentconfig
ds deploymentsetting
ip installplan
mcp machineconfigpool
pv persistent volume
sa service account
scc security context constraints
svc service