@Arjun Here are some possible solutions that might help:
- Ensure that the Kubernetes cluster is accessible to Azure DevOps at the time-of-service connection configuration.
- Check if the service account secret is listed and follow the steps mentioned in this Stack Overflow post to fix it.
- If you’re using a pre-created Kubernetes configuration stored locally, make sure that it’s accessible to Azure DevOps at the time-of-service connection configuration.
- If you’re using the ‘kubeconfig’ option, install kubectl and kubelogin on your self-hosted build agent and use shell scripts to create a service connection.
- Create a service account in your AKS with a secret and use it to create a service connection
Please go through these posts on similar issue and try the suggested solutions:
- https://learn.microsoft.com/en-us/answers/questions/1377376/i-am-unable-to-create-kubernetes-service-connectio
- https://learn.microsoft.com/en-us/answers/questions/1381440/i-am-unable-to-create-kubernetes-service-connectio
- https://learn.microsoft.com/en-us/answers/questions/1407156/unable-to-create-service-connection-for-kubernetes
If your issue remains unresolved or have further questions, please let us know in the comments and I can further investigate.