Skip to content

Commit 1a2ac23

Browse files
committed
Add K8s API endpoint script
Add a simple script to show the actual endpoint of the K8s API for the currently active KUBECONFIG Signed-off-by: Scott Lowe <[email protected]>
1 parent 275dd3d commit 1a2ac23

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Diff for: kaep

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
3+
# Check for yq executable; error if not found
4+
YQCMD=$(command -v yq)
5+
if [[ ! -x "${YQCMD}" ]]; then
6+
echo -e "The `yq` executable was not found; please install it or move it into your PATH\n"
7+
exit 1
8+
fi
9+
10+
# Make sure the KUBECONFIG environment variable is defined
11+
if [[ -z "$KUBECONFIG" ]]; then
12+
echo -e "No valid KUBECONFIG defined\n"
13+
exit 1
14+
fi
15+
16+
# Get the Kubernetes API endpoint of the first cluster in the current KUBECONFIG
17+
KAEP=$(yq e '.clusters[0].cluster.server' "${KUBECONFIG}")
18+
19+
# Display the value to the user
20+
echo -e "The current Kubernetes API endpoint is: ${KAEP}\n"

0 commit comments

Comments
 (0)