Skip to content
/ my-gke Public

GKE Cluster Access Manager is a CLI tool that simplifies access management for Google Kubernetes Engine (GKE) clusters.

License

Notifications You must be signed in to change notification settings

bobphul/my-gke

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

GKE Cluster Access Manager

GKE Cluster Access Manager is a CLI tool that simplifies access management for Google Kubernetes Engine (GKE) clusters.

Key Features

  • List and select GCP projects
  • List and select GKE clusters from the chosen project
  • Easy cluster selection through interactive UI
  • Automatic kubeconfig configuration
  • Automatic Authorized Networks update (if enabled)

Prerequisites

  1. Go 1.20 or higher
  2. Google Cloud SDK (gcloud)
  3. kubectl
  4. GCP account with required permissions
    • Container Engine related permissions
    • Cloud Resource Manager related permissions

Installation

  1. Clone repository
git clone https://github.com/bobphul/my-gke.git
cd my-gke
  1. Install packages
go mod tidy
  1. Build
go build -o gke
  1. Add executable to PATH

For local environment:

sudo mv gke /usr/local/bin/

For Google Cloud Shell:

# Create Go bin directory if it doesn't exist
mkdir -p ~/gopath/bin
# Move the executable
mv gke ~/gopath/bin/
# Add to PATH if not already added
echo 'export PATH=$PATH:~/gopath/bin' >> ~/.bashrc
source ~/.bashrc

Usage

  1. Configure gcloud authentication (SKIP if using Google Cloud Shell)
gcloud auth login
gcloud auth application-default login
  1. Run the program
gke
  1. Use arrow keys (↑/↓) to select projects and clusters, press Enter to confirm

Feature Details

  • Project Selection: Displays all accessible GCP projects in your account
  • Cluster Selection: Shows all GKE clusters in the selected project
  • Automatic Authentication: Automatically configures kubeconfig for the selected cluster
  • IP Auto-update: Automatically adds/updates the current user's IP to Authorized Networks if enabled

Required GCP Permissions

  • container.clusters.get
  • container.clusters.list
  • container.clusters.update
  • container.operations.get
  • resourcemanager.projects.get
  • resourcemanager.projects.list

Troubleshooting

  1. If permission errors occur:

    • Verify gcloud authentication is properly set up
    • Check if necessary IAM permissions are granted
  2. If cluster connection errors occur:

    • Check Authorized Networks settings
    • Verify VPC firewall rules

Limitations

  • IP auto-update feature is skipped if Authorized Networks is not enabled on the GKE cluster
  • Private clusters may require additional network configuration

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

GKE Cluster Access Manager is a CLI tool that simplifies access management for Google Kubernetes Engine (GKE) clusters.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages