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
contexts="$(cat "$KUBECONFIG" | yq e ".contexts[].name" -)"; | |
for current_context in $contexts; do | |
kubeconfig_path="$(printf "%s" "$current_context" | rev | cut -d'/' -f1 | rev)"; | |
kubectl config view --minify --flatten --context="$current_context" > "$kubeconfig_path"; | |
if [[ "$?" != "0" ]]; then | |
rm -f "$kubeconfig_path"; | |
echo "bad context: $current_context"; | |
fi; | |
done; |
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
contexts="$(cat "$KUBECONFIG" | yq e ".contexts[].name" -)"; | |
for current_context in $contexts; do | |
kubectl config view --minify --flatten --context="$current_context" || echo "bad context: $current_context"; | |
echo "---"; | |
done; |
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
# kubectl_print_context CONTEXT_NAME | |
kubectl_print_context() { | |
kubectl config view --minify --flatten --context="$1"; | |
} |
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
kubectl config view --minify --flatten --context="$(kubectl config current-context)"; |
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
# capacity | |
capacity() { | |
echo "node cpu.capacity cpu.allocatable memory.capacity memory.allocatable" | awk '{printf "%-50s %-20s %-20s %-20s %-20s \n", $1, $2, $3, $4, $5}'; | |
kubectl get nodes -o json | jq -r '.items[] | "\(.metadata.name) \(.status.capacity.cpu) \(.status.allocatable.cpu) \(.status.capacity.memory) \(.status.allocatable.memory)"' | awk '{printf "%-50s %-20s %-20s %-20s %-20s \n", $1, $2, $3, $4, $5}'; | |
} |
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
# system [cpu|mem] | |
system() { | |
if [[ "$1" == "cpu" ]]; then | |
kubectl top pod --all-namespaces | tail -n +2 | sort --reverse --key 3 --numeric; | |
elif [[ "$1" == "mem" ]]; then | |
kubectl top pod --all-namespaces | tail -n +2 | sort --reverse --key 4 --numeric; | |
else | |
echo "unknown resource type"; | |
fi; | |
} |
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
# so many steps to share a value 🙁 | |
# set-output command -> internal key name -> output key name -> needs on next job -> handlebars (not portable) | |
jobs: | |
setup: | |
runs-on: ubuntu-latest | |
outputs: | |
key-name-alt: ${{ steps.set-value.outputs.key-name }} | |
steps: | |
- id: set-value | |
run: echo "::set-output name=key-name::value-goes-here" |
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
on: | |
workflow_call: | |
inputs: | |
BUILD_NO_CACHE: | |
description: 'Add any value to disable build caching' | |
default: '' | |
required: false | |
type: string |
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
variables: | |
BUILD_NO_CACHE: | |
value: "" | |
description: "Add any value to build your Dockerfiles without using the cache" |
NewerOlder