Skip to content

Instantly share code, notes, and snippets.

###Creating a template
oc login <YOUR_MINISHIFT_URL>
oc login -u system:admin
oc create -f <YOUR_YAML_FILE>.yaml -n openshift
###View/Edit template
oc edit template <YOUR_TEMPLATE> -n openshift
###View all templates available
oc get templates -n openshift

Quick Reference

  • Basic structure
    • oc [name]
    • There are some exceptions, like oc help or oc logs <pod> or oc exec
    • Most commands support oc <command> --help
  • Common resources (nouns)
    • Pods
    • Deployments
  • Services
- Basic structure
- oc <verb> <noun> [name]
- There are some exceptions, like `oc help` or `oc logs <pod>` or `oc exec`
- Most commands support `oc <command> --help`
- Common resources (nouns)
- Pods
- Deployments
- Services
- Routes
- ConfigMaps
@hemanth22
hemanth22 / oc_delete_items.sh
Created December 4, 2021 13:45 — forked from guimou/oc_delete_items.sh
[OC delete items in one line] Deletes OpenShift item in one line
# Delete Running pods
for pod in $(oc get pods | grep Running | awk '{print $1}'); do oc delete pod ${pod} --grace-period=1;done
# Delete Secrets
for secret in $(oc get secrets | awk '{if (NR!=1){print $1}}'); do oc delete secret ${secret};done
### Namespace per tier ###
oc new-project kiosk-backend
oc new-project kiosk-frontend
oc new-project kiosk-database
oc new-app https://github.com/jankleinert/concession-kiosk-backend --name backend -n kiosk-backend
@hemanth22
hemanth22 / OSD-7443
Created December 4, 2021 13:42 — forked from bh7cw/OSD-7443
OSD-7443 script
#!/bin/bash
# set -x
echo "INFO: start putting the cluster into an imbalanced state"
# target workloads to rebalance
TARGET_PODS="alertmanager-main|prometheus-k8s|prometheus-adapter|splunkforwarder-deployment"
# check all the target pods on each infra node
for NODE in $(oc get node -l node-role.kubernetes.io/infra= --no-headers | awk '{print $1}'); do
@hemanth22
hemanth22 / oc-by-example-content.adoc
Created December 4, 2021 13:42 — forked from bergerhoffer/oc-by-example-content.adoc
Auto generated oc commands

OpenShift CLI (oc) commands

export current_pod =
export current_project =
export current_application =
export current_cicd_project =
export current_template =
# show / explore all openshift resources
oc get all
# exame deployment configuration of a pod
./oc get pods -A --template '{{range .items}}{{if eq .status.phase "Running"}}{{.metadata.name}}{{"\n"}}{{end}}{{end}}'
oc get pods -A --template '{{range .items}}{{if and (ne .status.phase "Running") (ne .status.phase "Succeeded") }}{{.metadata.name}}{{"\n"}}{{end}}{{end}}'
@hemanth22
hemanth22 / common_MariaDB_commands.md
Created November 29, 2021 04:37 — forked from zhangzhhz/common_MariaDB_commands.md
Common Useful MySQL / MariaDB Commands