Easy methods to 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 remember to have legitimate AWS Credentials setup in your aws cli.

You’ll be able to test this by typing:

aws sts get-caller-identity

This may let you already know the place your aws cli is pointing to.

You could 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 need to use going ahead, that isn’t the default, then you may export it into the present CLI session. This may 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 will want to get aws cli to replace the native ~/.kube/config file for you.

To do that, exchange 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 is best to get a response that appears one thing like:

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

Step 3 – Confirm Cluster Info

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

kubectl cluster-info

This may output one thing like:

Kubernetes management airplane is working at https://xxxxx.xxx.<area>.eks.amazonaws.com
CoreDNS is working at https://xxxxx.xxx.<area>.eks.amazonaws.com/api/v1/namespaces/kube-system/providers/kube-dns:dns/proxy

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?

Possibility 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 https://console.aws.amazon.com/eks/house#/clusters.
  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 Verify.The replace takes a number of minutes to finish.

Possibility 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 need to improve to

This may 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

Possibility 3 – Utilizing the EKSCtl

You may as well 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 software.

How do I get Kubeconfig file?

You will 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 could actually 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 should utilize the set-context command to shortly swap between Kubernetes/EKS clusters.

First you will want to know what config exists.

kubectl config view

As soon as you already know 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 change:

kubectl config use-context <context-name>