rancher: Fail to provision AKS private cluster: "error generating service account"
Rancher Server Setup
- Rancher version: 2.7.5-rc1
- Installation option: Helm
- If Helm Chart, Kubernetes Cluster and version: AKS with Kubernetes v1.25.5
Information about the Cluster
- Kubernetes version: v1.25.5
- Cluster Type: AKS cluster
User Information
- What is the role of the user logged in? Admin
Describe the bug This issue was found during validation of version 2.7.5-rc1.
A similar, very detailed, issue was reported last year rancher/rancher#37164 but looks like this is still happening.
Provisioning a private AKS cluster (selecting the ‘Enable Private Cluster’) successfully creates the required resources in Azure but, after running the registration command in the provisioned cluster, it fails to establish connection between Rancher and AKS.
To enable communication with the private cluster, cluster agent opens a tunnel to connect the managed cluster with Rancher. For some unknown reason the tunnel is not providing the expected connectivity.
To Reproduce
- Using Rancher UI, provision a new AKS cluster
- Configure the cluster to be private: Networking Options -> Show advanced options -> Enable Private Cluster
- Connect to the AKS cluster and apply the registration command provided by Rancher: via a bastion VM or using
az aks command invoke --resource-group <rg> --name <cluster> --command "kubectl <command>"
Result
The cluster gets stuck in Waiting state with error:
Failed to communicate with cluster: error generating service account token:
Logs from aks-operator and cattle-cluster-agent apparently do not contain errors.
Expected Result Investigate this issue to understand how the tunnel works and what’s causing the connectivity error.
Ideally, the cluster agent connection between Rancher and managed cluster is established and the cluster appears as Active in the UI.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 23 (19 by maintainers)
It seems hostname of AKS private cluster exceeding 100 char limit caused this failure. Using this theory I was also able to reproduce this issue in the
eastusregion, where previously I was able to successfully provision a private cluster.Great job on finding the cause and fixing it @rohitsakala 🎉
@rohitsakala I tested on v2.11-7b3687b2e6fc130b8931e5b4eed28180cc5e3e2a-head.
eastusworks well, but I was able to reproduce incentralindia, consistently; even with system-store.No
We could reproduce this issue on v2.11-head today with @valaparthvi. We observed that sometimes the cluster-agent on Private AKS cluster in unable to initiate the wss connection to rancher so rancher is keep trying to do a direct api call to the AKS cluster which fails:
From the cluster-agent logs on AKS it seems the wss reverse tunnel is probably not initiated although its pod is
Running. The logs are stuck onConnecting to ....Interesting is that for some regions like
canadacentralit’s working fine but “sometimes” it doesn’t work fromcentralindiaregion (both tried on the same local rancher cluster). We did not touch tls-mode settings in rancher.The error message:
is appearing in some cases. There is a race condition somewhere, preventing agent setup. To understand what is wrong at least the size of the remotedialer error messages should be increased. Right now it is trimmed to 100 bytes as per https://github.com/rancher/remotedialer/blob/0018e88e72de6eb8714acab029ea01376d4678e2/message.go#L180C54-L180C54. Is it
dial tcp too many colons in address?.. Simply can’t say. Some private clusters come up normally and experience no issues with connectivity. Potential areas of the issue - networking, remotedialer setup.