Automatic discovery and registration of AKS clusters.
Flux Orchestrator now supports automatic discovery and management of Azure AKS clusters using Azure Service Principal authentication.
Create an Azure service principal with appropriate permissions:
# Login to Azure CLI
az login
# Create service principal with Contributor role
az ad sp create-for-rbac --name "flux-orchestrator-sp" \
--role "Azure Kubernetes Service Cluster User Role" \
--scopes /subscriptions/{subscription-id}
# Output will include:
# - appId (Client ID)
# - password (Client Secret)
# - tenant (Tenant ID)
Required Permissions:
Azure Kubernetes Service Cluster User Role - to list and access AKS clustersReader role on subscription - to discover resourcesOn your local machine or wherever Flux Orchestrator runs:
# macOS
brew install Azure/kubelogin/kubelogin
# Linux
wget https://github.com/Azure/kubelogin/releases/latest/download/kubelogin-linux-amd64.zip
unzip kubelogin-linux-amd64.zip
sudo mv bin/linux_amd64/kubelogin /usr/local/bin/
# Windows
choco install kubelogin
# Verify installation
kubelogin --version
Note: kube login must be available in the PATH where Flux Orchestrator runs.
┌─────────────────┐ ┌──────────────┐ ┌─────────────┐
│ Flux Orchestr. │────────▶│ Azure API │────────▶│ AKS Cluster │
│ (Service │◀────────│ (ARM) │◀────────│ │
│ Principal) │ └──────────────┘ └─────────────┘
└─────────────────┘ │
│ │
│ ▼
│ ┌──────────────────┐
│ │ Azure AD │
│ │ (Token Provider) │
└─────────────────▶└──────────────────┘
kubelogin
kubelogin exec plugin for token refreshThe generated kubeconfig uses the Kubernetes exec credential plugin:
users:
- name: clusterUser_resourceGroup_clusterName
user:
exec:
apiVersion: client.authentication.k8s.io/v1beta1
command: kubelogin
args:
- get-token
- --login
- spn # Service Principal
- --environment
- AzurePublicCloud
- --tenant-id
- {tenant-id}
- --server-id
- 6dae42f8-4368-4678-94ff-3960e28e3630 # AKS AAD Server
- --client-id
- {client-id}
- --client-secret
- {client-secret}
GET /api/v1/azure/subscriptions
POST /api/v1/azure/subscriptions
Content-Type: application/json
{
"name": "Production Subscription",
"subscription_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"tenant_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"client_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"client_secret": "your-secret-here"
}
POST /api/v1/azure/subscriptions/{subscription_id}/test
GET /api/v1/azure/subscriptions/{subscription_id}/clusters
POST /api/v1/azure/subscriptions/{subscription_id}/sync
Solution: Install kubelogin and ensure it’s in the PATH:
which kubelogin
# Should print: /usr/local/bin/kubelogin
Causes:
Solution:
az ad sp show --id {client-id}
az role assignment list --assignee {client-id}
Causes:
Solution:
az aks list --subscription {subscription-id}
az role assignment create \
--assignee {client-id} \
--role Reader \
--scope /subscriptions/{subscription-id}
Causes:
Solution:
az role assignment create \
--assignee {client-id} \
--role "Azure Kubernetes Service Cluster User Role" \
--scope /subscriptions/{subscription-id}/resourceGroups/{rg}/providers/Microsoft.ContainerService/managedClusters/{cluster-name}
az role assignment create \
--assignee {client-id} \
--role "Azure Kubernetes Service Cluster Admin Role" \
--scope /subscriptions/{subscription-id}
Kubelogin automatically refreshes tokens. If you see authentication errors:
kubelogin get-token \
--login spn \
--tenant-id {tenant-id} \
--client-id {client-id} \
--client-secret {client-secret} \
--server-id 6dae42f8-4368-4678-94ff-3960e28e3630
After syncing AKS clusters, configure RBAC in each cluster:
# Give service principal view access
apiVersion: rbac.authorization.k8s.io/v1
kind:ClusterRoleBinding
metadata:
name: flux-orchestrator-viewer
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: view
subjects:
- apiGroup: rbac.authorization.k8s.io
kind: User
name: {client-id}
| Feature | Azure Integration | Manual Kubeconfig |
|---|---|---|
| Discovery | Automatic | Manual |
| Setup | Service Principal | Export kubeconfig |
| Token Refresh | Automatic (kubelogin) | Manual refresh |
| Multi-Cluster | One-click sync | Individual setup |
| Credentials | Encrypted | Encrypted |
| Updates | Re-sync to update | Manual re-export |