Access with kubectl
Point kubectl at any cluster AstroPulse manages: EKS, GKE, AKS or registered. The kubeconfig holds no token, certificate or cloud session: kubectl runs astroctl to get a short-lived token, so you need astroctl signed in on your machine and nothing from your cloud. A self-hosted cluster gets a kubeconfig with its own client certificate instead (Self-hosted clusters), and --native signs in with your own cloud identity (below).
Before you start
astroctlinstalled and signed in on the machine that runskubectl: the setup guide. A self-hosted cluster's certificate kubeconfig and a--nativekubeconfig do not runastroctl.- An org admin role. The organization owner counts as one; other members are refused with
Insufficient organization permissions. - A plan with role-based access.
In the console
-
Open the cluster from the cluster list and select the Access tab: "Connect kubectl to <cluster>."
-
With astroctl (marked Recommended): "Install it and sign in once, then point kubectl at this cluster. No file to keep safe." Copy the three commands and run them: install
astroctl, sign in, andastroctl infra k8s set-context --cluster-name <cluster-name>. -
Or With a kubeconfig file: pick Valid for, then select Generate. "Save it now. It won't be shown again." Select Download, then use it with
export KUBECONFIG=./<cluster-name>-kubeconfig.yaml. Generate new makes another.Open zoom view
The downloaded file still runs astroctl to sign in, so astroctl must be installed and signed in wherever you use it.
You should see
kubectl get nodes
lists the cluster's nodes.
How access works
The kubeconfig holds no token, certificate or cloud session. kubectl runs astroctl as a credential plugin:
users:
- name: <cluster-name>
user:
exec:
apiVersion: client.authentication.k8s.io/v1
command: astroctl
args: ["infra", "k8s", "access-token", "--cluster-name", "<cluster-name>"]
interactiveMode: Never
astroctl infra k8s access-token returns a short-lived token, and astroctl
renews it on its own five minutes before it expires. kubectl keeps working with
no step from you until the duration ends.
One end time per cluster. You have one end time on each cluster for all your kubeconfigs that renew through AstroPulse. Generating a kubeconfig, from the console or astroctl, sets that end time for all of them, shorter included: a 1 hour kubeconfig from the console ends a 24 hour one from your terminal at the same moment. A file someone else generated works only while you have an end time of your own on that cluster.
Who the cluster sees. On a cluster AstroPulse created, kubectl acts as the
identity AstroPulse uses for that cluster, so every admin gets the same rights and
the cluster's own logs do not name the person. Audit Logs
(Enterprise plan) record who asked for each token, as a Credential event.
Organization. The token is issued in the organization astroctl is using when
kubectl runs it. After astroctl org use to another organization, kubectl is
refused for this cluster until you switch back.
Ending someone's access. Remove them from the organization, or lower their role below admin. That stops new tokens at once; a token already issued runs to its own expiry. No command ends a running duration. If access must end at an exact moment, remove the access of the identity AstroPulse uses for the cluster; that also stops everyone else's kubectl, and AstroPulse itself, until you restore it.
Sign in with your own cloud identity
Add --native to generate-kubeconfig. The kubeconfig then runs your cloud's
tool, carries no AstroPulse session and has no duration.
| Cluster | You need |
|---|---|
| EKS | AWS CLI v2 signed in to the account, and an EKS access entry for your IAM identity on the cluster |
| GKE | Google Cloud CLI with gke-gcloud-auth-plugin, gcloud auth login, and an IAM role on the project such as Kubernetes Engine Developer |
| AKS | Azure CLI signed in (az login), kubelogin, and an Azure RBAC role on the cluster such as Azure Kubernetes Service RBAC Cluster Admin |
| Self-hosted, registered | Not available. Generate without --native. |
--native on a self-hosted or registered cluster is refused; see If it's refused.
Self-hosted clusters
A self-hosted cluster's kubeconfig holds its own client certificate instead of running astroctl, and is generated in the background:
astroctl infra k8s generate-kubeconfig --cluster-name <cluster-name> --duration 4h
astroctl infra k8s set-context --cluster-name <cluster-name> # once it is ready, after a few minutes
The certificate lasts for the duration you chose. When it expires, generate a new one.
Other ways in
- Nova: ask "how do I get kubectl access to prod-eks?" and Nova returns the
astroctlcommand to run on your machine. - SDK and API: generate a kubeconfig for a cluster, and the access token
kubectluses. See the API reference.
With astroctl
astroctl infra k8s generate-kubeconfig --cluster-name <cluster-name> --duration 4h
kubectl get nodes
This writes the kubeconfig to the file $KUBECONFIG names (its first file) if it is set, else ~/.kube/config, and switches kubectl to it:
Kubeconfig generated and saved for cluster: <cluster-name>
This kubeconfig works for 4h, until <UTC time>; its access renews on its own until then. Your other kubeconfigs for this cluster that renew through AstroPulse now end then too. Generate a new one after that.
Written to <path>
kubectl context switched to "<context>" (was "<previous>")
Switch back with: kubectl config use-context <previous>
You can now use kubectl to access your cluster
With no earlier context, the two switched lines are instead
kubectl is now using context "<context>".
astroctl infra k8s set-context --cluster-name <cluster-name> writes the same
kubeconfig without choosing a duration: it starts the default hour if you have
none running, and never shortens one you have.
To remove the cluster from your kubeconfig:
astroctl infra k8s delete-context --cluster-name <cluster-name>
Settings
--durationHow long kubectl keeps access through this kubeconfig.
1h, 4h, 12h or 24h.1h--nativeSign in with your own cloud identity through your cloud's tool, instead of AstroPulse.
If it's refused
kubectl prints each message as sent.
astroctl infra k8s generate-kubeconfig --cluster-name <cluster-name>.Insufficient organization permissions, you are not an org admin.astroctl auth login and astroctl infra k8s get --cluster-name <cluster-name>. For a permissions refusal, ask an org owner for the admin role.Role-Based Access Control needs the <plan> plan; your organization is on <your plan>. See https://astropulse.io/pricingexec: executable astroctl not foundPATH.PATH.unknown command or unknown flag: --cluster-name from astroctlastroctl update, then astroctl infra k8s set-context --cluster-name <cluster-name>.Unauthorized from a cluster AstroPulse createdNotFound: No cluster is reachable at this address with this credential. If this kubeconfig is from an older astroctl, run astroctl infra k8s set-context --cluster-name <cluster> to refresh it.astroctl update, then astroctl infra k8s set-context --cluster-name <cluster-name>. Check that astroctl whoami shows the organization that owns the cluster.Unauthorized: Your AstroPulse access to this cluster has expired. kubectl gets a new access token on its next request; if this keeps happening, run astroctl infra k8s set-context --cluster-name <cluster> to refresh this kubeconfig.astroctl infra k8s set-context --cluster-name <cluster-name>.ServiceUnavailable: The cluster's agent has not reported its credential yet, so the request cannot be sent. Try again in a minute; if this persists, check the agent with astroctl infra k8s get --cluster-name <cluster>.astroctl infra k8s get --cluster-name <cluster-name> and check the agent.--native was used on a self-hosted cluster.--native.--native was used on a registered cluster.--native.