{"id":16476509,"url":"https://github.com/poneding/k2","last_synced_at":"2026-05-14T10:39:23.274Z","repository":{"id":56855504,"uuid":"526098233","full_name":"poneding/k2","owner":"poneding","description":"⚙️ k2 （kubernetes-tools）是围绕 kubernetes 的运维工具。","archived":false,"fork":false,"pushed_at":"2023-04-18T16:03:27.000Z","size":28,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-11T05:47:16.909Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/poneding.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}},"created_at":"2022-08-18T07:11:27.000Z","updated_at":"2024-08-19T00:43:44.000Z","dependencies_parsed_at":"2024-06-21T16:45:48.778Z","dependency_job_id":"63172820-5aca-4195-ad1a-f06aa359a7e3","html_url":"https://github.com/poneding/k2","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poneding%2Fk2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poneding%2Fk2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poneding%2Fk2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poneding%2Fk2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/poneding","download_url":"https://codeload.github.com/poneding/k2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241144812,"owners_count":19917357,"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":[],"created_at":"2024-10-11T12:42:49.110Z","updated_at":"2026-05-14T10:39:23.233Z","avatar_url":"https://github.com/poneding.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# k2  \n\n## 简介\n\nk2（kubernetes-tools）是围绕 kubernetes 的运维工具，目前包含的功能有：\n\n- 合并多个 kubeconfig 文件\n- 从 serviceaccount 生成 kubeconfig 文件\n\n## 安装\n\n```bash\ngo install github.com/poneding/k2@latest\n```\n\n## 命令自动补全\n\n按照以下命令方式配置，重启新的终端生效。\n\n```bash\n# bash:\n# Linux:\n$ k2 completion bash \u003e /etc/bash_completion.d/k2\n# macOS:\n$ k2 completion bash \u003e $(brew --prefix)/etc/bash_completion.d/k2\n\n# zsh:\n$ echo \"autoload -U compinit; compinit\" \u003e\u003e ~/.zshrc\n$ k2 completion zsh \u003e \"${fpath[1]}/_k2\"\n\n# fish:\n$ k2 completion fish \u003e ~/.config/fish/completions/k2.fish\n\n# PowerShell:\nPS\u003e k2 completion powershell \u003e k2.ps1\n```\n\n## 使用\n\n### config\n\n`k2 config` 命令包含一些围绕 `kubeconfig` 文件的运维操作。\n\n**gen**  \n使用 `gen` 子命令，从 `ServiceAccount` 生成 `kubeconfig` 文件\n\n```bash\nk2 config gen --from \u003cserviceaccount\u003e -n \u003cnamespace\u003e\nk2 config gen --from \u003cserviceaccount\u003e -n \u003cnamespace\u003e --to \u003cfile\u003e\n```\n\n- 使用 `--from` 或 `-f` 传入 `ServiceAccount` 名称;  \n- 使用 `--namespace` 或 `-n` 指定 `ServiceAccount` 所在的命名空间，否则默认指定 `default`；  \n- 使用 `--kubeconfig` 指定访问集群配置文件，默认指定 `~/.kube/config`；\n- 使用 `--to` 或 `-t` 将生成的 `kubeconfig` 写入到目标文件，目标文件不存在则创建。不使用该参数会直接将生成结果打印到控制台。\n\n**merge**  \n使用子命令 `merge` 合并多个 `kubeconfig` 文件\n\n```bash\nk2 config merge --from \u003cconfig_a\u003e --to \u003cconfig_b\u003e\nk2 config merge --from \u003cconfig_a\u003e,\u003cconfig_b\u003e --to \u003cconfig_c\u003e\n```\n\n- 使用 `--from` 或 `-f` 指定待合并的 `kubeconfig` 文件，多个文件以 `,` 分隔；  \n- 使用 `--to` 或 `-t` 指定目标 `kubeconfig` 文件，目标文件不存在则创建。不使用该参数会直接将合并结果打印到控制台。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fponeding%2Fk2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fponeding%2Fk2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fponeding%2Fk2/lists"}