Last active
November 20, 2024 16:31
-
-
Save dlbewley/b4d4c85931e7a9c03caf56db1a1a0d2e to your computer and use it in GitHub Desktop.
OpenShift OVN Northbound DB CLI Access
This file contains 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 | |
# Connect to the OVN northbound database pod. | |
# Optionally specify the node and or command | |
# https://guifreelife.com/blog/2024/11/19/Open-Virtual-Network-Inspection-on-OpenShift/ | |
node=$1; shift; cmd=$* | |
if [[ -n "$node" ]]; then | |
nbdbpod=$(oc get pod \ | |
-l app=ovnkube-node \ | |
-n openshift-ovn-kubernetes \ | |
-o go-template='{{range .items}}{{if eq .spec.nodeName "'$node'"}}{{.metadata.name}}{{"\n"}}{{end}}{{end}}') | |
fi | |
if [[ -z "$nbdbpod" ]]; then | |
nbdbpod=$(oc get pod \ | |
-l app=ovnkube-node \ | |
-n openshift-ovn-kubernetes \ | |
-o jsonpath='{.items[0].metadata.name}') | |
fi | |
# hide any websocket errs | |
oc rsh -c nbdb -n openshift-ovn-kubernetes $nbdbpod $cmd 2>/dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment