A new version of Anthos clusters on AWS (GKE on AWS) was released on December 17. See the release notes for more information.

Connecting to your cluster with kubectl

Before you begin

Before you start using Anthos clusters on AWS, make sure you have performed the following tasks:

The bastion host

To connect to your Anthos clusters on AWS resources, perform the following steps. Select if you have an existing AWS VPC (or direct connection to your VPC) or created a dedicated VPC when creating your management service.

Existing VPC

If you have a direct or VPN connection to an existing VPC, omit the line env HTTP_PROXY=http://localhost:8118 from commands in this topic.

Dedicated VPC

When you create a management service in a dedicated VPC, Anthos clusters on AWS includes a bastion host in a public subnet.

To connect to your management service, perform the following steps:

  1. Change to the directory with your Anthos clusters on AWS configuration. You created this directory when Installing the management service.

    cd anthos-aws

  2. To open the tunnel, run the bastion-tunnel.sh script. The tunnel forwards to localhost:8118.

    To open a tunnel to the bastion host, run the following command:

    ./bastion-tunnel.sh -N

    Messages from the SSH tunnel appear in this window. When you are ready to close the connection, stop the process by using Control+C or closing the window.

  3. Open a new terminal and change into your anthos-aws directory.

    cd anthos-aws
  4. Check that you're able to connect to the cluster with kubectl.

    env HTTP_PROXY=http://localhost:8118 \
    kubectl cluster-info

    The output includes the URL for the management service API server.

The commands in the following sections assume you are using this bastion host. If you are not using the bastion host, remove the lines containing HTTP_PROXY.

Connecting to your clusters with kubectl

Anthos clusters on AWS uses contexts in your kubeconfig for authentication to your management and user clusters. When you use anthos-gke aws management get-credentials for management services or anthos-gke aws clusters get-credentials cluster-0 for user clusters, anthos-gke creates a new context entry if necessary and sets the current context.

To switch between contexts, use kubectl config use context.

kubectl config use-context [CLUSTER_NAME]