Last active
August 17, 2020 15:02
-
-
Save vlussenburg/94747e7412b540601a572e638910c0f6 to your computer and use it in GitHub Desktop.
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 | |
# Extract cluster information to check compatibility with Alcide Support Matrix | |
printf "Extracting Cluster Information...\n" | |
# Check if kubectl is accessible | |
if ! command -v kubectl &> /dev/null | |
then | |
printf "ERROR: kubectl command cannot be found. Please install kubectl for running this utility \n" | |
exit 1 | |
fi | |
# Check if kubectl working for the current context | |
if ! kubectl get pods > /dev/null | |
then | |
echo "kubectl is failing for the current context" | |
exit 1 | |
fi | |
printf "Cluster Context\n" | |
printf "==============\n" | |
kubectl config current-context | |
printf "\n" | |
printf "Check network accessibility to Alcide's cloud\n" | |
printf "=============================================\n" | |
kubectl run -it --rm --restart=Never --image alcide/net-check alcide-net-check \ | |
ca-service.prod.cloud.alcide.io:31443 \ | |
kafka-0.kafka-service.prod.cloud.alcide.io:30000 \ | |
kafka-1.kafka-service.prod.cloud.alcide.io:30001 \ | |
kafka-2.kafka-service.prod.cloud.alcide.io:30002 \ | |
free.cloud.alcide.io:443 \ | |
ca-service.free.cloud.alcide.io:31443 \ | |
kafka-0.kafka-service.free.cloud.alcide.io:30000 \ | |
kafka-1.kafka-service.free.cloud.alcide.io:30001 \ | |
kafka-2.kafka-service.free.cloud.alcide.io:30002 | |
printf "\n" | |
printf "Nodes Cloud Provider\n" | |
printf "====================\n" | |
kubectl get nodes -o go-template='{{range.items}}{{.spec.providerID}}{{"\n"}}{{end}}' | sed 's/:.*//g' | sort | uniq | |
printf "\n" | |
printf "Kuberntes conrol plane version\n" | |
printf "==============================\n" | |
# check if jq is available. If yes then print concise info | |
if command -v jq &> /dev/null | |
then | |
kubectl version -o json | jq .serverVersion.gitVersion | |
else | |
kubectl version | grep "Server" | |
fi | |
printf "\n" | |
printf "kubelet Version\n" | |
printf "===============\n" | |
kubectl get nodes -o go-template='{{range.items}}{{.status.nodeInfo.kubeletVersion}}{{"\n"}}{{end}}' | sort | uniq | |
printf "\n" | |
printf "Container run time\n" | |
printf "==================\n" | |
kubectl get nodes -o go-template='{{range.items}}{{.status.nodeInfo.containerRuntimeVersion}}{{"\n"}}{{end}}' | sort | uniq | |
printf "\n" | |
printf "Operating System\n" | |
printf "================\n" | |
kubectl get nodes -o go-template='{{range.items}}{{.status.nodeInfo.operatingSystem}}{{"\n"}}{{end}}' | sort | uniq | |
printf "\n" | |
printf "OS Image\n" | |
printf "========\n" | |
kubectl get nodes -o go-template='{{range.items}}{{.status.nodeInfo.osImage}}{{"\n"}}{{end}}' | sort | uniq | |
printf "\n" | |
printf "Kernel version\n" | |
printf "==============\n" | |
kubectl get nodes -o go-template='{{range.items}}{{.status.nodeInfo.kernelVersion}}{{"\n"}}{{end}}' | sort | uniq | |
printf "\n" | |
printf "CNI - looking for image or labels with the cni name in it...\n" | |
printf "============================================================\n" | |
kubectl get pods --all-namespaces -o go-template='{{range.items}}{{range.spec.containers}}{{.image}}{{"\n"}}{{end}}{{end}}' | sort | uniq | grep -i 'cni' | |
kubectl get nodes -o go-template='{{range.items}}{{range.metadata.labels}}{{.}}{{"\n"}}{{end}}{{end}}' | sort | uniq | grep -i 'cni' | |
printf "\n" | |
printf "Storage Classes Provisioners (help detection K8s provisioner - EKS/GKE/AKS etc.)\n" | |
printf "============================================================\n" | |
kubectl get storageclasses -n kube-system -o custom-columns=PROVISIONER:.provisioner --no-headers | sort | uniq | |
printf "\n" | |
printf "done!\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment