{"id":16787170,"url":"https://github.com/yaacov/kubectl-sql","last_synced_at":"2025-03-17T16:13:47.419Z","repository":{"id":57709904,"uuid":"241104481","full_name":"yaacov/kubectl-sql","owner":"yaacov","description":"kubectl-sql is a kubectl plugin that use SQL like language to query the Kubernetes cluster manager","archived":false,"fork":false,"pushed_at":"2025-03-09T12:08:21.000Z","size":349,"stargazers_count":62,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-09T12:27:37.023Z","etag":null,"topics":["hacktoberfest","k8s-client","k8s-filtering","k8s-search","kubectl","kubectl-plugin","kubectl-sql","kubernetes","plugin","query","resources","search","sql"],"latest_commit_sha":null,"homepage":"","language":"Go","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/yaacov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2020-02-17T12:39:54.000Z","updated_at":"2025-03-09T12:08:25.000Z","dependencies_parsed_at":"2022-09-26T21:21:21.392Z","dependency_job_id":"c64ff76a-9d6a-413c-8c4d-c9761a1f0361","html_url":"https://github.com/yaacov/kubectl-sql","commit_stats":null,"previous_names":["yaacov/kubesql"],"tags_count":43,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaacov%2Fkubectl-sql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaacov%2Fkubectl-sql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaacov%2Fkubectl-sql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaacov%2Fkubectl-sql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yaacov","download_url":"https://codeload.github.com/yaacov/kubectl-sql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244066189,"owners_count":20392406,"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":["hacktoberfest","k8s-client","k8s-filtering","k8s-search","kubectl","kubectl-plugin","kubectl-sql","kubernetes","plugin","query","resources","search","sql"],"created_at":"2024-10-13T08:14:23.778Z","updated_at":"2025-03-17T16:13:47.413Z","avatar_url":"https://github.com/yaacov.png","language":"Go","readme":"\n[![Go Report Card](https://goreportcard.com/badge/github.com/yaacov/kubectl-sql)](https://goreportcard.com/report/github.com/yaacov/kubectl-sql)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/yaacov/kubectl-sql/master/img/kubesql-248.png\" alt=\"kubectl-sql Logo\"\u003e\n\u003c/p\u003e\n\n# kubectl-sql\n\nkubectl-sql is a [kubectl plugin](https://kubernetes.io/docs/tasks/extend-kubectl/kubectl-plugins/) that use SQL like language to query the [Kubernetes](https://kubernetes.io/) cluster manager\n\n  - [Install](#install)\n  - [What can I do with it ?](#what-can-i-do-with-it-)\n  - [Alternatives](#alternatives)\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://asciinema.org/a/308607\" target=\"_blank\"\u003e\u003cimg src=\"https://asciinema.org/a/308607.svg\" /\u003e\u003c/a\u003e\n\u003cp\u003e\n\n## More docs\n\n - [kubectl-sql's query language](https://github.com/yaacov/kubectl-sql/blob/master/README_language.md)\n - [More kubectl-sql examples](https://github.com/yaacov/kubectl-sql/blob/master/README_examples.md)\n - [Using the config file](https://github.com/yaacov/kubectl-sql/blob/master/README_config.md)\n\n## Install\n\nUsing [krew](https://sigs.k8s.io/krew) plugin manager to install:\n\n``` bash\n# Available for linux-amd64\nkubectl krew install sql\nkubectl sql --help\n```\n\nUsing Fedora Copr:\n\n``` bash\n# Available for F41 and F42 (linux-amd64)\ndnf copr enable yaacov/kubesql\ndnf install kubectl-sql\n```\n\nFrom source:\n\n``` bash\n# Clone code\ngit clone git@github.com:yaacov/kubectl-sql.git\ncd kubectl-sql\n\n# Build kubectl-sql\nmake\n\n# Install into local machine PATH\nsudo install ./kubectl-sql /usr/local/bin/\n```\n\n\u003cp align=\"center\"\u003e\n   \u003ca href=\"https://asciinema.org/a/jPQQCjFG2qGqlZ6HKXWoQjFWa\" target=\"_blank\"\u003e\u003cimg src=\"https://asciinema.org/a/jPQQCjFG2qGqlZ6HKXWoQjFWa.svg\" /\u003e\u003c/a\u003e\n\u003cp\u003e\n \n## What can I do with it ?\n\nkubectl-sql let you select Kubernetes resources based on the value of one or more resource fields, using\nhuman readable easy to use SQL like query language. It is also posible to find connected resources useing the\n`join` command.\n\n[More kubectl-sql examples](https://github.com/yaacov/kubectl-sql/blob/master/README_examples.md)\n\n``` bash\n# Get pods in namespace \"openshift-multus\" that hase name containing \"cni\"\n# Select the fields name, status.phase as phase, status.podIP as ip\nkubectl-sql \"select name, status.phase as phase, status.podIP as ip \\\n  from openshift-multus/pods \\\n  where name ~= 'cni' and (ip ~= '5$' or phase = 'Running')\"\nKIND: Pod\tCOUNT: 2\nname                               \tphase  \tip          \t\nmultus-additional-cni-plugins-7kcsd\tRunning\t10.130.10.85\t\nmultus-additional-cni-plugins-kc8sz\tRunning\t10.131.6.65 \n...\n```\n\n``` bash\n# Get all persistant volume clames that are less then 20Gi, and output as json.\nkubectl-sql -o json \"select * from pvc where spec.resources.requests.storage \u003c 20Gi\"\n...\n```\n  \n``` bash\n# Display non running pods by nodes for all namespaces.\nkubectl-sql \"select * from nodes join pods on \\\n    nodes.status.addresses[1].address = pods.status.hostIP and not pods.phase ~= 'Running'\" -A\n...\n```\n\n``` bash\n# Filter replica sets with less ready-replicas then replicas\"\nkubectl-sql --all-namespaces \"select * from rs where status.readyReplicas \u003c status.replicas\"\n```\n\n\u003cp align=\"center\"\u003e\n   \u003ca href=\"https://asciinema.org/a/vOSwHzeOLbVhQb79ajFmql2uk\" target=\"_blank\"\u003e\u003cimg src=\"https://asciinema.org/a/vOSwHzeOLbVhQb79ajFmql2uk.svg\" /\u003e\u003c/a\u003e\n\u003cp\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://asciinema.org/a/308443\" target=\"_blank\"\u003e\u003cimg src=\"https://asciinema.org/a/308443.svg\" /\u003e\u003c/a\u003e\n\u003cp\u003e\n\n\u003cp align=\"center\"\u003e\n   \u003ca href=\"https://asciinema.org/a/308434\" target=\"_blank\"\u003e\u003cimg src=\"https://asciinema.org/a/308434.svg\" /\u003e\u003c/a\u003e\n\u003cp\u003e\n\n#### Output formats:\n| --output flag | Print format |\n|----|---|\n| table | Table |\n| name | Names only |\n| yaml | YAML |\n| json | JSON |\n\n## Alternatives\n\n#### jq\n\n`jq` is a lightweight and flexible command-line JSON processor. It is possible to\npipe the kubectl command output into the `jq` command to create complicated searches ( [Illustrated jq toturial](https://github.com/MoserMichael/jq-illustrated) )\n\nhttps://stedolan.github.io/jq/manual/#select(boolean_expression)\n\n#### kubectl --field-selector\n\nField selectors let you select Kubernetes resources based on the value of one or more resource fields. Here are some examples of field selector queries.\n\nhttps://kubernetes.io/docs/concepts/overview/working-with-objects/field-selectors/\n","funding_links":[],"categories":["Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyaacov%2Fkubectl-sql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyaacov%2Fkubectl-sql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyaacov%2Fkubectl-sql/lists"}