Skip to content

Instantly share code, notes, and snippets.

@lemin-ou
Created May 13, 2024 21:22
Show Gist options
  • Save lemin-ou/ed38f19999f9a55c6c2063fe1bbb8ed3 to your computer and use it in GitHub Desktop.
Save lemin-ou/ed38f19999f9a55c6c2063fe1bbb8ed3 to your computer and use it in GitHub Desktop.
Kubeconfig for EKS
#!/bin/bash
# resource that will help you setup mutli-cluster configuration : https://docs.aws.amazon.com/eks/latest/userguide/create-kubeconfig.html
read -r -d '' KUBECONFIG <<EOF
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: $certificate_data
server: $cluster_endpoint
name: arn:aws:eks:$region_code:$account_id:cluster/$cluster_name
contexts:
- context:
cluster: arn:aws:eks:$region_code:$account_id:cluster/$cluster_name
user: arn:aws:eks:$region_code:$account_id:cluster/$cluster_name
name: arn:aws:eks:$region_code:$account_id:cluster/$cluster_name
current-context: arn:aws:eks:$region_code:$account_id:cluster/$cluster_name
kind: Config
preferences: {}
users:
- name: arn:aws:eks:$region_code:$account_id:cluster/$cluster_name
user:
exec:
apiVersion: client.authentication.k8s.io/v1beta1
command: aws
args:
- --region
- $region_code
- eks
- get-token
- --cluster-name
- $cluster_name
# - --role
# - "arn:aws:iam::$account_id:role/my-role"
env:
- name: "AWS_PROFILE"
value: "default"
EOF
# echo "${KUBECONFIG}" > ~/.kube/config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment