- π Flexible Authentication - Interactive Azure login or Service principal authentication
- π Cluster Management - Start, stop, and check cluster status
- π Smart File Upload - Automatic detection and upload of required files
- π― Direct Command Execution - Run kubectl/helm commands without Azure CLI syntax
- β‘ Enhanced Experience - Verbose output, error handling, and command result retrieval
- π‘οΈ Secure - Works with private AKS clusters behind firewalls
- Azure CLI (
az) installed and configured - Go 1.21+ (for building from source)
- Access to an AKS cluster with command invoke permissions
- Either: Interactive access to Azure CLI OR Azure Service Principal with appropriate permissions
# Download and run the install script
curl -fsSL https://raw.githubusercontent.com/open-factoryai/xks/main/scripts/install.sh | bash
# Or with custom install directory
curl -fsSL https://raw.githubusercontent.com/open-factoryai/xks/main/scripts/install.sh | bash -s -- -d ~/.local/bingit clone https://github.com/open-factoryai/xks.git
cd xks
go mod tidy
go build -o xks
sudo mv xks /usr/local/bin/# Show help
./scripts/install.sh --help
# Install to custom directory
./scripts/install.sh -d ~/.local/bin
# Uninstall
./scripts/install.sh --uninstallXKS supports two authentication methods with automatic fallback:
- Interactive Login (Recommended) - Uses
az login - Service Principal - For automation and CI/CD
Simply ensure you're logged in with Azure CLI:
# Login to Azure (if not already done)
az login
# That's it! XKS will use your existing authentication
./xks kubectl get podsCreate a .env file for service principal authentication:
# Azure Service Principal (optional - for automation)
AZURE_TENANTID=your-tenant-id
AZURE_APPID=your-app-id
AZURE_SECRETID=your-secret
AZURE_SUBSCRIPTION=your-subscription-id-or-name
# AKS Cluster Info (required)
AKS_RESOURCE_NAME=your-resource-group
AKS_NAME=your-aks-cluster| Variable | Description | Required | Example |
|---|---|---|---|
AKS_RESOURCE_NAME |
Resource group containing AKS cluster | β | my-rg-prod |
AKS_NAME |
AKS cluster name | β | my-aks-cluster |
AZURE_TENANTID |
Azure tenant ID | β‘ Optional* | 12345678-1234-1234-1234-123456789012 |
AZURE_APPID |
Service principal application ID | β‘ Optional* | 87654321-4321-4321-4321-210987654321 |
AZURE_SECRETID |
Service principal secret | β‘ Optional* | your-secret-value |
AZURE_SUBSCRIPTION |
Azure subscription ID or name | β‘ Optional | My Production Subscription |
*Required only for service principal authentication. XKS will first try interactive login, then fallback to service principal if configured.
XKS automatically handles authentication with this priority:
- Check existing authentication - Uses current
az loginsession if valid - Interactive login - Prompts for
az loginif not authenticated - Service principal fallback - Uses
.envcredentials if interactive fails
# Example: First run triggers authentication
./xks kubectl get pods
# π Attempting interactive login...
# β
Interactive login successful
# Subsequent runs use cached authentication
./xks kubectl get services
# β
Already authenticated.# π’ Start AKS cluster
./xks start
# π΄ Stop AKS cluster
./xks stop
# βΉοΈ Check cluster status
./xks status# Get pods
./xks kubectl get pods
# Get all resources
./xks kubectl get all -A
# Apply configuration
./xks kubectl apply -f deployment.yaml
# Delete resources
./xks kubectl delete -f deployment.yaml# List releases
./xks helm list
# Install chart
./xks helm install my-app ./chart-directory
# Upgrade release
./xks helm upgrade my-app ./chart-directory --values values.yaml# π Get resources
./xks kubectl get pods
./xks kubectl get services
./xks kubectl get deployments -n kube-system
# π Apply configurations
./xks kubectl apply -f deployment.yaml
./xks kubectl apply -f file1.yaml -f file2.yaml
./xks kubectl apply -k ./kustomize-directory
# π Describe resources
./xks kubectl describe pod my-pod
./xks kubectl describe service my-service
# π Scale deployments
./xks kubectl scale deployment my-app --replicas=5
# π Port forwarding
./xks kubectl port-forward svc/my-service 8080:80
# π View logs
./xks kubectl logs -f deployment/my-app
./xks kubectl logs --since=1h my-pod
# π₯οΈ Execute commands in pods
./xks kubectl exec -it my-pod -- /bin/bash
./xks kubectl exec my-pod -- env
# π·οΈ Label and annotate
./xks kubectl label pods my-pod environment=production
./xks kubectl annotate service my-service description="Main API service"
# π Rolling updates
./xks kubectl rollout status deployment/my-app
./xks kubectl rollout restart deployment/my-app
./xks kubectl rollout undo deployment/my-app# π¦ Repository management
./xks helm repo add bitnami https://charts.bitnami.com/bitnami
./xks helm repo update
# π Install applications
./xks helm install my-app ./charts/my-app
./xks helm install nginx bitnami/nginx
./xks helm install postgres bitnami/postgresql --values postgres-values.yaml
# π Upgrade releases
./xks helm upgrade my-app ./charts/my-app
./xks helm upgrade my-app ./charts/my-app --values prod-values.yaml --set image.tag=v2.0
# π List and status
./xks helm list --all-namespaces
./xks helm status my-app
./xks helm history my-app
# βͺ Rollback
./xks helm rollback my-app 1
./xks helm rollback my-app --revision=3
# ποΈ Uninstall
./xks helm uninstall my-app
./xks helm uninstall my-app --keep-history
# π§ͺ Testing and debugging
./xks helm install my-app ./charts/my-app --dry-run --debug
./xks helm test my-app# π§ Using --command flag
./xks --command "kubectl get pods"
./xks --command "kubectl apply -f deployment.yaml" --file deployment.yaml
# π€ Manual file specification
./xks --command "kubectl apply -f app.yaml" --file ./configs/ --file app.yaml
# π Verbose output
./xks -v kubectl get pods
./xks --verbose helm list
# β³ No-wait mode (for long-running commands)
./xks --no-wait kubectl apply -f large-deployment.yaml
# π Custom output formats
./xks --output json kubectl get pods
./xks --output yaml kubectl get service my-service
# π Query results with JMESPath
./xks --query "items[?status.phase=='Running'].metadata.name" kubectl get pods -o json
./xks --query "spec.ports[0].port" kubectl get service my-service -o json
# π Debug mode
./xks --debug kubectl get pods
./xks --debug --verbose helm install my-app ./chart
# π Get command results
./xks --get-result --command-id <command-id>
# π Azure CLI options passthrough
./xks --command "kubectl get pods" --output json --query "[?status.phase=='Running']"XKS automatically detects and uploads files referenced in your commands:
- kubectl:
-f,--filename,-k,--kustomizeflags - Helm: Chart directories and values files
- Manual: Use
--fileto specify files/directories explicitly
# β
Automatic file detection
./xks kubectl apply -f app.yaml
# β
Multiple files
./xks kubectl apply -f deployment.yaml -f service.yaml -f configmap.yaml
# β
Kustomize
./xks kubectl apply -k ./overlays/production
./xks kubectl apply -k ./base
# β
Helm charts
./xks helm install myapp ./charts/myapp
./xks helm upgrade myapp ./charts/myapp --values values-prod.yaml
# β
Complex scenarios
./xks kubectl apply -f ./k8s/ -k ./overlays/staging
./xks helm install app ./charts/app --values ./values/prod.yaml --values ./values/secrets.yamlClick me !
π xks/
βββ π main.go # Point d'entrΓ©e
βββ π cmd/
β βββ πroot.go # Commandes CLI
βββ π azure/
β βββ πconfig.go # Configuration
β βββ πauth.go # Authentification
β βββ πcommand.go # ExΓ©cution commandes
βββ π Makefile # Automatisation build
βββ π .env.example # Exemple configuration
βββ π README.md # Documentation
Note: The actual project structure may vary. Check the repository for the most current organization.
XKS consists of several key components:
- AuthClient: Handles Azure authentication with interactive and service principal support
- ClusterManager: Manages AKS cluster lifecycle (start/stop/status)
- CommandRunner: Executes commands with intelligent file handling
- Config: Manages environment configuration and validation
- FileDetector: Smart file detection and upload optimization
graph TD
A[Command Input] --> B[Parse Command]
B --> C{File Flags Found?}
C -->|Yes| D[Extract File Paths]
C -->|No| E[Check Manual Files]
D --> F[Validate File Existence]
E --> F
F --> G[Remove Duplicates]
G --> H[Upload to AKS]
H --> I[Execute Command]
# Complete application deployment
./xks kubectl create namespace myapp
./xks kubectl apply -f ./k8s/configmap.yaml
./xks kubectl apply -f ./k8s/secret.yaml
./xks kubectl apply -f ./k8s/deployment.yaml
./xks kubectl apply -f ./k8s/service.yaml
./xks kubectl apply -f ./k8s/ingress.yaml
# Check deployment status
./xks kubectl rollout status deployment/myapp -n myapp
./xks kubectl get pods -n myapp -w# Resource monitoring
./xks kubectl top nodes
./xks kubectl top pods --all-namespaces
# Troubleshooting
./xks kubectl describe pod failing-pod
./xks kubectl logs -f deployment/myapp --previous
./xks kubectl get events --sort-by=.metadata.creationTimestamp
# Network debugging
./xks kubectl exec -it debug-pod -- nslookup my-service
./xks kubectl exec -it debug-pod -- curl -v http://my-service:8080/health# ConfigMaps and Secrets
./xks kubectl create configmap app-config --from-file=./config/
./xks kubectl create secret generic app-secrets --from-env-file=.env.prod
# Kustomize deployments
./xks kubectl apply -k ./overlays/development
./xks kubectl apply -k ./overlays/staging
./xks kubectl apply -k ./overlays/production# Complete Helm workflow
./xks helm create myapp
./xks helm lint ./myapp
./xks helm install myapp ./myapp --dry-run --debug
./xks helm install myapp ./myapp --wait --timeout=300s
# Production deployment
./xks helm upgrade myapp ./myapp \
--values ./values-prod.yaml \
--set image.tag=v1.2.3 \
--set replicas=5 \
--wait# You can create a shortcut by adding the following line to your ~/.zshrc or ~/.bash_profile after adding the xks tool in your PATH or in /usr/local/bin
alias kubectl="xks kubectl"
alias helm="xks helm"
# then you can use directly kubectl or helm commands
kubectl get pods -A
helm list
# Check current authentication status
az account show
# Re-authenticate if needed
az login
# For service principal issues, test credentials manually
az login --service-principal \
--username $AZURE_APPID \
--password $AZURE_SECRETID \
--tenant $AZURE_TENANTID
# Verify cluster access permissions
az aks show --name $AKS_NAME --resource-group $AKS_RESOURCE_NAME# Use explicit file specification
./xks --command "kubectl apply -f app.yaml" --file app.yaml
# Check file permissions
ls -la app.yaml
chmod 644 app.yaml
# Debug file detection
./xks --debug -v kubectl apply -f app.yaml# Verify cluster status
./xks status
# Check cluster accessibility
az aks command invoke \
--resource-group $AKS_RESOURCE_NAME \
--name $AKS_NAME \
--command "kubectl get nodes"# Use no-wait for long operations
./xks --no-wait kubectl apply -f large-deployment.yaml
# Check operation result later
./xks --get-result
# Increase timeout (if available)
./xks --timeout=600 kubectl apply -f complex-deployment.yamlEnable comprehensive debugging:
# Full debug output
./xks --debug --verbose kubectl get pods
# Save debug output
./xks --debug kubectl get pods 2>&1 | tee debug.log
# Check XKS version and config
./xks version
./xks config show- Requires Azure CLI to be installed and accessible
- User or service principal must have
Azure Kubernetes Service Cluster Userrole - File uploads are limited by Azure's size restrictions (~4MB)
- Commands are executed in the context of AKS cluster's command service
- Network policies may affect certain kubectl operations
- Some interactive commands may not work as expected
We welcome contributions! Here's how to get started:
# Fork and clone
git clone https://github.com/yourusername/xks.git
cd xks
# Install dependencies
go mod tidy
# Run tests
go test ./...
# Build locally
go build -o xks- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Add tests if applicable
- Ensure all tests pass (
go test ./...) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
# Run all tests
go test ./...
# Run tests with coverage
go test -cover ./...
# Run specific test
go test ./internal/auth -vThis project is licensed under the MIT License - see the LICENSE file for details.
- π Issues: GitHub Issues
- π¬ Discussions: GitHub Discussions
- π Documentation: Wiki
- π§ Email: open.factoryia@gmail.com
- Azure Kubernetes Service team for the command invoke functionality
- The Kubernetes and Helm communities
- All contributors and users of XKS
β If this project helps you, please give it a star!
Made with β€οΈ by FBO
