Official documentation: https://docs.openshift.com/container-platform/3.11/cli_reference/basic_cli_operations.html
Get informations about the OpenShift / Kubernetes resource objects.
Dive into resource description:
oc explain DeploymentConfig
oc explain DeploymentConfig.spec
oc explain DeploymentConfig.spec.strategy
Full description of a DeploymentConfig: oc explain dc --recursive=true
JSON schema definitions: https://github.com/garethr/openshift-json-schema
Get informations about the resources used by calling the OpenShift API.
Get all resource types: oc api-resources | sort
Get the definition of a resource. Path: https://OPENSHIFT_API_URL/apis/VERSION
Example for the DeploymentConfig (kind: DeploymentConfig, version: apps.openshift.io/v1)
curl -k -H "Authorization: Bearer $(oc whoami -t)" -H 'Accept: application/yaml' https://OPENSHIFT_API_URL/apis/apps.openshift.io/v1
Documentation: https://docs.openshift.com/container-platform/3.11/rest_api/index.html
Login into two cluster at the same time. Or login as two different user.
Do this in two different bash windows and different directories.
export KUBECONFIG=$(pwd)/.kube
oc get events -o wide -o custom-columns="creation:metadata.creationTimestamp,last:lastTimestamp,count:count,name:metadata.name,type:type,reason:reason,source:source,message:message"
get all project names:
oc get project -o custom-columns=NAME:metadata.name
Patch the configmap with the oc tool.
example configmap
apiVersion: v1
data:
launcher.backend.catalog.filter: ""
...
launcher.keycloak.client.id: ""
launcher.keycloak.realm: ""
launcher.keycloak.url: ""
Patch command to update values.
oc patch configmap launcher -p '{"data":{"launcher.keycloak.client.id":"fabric8-launcher"}}'
oc patch configmap launcher -p '{"data":{"launcher.keycloak.realm":"realm-name"}}'
oc patch configmap launcher -p '{"data":{"launcher.keycloak.url":"https://sso.keycloak.com/auth"}}'
Easy way to convert between json and yaml format.
oc convert -f pod.yaml --local -o json
oc convert -f pod.json --local -o yaml
oc get pods -l deploymentconfig=mysql
oc delete pods -l deploymentconfig=mysql
oc rsh dc/mysql
oc rsh $(oc get pods -o name -l app=my-app)
oc debug dc/my-app
# same but as root user
oc debug --as-root=true dc/my-app