#!/bin/bash # Set up colors for better readability GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' PURPLE='\033[0;35m' NC='\033[0m' # No Color # The namespace where the dashboard is installed NAMESPACE=kubernetes-dashboard # Get the token TOKEN=$(kubectl -n $NAMESPACE get secret dashboard-admin-token -o jsonpath="{.data.token}" | base64 -d) # Print instructions echo -e "${BLUE}╔════════════════════════════════════════════════════════════╗${NC}" echo -e "${BLUE}║ ${GREEN}Kubernetes Dashboard Token${BLUE} ║${NC}" echo -e "${BLUE}╚════════════════════════════════════════════════════════════╝${NC}" echo echo -e "${GREEN}Use this token to authenticate to the Kubernetes Dashboard:${NC}" echo echo -e "${PURPLE}$TOKEN${NC}" echo # Save token to clipboard if xclip is available if command -v xclip &> /dev/null; then echo -n "$TOKEN" | xclip -selection clipboard echo -e "${GREEN}Token has been copied to your clipboard!${NC}" fi