Skip to content

Instantly share code, notes, and snippets.

@dlbewley
Last active April 2, 2024 23:54
Show Gist options
  • Save dlbewley/b4d4c85931e7a9c03caf56db1a1a0d2e to your computer and use it in GitHub Desktop.
Save dlbewley/b4d4c85931e7a9c03caf56db1a1a0d2e to your computer and use it in GitHub Desktop.
OpenShift OVN Northbound DB CLI Access
#!/bin/bash
# Connect to the OVN northbound database pod.
# Optionally specify on which node.
node=$1
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
oc rsh -c nbdb -n openshift-ovn-kubernetes $nbdbpod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment