{"id":29735881,"url":"https://github.com/moulick/cache-eks-token","last_synced_at":"2026-05-05T17:33:10.448Z","repository":{"id":305546444,"uuid":"1023159638","full_name":"Moulick/cache-eks-token","owner":"Moulick","description":"Script to cache eks token and make kubectl commands faster","archived":false,"fork":false,"pushed_at":"2025-07-22T17:25:30.000Z","size":432,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-04T19:49:04.303Z","etag":null,"topics":["aws","cache","eks","fast","kubectl","kubernetes"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Moulick.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-20T16:45:55.000Z","updated_at":"2025-08-30T21:01:13.000Z","dependencies_parsed_at":"2025-07-20T19:22:05.669Z","dependency_job_id":null,"html_url":"https://github.com/Moulick/cache-eks-token","commit_stats":null,"previous_names":["moulick/cache-eks-token"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Moulick/cache-eks-token","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moulick%2Fcache-eks-token","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moulick%2Fcache-eks-token/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moulick%2Fcache-eks-token/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moulick%2Fcache-eks-token/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Moulick","download_url":"https://codeload.github.com/Moulick/cache-eks-token/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moulick%2Fcache-eks-token/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279134207,"owners_count":26110951,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-15T02:00:07.814Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","cache","eks","fast","kubectl","kubernetes"],"created_at":"2025-07-25T14:01:16.227Z","updated_at":"2025-10-16T00:58:17.259Z","avatar_url":"https://github.com/Moulick.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cache AWS EKS Token\n\nThis is a script that is used to speed up kubectl when using AWS EKS. This works by caching the eks token from AWS.\nThe speed increase for a simple `kubectl get pods` is ~73%. It's really noticeable.\n\nThe default way is to use `aws eks get-token` command, but it is not cached and it is not very fast.\nIt's slow because:\n1. Every kubectl command will do a `aws eks get-token` which makes an api call to AWS\n2. `aws` is python. When running kubectl in a script, you can very clearly see how much performance is lost generating tokens for each kubectl invocation in Activity Monitor.\n\nHere is a quick comparison before and after\n\n| Before                | After                 |\n| --------------------- | --------------------- |\n| ![Slow](img/slow.gif) | ![Fast](img/fast.gif) |\n\n\n# How to use\n1. Clone repo\n2. cd into the repo and `chmod +x cached-aws-eks-token.sh`. Necessary as git clone removes the executable flag from files.\n3. Simply replace the `command: aws` with `command: ../cache-eks-token/cached-aws-eks-token.sh` in your `~/.kube/config` files.\n   1. The command might differ based on where you placed the script.\n\n\u003e [!IMPORTANT]\n\u003e Remember to update your kubeconfig with the above script whenever you create a new kubeconfig or use `aws eks update-kubeconfig` to generate/update as it will replace it back with `command: aws`, wasting time in your life :)\n\n## How it works\nThis script will caches the token generated by `aws eks get-token` in a file based on cluster name in the `$HOME/.kube/cache` directory.\nAWS issues token for at-most 15 mins. This script will check the expiry and return existing token if it's till valid.\nThe token will be refreshed if it's expiring within 30 seconds.\n\n## Errors\n\n1. `Unable to connect to the server: getting credentials: exec: ... permission denied`\n   1. simply run `chmod +x cached-aws-eks-token.sh`\n2. If error like `Unable to connect to the server: getting credentials: ... no such file or directory`\n   1. Make sure to make the command path is relative to wherever the script exists. You can use `../` in the `command` to move up directories.\n3. `Failed conversion of ``'' using format ``%Y-%m-%dT%H:%M:%SZ''`\n   1. Happens when unable to get the date from the cache file. Try deleing the token cache files from `$HOME/.kube/cache`\n   2. The cache file generated by the script should looks like this\n      ```json\n      {\n        \"kind\": \"ExecCredential\",\n        \"apiVersion\": \"client.authentication.k8s.io/v1beta1\",\n        \"spec\": {},\n        \"status\": {\n          \"expirationTimestamp\": \"2025-07-20T17:38:15Z\",\n          \"token\": \"k8s-aws-v1.\u003ctoken\u003e\"\n        }\n      }\n      ```\n\n## Dependencies\n1. jq `brew install jq`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoulick%2Fcache-eks-token","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoulick%2Fcache-eks-token","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoulick%2Fcache-eks-token/lists"}