freeleaps-ops/cluster/bin
2025-05-09 15:25:14 +08:00
..
freeleaps-cluster-authenticator ci(bump): update freeleaps-cluster-authenticator version to 0.0.3-20250509 and add refresh-auth command 2025-05-09 15:25:14 +08:00
infra-auth-retriver feat(auth): add infra-auth-retriever script for retrieving service authentication 2025-03-04 00:31:44 +08:00
README.md docs: add README files for Freeleaps repo migrator and cluster authenticator 2025-03-25 17:22:29 +08:00

Freeleaps Cluster Authenticator

Helps to kubectl authenticated to Freeleaps Kubernetes Cluster.

Prerequisites

  • mathmast.com Azure Directory account
  • Linux with Shell / Bash support
  • Internet access

How to use ?

First, you need grant this script to executable with commands:

chmod ug+x freeleaps-cluster-authenticator

Now, you can get help text with commands:

freeleaps-cluster-authenticator -h

Freeleaps Cluster Authentication requires some tools to ensure authentication workflow, please check belows and make sure they are installed on your device:

  • curl
  • unzip
  • uname
  • jq

Once the required tools are installed, you can using command:

freeleaps-cluster-authenticator auth

to start authentication workflow.

Once authentication workflow started, Freeleaps Cluster Authenticator will check the requirements and automatically install kubectl and kubelogin if not found.

The console output should be like:

[GATHER] Checking OS and architecture...
[INFO] OS: linux
[INFO] Architecture: amd64
[PREREQUISITES] Checking for required tools...
[PREREQUISITES] curl: ✓
[PREREQUISITES] unzip: ✓
[PREREQUISITES] uname: ✓
[PREREQUISITES] kubectl: ✓
[PREREQUISITES] kubelogin: ✓
[PREREQUISITES] jq: ✓

And will shows [SETUP] Setting up kubelogin... if prerequisites checking passed.

Now you can open http://127.0.0.1:8000 with your browser, it will redirect to Microsoft login page, you can login Freeleaps Kubernetes Cluster with your mathmast.com Azure Directory account.

Console will shows [SETUP] kubelogin setup completed successfully. when authenticated successfully.

Now the Freeleaps Cluster Authenticator will prompt you to input your mathmast Azure Directory account name (ends with @mathmast.com):

[GATHER] Checking OS and architecture...
[INFO] OS: linux
[INFO] Architecture: amd64
[PREREQUISITES] Checking for required tools...
[PREREQUISITES] curl: ✓
[PREREQUISITES] unzip: ✓
[PREREQUISITES] uname: ✓
[PREREQUISITES] kubectl: ✓
[PREREQUISITES] kubelogin: ✓
[PREREQUISITES] jq: ✓
[SETUP] Setting up kubelogin...
[SETUP] kubelogin setup completed successfully.
[PROMPT] Please enter your Mathmast account name (ending with @mathmast.com, eg. jack@mathmast.com):

You can enter your mathmast.com Azure Directory account name and press enter to submit.

The Freeleaps Cluster Authenticator will automatically finish setting works when you submit your mathmast.com Azure Directory account name and the console should be like:

[PROMPT] Username: zhenyus@mathmast.com
[KUBECTL & KUBE_LOGIN] Setting kubectl credentials for zhenyus@mathmast.com...
[KUBECTL & KUBE_LOGIN] Credentials set successfully.
[KUBECTL] Adding cluster (named to: freeleaps-cluster) to kubectl...
[KUBECTL] Cluster added to kubectl successfully.
[KUBECTL] Creating kubectl context...
[KUBECTL] Context created successfully.
[KUBECTL] Using kubectl context...
[KUBECTL] Context set successfully.
[KUBECTL] Checking whoami...
ATTRIBUTE   VALUE
Username    zhenyus@mathmast.com
Groups      [mathmast:admin system:authenticated]
[INFO] Your kubectl has been authenticated with your Mathmast account.
[INFO] Now you can try to using kubectl to interact with the cluster.

Now you are already finished authentication for Freeleaps Kubernetes Cluster.

You can using kubectl to work with Freeleaps Kubernetes CLuster right now.

Commands

Freeleaps Cluster Authenticator provides lots of useful command to help you complete authentication flow.

Command Alias Usage
auth -a,--auth Setup kubectl for Freeleaps Kubernetes Cluster with provides mathmast.com Azure Directory account
reset-auth -r,--reset-auth Reset kubectl authentication state
clear -c,--clear Clear authentication
doctor -d, --doctor Check if all the required tools are installed
dashboard -db, --dashboard Open dashboard for Freeleaps Kubernetes Cluster and forward the port to localhost and listen on 8443
get-token -gt, --get-token Get the token for the current user, usually to using for Kubernetes Dashboard authentication