-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Secure the k2d API endpoint kubernetes.default.svc #14
Comments
The current implementation uses a secret to interact with the k2d specific API. Currently, only the API endpoint to retrieve the kubeconfig is protected by this secret based authentication. This implementation was developed to prevent anonymous users from retrieving the kubeconfig when k2d is publicly exposed. Currently, no authentication method is supported for the Kubernetes API. However, since we are already generating a token in the kubeconfig, we can improve this by ensuring that the token is used when communicating with the Kubernetes API as well as generating a stronger token. |
It's worth noting that Kubernetes will inject the necessary credentials by default in all pods/containers running inside the cluster. These credentials can be used to authenticate and execute requests to the Kubernetes API, as explained in this documentation: https://kubernetes.io/docs/tasks/run-application/access-api-from-pod/ Therefore, the current approach is similar, as it allows direct access to the Kubernetes API. However, it is essential to ensure that the Kubernetes API cannot be accessed from outside the cluster without some form of authentication. |
The approach I suggest for authentication is to leverage the secret passed to k2d (or automatically generated if not present) as the bearer token used for any request to the k2d API:
This will allow full access to the Kubernetes API via:
This means that the following command:
Would be changed to:
You could then query the Kubernetes API using the Authorization bearer as well:
Consideration:
This implies that instead of running the following command after starting k2d:
You would need to run the following command, therefore relying on the availability of
|
I think a reliance on base64 should be ok, just validate that MacOS/Windows OS have it installed by default... as that is where most users would connect from to retrieve the token. |
In the Alpha, the kubernetes API endpoint is not secured for communications with the emulated cluster. This means that any pod for any deployment has complete access to the emulated API, akin to "anonymous" access to the Kube API. This is not secure.
We already generate a kube access token, which is used for remote connections. We should also enforce the use of this when accessing the k2d endpoint from within the docker environment.
The text was updated successfully, but these errors were encountered: