Software Engineering

Easy methods to Replace Kubectl Config from AWS EKS

Easy methods to Replace Kubectl Config from AWS EKS
Written by admin


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 possibly can test this by typing:

aws sts get-caller-identity

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

It’s possible you’ll 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).

You probably have a profile you need to use going ahead, that isn’t the default, then you possibly can 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 have to 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 related to the cluster you needed, run the next command:

kubectl cluster-info

This can 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/dwelling#/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 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

Possibility 3 – Utilizing the EKSCtl

You may also 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 device.

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 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 need to use the set-context command to rapidly swap between Kubernetes/EKS clusters.

First you have to to know what config exists.

kubectl config view

As soon as this, you possibly can set a context:

kubectl config set-context 
  dev-context 
    --namespace=dev-namespace 
    --cluster=docker-desktop 
    --user=dev-user

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>

About the author

admin

Leave a Comment