Kconnect: Simplifying Kubernetes Connectivity With a Powerful CLI
Kconnect is a simple CLI tool that quickly connects to Kubernetes clusters like EKS, AKS, and RKS, saving time by generating kubeconfig files instantly.
Join the DZone community and get the full member experience.
Join For FreeLet's assume that if you want to connect to a Kubernetes cluster with multiple CSPs (EKS/AKS/RKS), you have to use respective CLI to generate kubeconfig and use kubectl commands. What if I say there is a better way for Cloud/Platform/DevOps and SRE Engineers to connect to clusters using kconnect
?
kconnect
is a Command-Line Interface (CLI) utility that can be used to discover and securely access Kubernetes clusters across multiple operating environments.
Based on the authentication mechanism chosen, the CLI will discover Kubernetes clusters you are allowed to access in a target hosting environment and generate a kubeconfig
for a chosen cluster. Currently, kconnect supports the following platforms: EKS, AKS, and Rancher.
Resolution
Using kconnect
, you can easily connect to multiple clusters and multiple regions seamlessly. This is a powerful tool for any troubleshooting, automating workloads like routine tasks, generating reports, etc. Below are some features, and we will go through detailed steps on how to use kconnect
.
Features
- Authenticate using SAML, Azure Active Directory, AWS IAM, and Rancher Token.
- Discover clusters in EKS, AKS, and Rancher.
- Generate a
kubeconfig
for a cluster. - Query history of connected servers.
- Regenerate the
kubeconfig
from your history by using an ID or an alias.
Prerequisites
Before getting started, we need to have below dependencies for EKS and AKS:
Installation
MacOS/Linux
The latest release contains the binaries here.
Alternatively, you can use the command below:
brew install fidelity/tap/kconnect
Windows
The latest release contains the binaries here.
Install the Binaries in One Go
Use the command below to install the binaries, i.e., kubectl
, helm
and aws-iam-authenticator
:
curl -fsSL -o install-kconnect.sh https://raw.githubusercontent.com/fidelity/kconnect/main/scripts/install-kconnect.sh
chmod 700 install-kconnect.sh
./install-kconnect.sh
Connecting to EKS Using Kconnect
Use the commands below to connect to the EKS cluster and authenticate to the cluster:
sh-3.2# kconnect use eks --idp-protocol saml
info kconnect - the Kubernetes Connection Manager CLI {"version": "0.5.18"}
info authenticating user {"app": "kconnect", "provider": "saml"}
? Select your identity provider ADFS
? Enter the endpoint for the IdP https://enteryouridpendpoint.yourcompanydomain.com
? Select an AWS region us-east-1
? Username: sogety
? Password: **************
sh-3.2# kubectl get pods -A
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system aws-node-5rjcg 2/2 Running 0 46m
kube-system aws-node-jglpd 2/2 Running 0 46m
kube-system aws-node-jtcm6 2/2 Running 0 46m
kube-system coredns-6556f9967c-spmcl 1/1 Running 0 50m
kube-system coredns-6556f9967c-xhkjg 1/1 Running 0 50m
kube-system ebs-csi-controller-8df7f678f-4zg2w 6/6 Running 0 46m
kube-system ebs-csi-controller-8df7f678f-65h7n 6/6 Running 0 46m
kube-system ebs-csi-node-422fg 3/3 Running 0 46m
kube-system ebs-csi-node-khwwq 3/3 Running 0 46m
kube-system ebs-csi-node-vtxkn 3/3 Running 0 46m
kube-system kube-proxy-6kcgr 1/1 Running 0 46m
kube-system kube-proxy-qk7gj 1/1 Running 0 46m
kube-system kube-proxy-r8f9p 1/1 Running 0 46m
Connecting to AKS Using Kconnect
Use the commands below to connect to the AKS cluster and authenticate to the cluster:
sh-3.2# kconnect use aks --idp-protocol aad
info kconnect - the Kubernetes Connection Manager CLI {"version": "0.5.18"}
info authenticating user {"app": "kconnect", "provider": "aad"}
? Username: sogety
? Password: **************
? Enter the Azure tenant ID **************
? Enter the Azure client ID **************
? Enter the Azure client secret **************
sh-3.2# kubectl get pods -A
Connecting to RKS Using Kconnect
Use the commands below to connect to the RKS cluster and authenticate to the cluster:
sh-3.2# kconnect use rancher
info kconnect - the Kubernetes Connection Manager CLI {"version": "0.5.18"}
info using static token for authentication {"app": "kconnect", "provider": "static-token"}
? Enter authentication token **************
? Enter the Rancher API endpoint **************
info discovering clusters {"app": "kconnect", "provider": "rancher"}
info discovering clusters via Rancher {"app": "kconnect", "provider": "rancher"}
sh-3.2# kubectl get pods -A
Conclusion
Authenticating multiple Kubernetes clusters across EKS, AKS, and RKS can be challenging, especially for platform engineers, DevOps teams, and SREs. This tool streamlines the process by generating kubeconfig
files on the fly, saving valuable time and effort. It’s particularly useful for automating workflows and managing clusters across different regions and environments. Based on my experience with EKS, AKS, and RKS, this approach has greatly simplified cluster authentication and improved efficiency across platforms.
Opinions expressed by DZone contributors are their own.
Comments