- Basic structure
- oc [name]
- There are some exceptions, like
oc help
oroc logs <pod>
oroc exec
- Most commands support
oc <command> --help
- Common resources (nouns)
- Pods
- Deployments
- Services
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 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 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
./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}}' |
-
Show all users in the mysql database:
MariaDB [(none)]> select * from mysql.user;
-
Delete a null user: