Replace Kubectl Config from AWS EKS



Ever looked for kubectl replace config from aws eks and wanted a fast end result?

Step 1 – Validate AWS CLI

Just be sure you have legitimate AWS Credentials setup in your aws cli.

You’ll be able to test this by typing:

aws sts get-caller-identity

This can let you understand the place your aws cli is pointing to.

You might must replace your ~/.aws/credentials file with a profile_name, aws_access_key_id, aws_secret_access_key and aws_session_token if these are generated for you by your Single Signal On (SSO).

When you have a profile you wish to use going ahead, that isn’t the default, then you may export it into the present CLI session. This can forestall you having to sort --profile <profile_name> every time you make an API name.

export AWS_PROFILE=<profile_name_in_credentials_file>

Step 2 – Replace Kubectl Config

Subsequent you’ll need to get aws cli to replace the native ~/.kube/config file for you.

To do that, substitute the next together with your cluster_name and aws_region it’s deployed in:

aws eks update-kubeconfig --name <your_eks_cluster_name> --region <aws_region>

If this was profitable, it’s best to get a response that appears one thing like:

Added new context arn:aws:eks:<area>:<accountnumber>:cluster/<clustername> to /Customers/consumer/.kube/config

Step 3 – Confirm Cluster Info

To ensure that you’re related to the cluster you wished, run the next command:

kubectl cluster-info

This can output one thing like:

Kubernetes management aircraft is working at<area>
CoreDNS is working at<area>

To additional debug and diagnose cluster issues, use 'kubectl cluster-info dump'.

How do I replace my Kubeconfig file?

aws eks update-kubeconfig --name <your_eks_cluster_name> --region <aws_region>

How do I improve AWS EKS?

Choice 1 – From the AWS Administration Console

You are able to do this straight from the AWS Administration Console.

  1. Open the Amazon EKS console at
  2. Select the identify of the Amazon EKS cluster to replace and select Replace cluster model.
  3. For Kubernetes model, choose the model to replace your cluster to and select Replace.
  4. For Cluster identify, enter the identify of your cluster and select Affirm.The replace takes a number of minutes to finish.

Choice 2 – From the AWS CLI

Alternatively, from the AWS CLI, you are able to do the next:

aws eks update-cluster-version 
 --region <area> 
 --name <cluster-name> 
 --kubernetes-version 1.22 # specify the model you wish to improve to

This can offer you a replace id, which you should utilize to question the cluster improve because it progresses:

aws eks describe-update 
  --region <area> 
  --name <cluster-name> 
  --update-id abc12318-9a87-xxxx-b5a0-825e6e844789

Choice 3 – Utilizing the EKSCtl

You can even use the EKSCtl to do that for you:

eksctl improve cluster --name <cluster-name> --approve

What’s Kubeconfig file in Kubernetes?

The kubeconfig is a file used to configure entry to Kubernetes when used together with the kubectl CLI instrument.

How do I get Kubeconfig file?

You may get the kubeconfig file by working the next command:

aws eks update-kubeconfig --region <area> --name <cluster-name>

How lengthy does EKS improve take?

It might take round 20 minutes to create and put together an EKS cluster, depending on the quantity of nodes and configuration required.

How do I modify the context in kubectl?

You need to use the set-context command to rapidly change between Kubernetes/EKS clusters.

First you’ll need to know what config exists.

kubectl config view

As soon as you understand this, you may set a context:

kubectl config set-context 

Subsequent we are able to see what the present context is:

kubectl config current-context

This now permits us to use-context to modify:

kubectl config use-context <context-name>