{"id":13545820,"url":"https://github.com/ahmetb/kubectl-aliases","last_synced_at":"2025-04-09T11:04:11.095Z","repository":{"id":37458477,"uuid":"107304714","full_name":"ahmetb/kubectl-aliases","owner":"ahmetb","description":"Programmatically generated handy kubectl aliases.","archived":false,"fork":false,"pushed_at":"2024-06-18T12:34:15.000Z","size":174,"stargazers_count":3390,"open_issues_count":5,"forks_count":837,"subscribers_count":59,"default_branch":"master","last_synced_at":"2024-10-29T15:34:38.061Z","etag":null,"topics":["kubectl","kubernetes"],"latest_commit_sha":null,"homepage":"https://ahmet.im/blog/kubectl-aliases/","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/ahmetb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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}},"created_at":"2017-10-17T17:56:30.000Z","updated_at":"2024-10-28T17:19:13.000Z","dependencies_parsed_at":"2024-11-19T09:06:04.281Z","dependency_job_id":"fe046090-6ed3-4dfb-9519-7966b62563d9","html_url":"https://github.com/ahmetb/kubectl-aliases","commit_stats":{"total_commits":59,"total_committers":14,"mean_commits":4.214285714285714,"dds":0.4067796610169492,"last_synced_commit":"ac5bfb00a1b351e7d5183d4a8f325bb3b235c1bd"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmetb%2Fkubectl-aliases","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmetb%2Fkubectl-aliases/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmetb%2Fkubectl-aliases/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahmetb%2Fkubectl-aliases/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ahmetb","download_url":"https://codeload.github.com/ahmetb/kubectl-aliases/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248027404,"owners_count":21035594,"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","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":["kubectl","kubernetes"],"created_at":"2024-08-01T12:00:20.399Z","updated_at":"2025-04-09T11:04:11.078Z","avatar_url":"https://github.com/ahmetb.png","language":"Shell","funding_links":[],"categories":["API/CLI adaptors","Useful Links","Nu","Tools and Libraries","Uncategorized","Shell","kubernetes"],"sub_categories":["[Jenkins](#jenkins)","Pod Management","Command Line Tools","Uncategorized"],"readme":"# kubectl-aliases\n\nThis repository contains [a script](generate_aliases.py) to generate hundreds of\nconvenient shell aliases for kubectl, so you no longer need to spell out every single\ncommand and --flag over and over again.\n\nAn example shell alias created from command/flags permutation looks like:\n\n    alias ksysgdepwslowidel='kubectl --namespace=kube-system get deployment --watch --show-labels -o=wide -l'\n\nConfused? Read on.\n\n### Examples\n\nSome of the 800 generated aliases are:\n\n```sh\nalias k='kubectl'\nalias kg='kubectl get'\nalias kgpo='kubectl get pod'\n\nalias ksysgpo='kubectl --namespace=kube-system get pod'\n\nalias krm='kubectl delete'\nalias krmf='kubectl delete -f'\nalias krming='kubectl delete ingress'\nalias krmingl='kubectl delete ingress -l'\nalias krmingall='kubectl delete ingress --all-namespaces'\n\nalias kgsvcoyaml='kubectl get service -o=yaml'\nalias kgsvcwn='kubectl get service --watch --namespace'\nalias kgsvcslwn='kubectl get service --show-labels --watch --namespace'\n\nalias kgwf='kubectl get --watch -f'\n...\n```\n\nSee [the full list](.kubectl_aliases).\n\n### Installation\n\nYou can directly download the [`.kubectl_aliases` file](https://raw.githubusercontent.com/ahmetb/kubectl-aliases/master/.kubectl_aliases)\nfor bash/zsh or the [`.kubectl_aliases.fish` file](https://raw.githubusercontent.com/ahmetb/kubectl-aliases/master/.kubectl_aliases.fish)\nfor fish and save it to your `$HOME` directory.\n\n#### Bash/Zsh\n\nAdd the following to your `.bashrc/.zshrc` file:\n\n```sh\n[ -f ~/.kubectl_aliases ] \u0026\u0026 source ~/.kubectl_aliases\n```\n\n\u003e **Recommendation:** If you want to use GNU `watch`  command instead of\n\u003e `kubectl [...] --watch`, run it like this:\n\u003e\n\u003e     [ -f ~/.kubectl_aliases ] \u0026\u0026 source \\\n\u003e        \u003c(cat ~/.kubectl_aliases | sed -r 's/(kubectl.*) --watch/watch \\1/g')\n\n**Print the full command before running it:** Add this to your `.bashrc` or\n`.zshrc` file:\n\n```sh\nfunction kubectl() { echo \"+ kubectl $@\"\u003e\u00262; command kubectl $@; }\n```\n\n#### Fish\n\nAdd the following to your `~/.config/fish/config.fish` file:\n\n```fish\ntest -f ~/.kubectl_aliases.fish \u0026\u0026 source ~/.kubectl_aliases.fish\n```\n\nThis actually adds the more powerful fish [abbreviations](https://fishshell.com/docs/current/cmds/abbr.html)\ninstead of aliases, so that pressing space shows the full command before execution.\n\n\u003e **Recommendation:** If you want to use GNU `watch`  command instead of\n\u003e `kubectl [...] --watch`, run it like this:\n\u003e\n\u003e     test -f ~/.kubectl_aliases.fish \u0026\u0026 source \\\n\u003e          (cat ~/.kubectl_aliases.fish | sed -r 's/(kubectl.*) --watch/watch \\1/g' | psub)\n\n### Syntax explanation\n\n* **`k`**=`kubectl`\n  * **`sys`**=`--namespace kube-system`\n* commands:\n  * **`g`**=`get`\n  * **`d`**=`describe`\n  * **`rm`**=`delete`\n  * **`a`**:`apply -f`\n  * **`ak`**:`apply -k`\n  * **`k`**:`kustomize`\n  * **`ex`**: `exec -i -t`\n  * **`lo`**: `logs -f`\n* resources:\n  * **`po`**=pod, **`dep`**=`deployment`, **`ing`**=`ingress`,\n    **`svc`**=`service`, **`cm`**=`configmap`, **`sec`**=`secret`,\n    **`ns`**=`namespace`, **`no`**=`node`\n    **:warning: Please do not suggest new resources here, instead fork the project.**\n* flags:\n  * output format: **`oyaml`**, **`ojson`**, **`owide`**\n  * **`all`**: `--all` or `--all-namespaces` depending on the command\n  * **`sl`**: `--show-labels`\n  * **`w`**=`-w/--watch`\n* value flags (should be at the end):\n  * **`n`**=`-n/--namespace`\n  * **`f`**=`-f/--filename`\n  * **`l`**=`-l/--selector`\n\n### Running the script\n\nThe script has only one optional argument, the shell to which the aliases will be generated. If not given, it assumes `bash`. Ex:\n\n```bash\n# Generate aliases for bash/zsh\npython generate_aliases.py \u003e .kubectl_aliases\n\n# Generate abbr for fish\npython generate_aliases.py fish \u003e .kubectl_aliases.fish\n```\n\n### FAQ\n\n- **Doesn't this slow down my shell start up?** Sourcing the file that contains\n~500 aliases takes about 30-45 milliseconds in my shell (zsh). I don't think\nit's a big deal for me. Measure it with `echo $(($(date +%s%N)/1000000))`\ncommand yourself in your .bashrc/.zshrc.\n\n- **Can I add more Kubernetes resource types to this?** Please consider forking\n  this repo and adding the resource types you want. Not all resource types are\n  used by everyone, and adding more resource types slows down shell initialization\n  see above).\n\n- **Where can I find PowerShell aliases for kubectl?** There’s a fork of this\n  [here](https://github.com/shanoor/kubectl-aliases-powershell).\n\n### Authors\n\n- [@ahmetb](https://twitter.com/ahmetb)\n\n-----\n\nThis is not an official Google project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahmetb%2Fkubectl-aliases","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fahmetb%2Fkubectl-aliases","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahmetb%2Fkubectl-aliases/lists"}