Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add column selector_query to kubernetes_* tables and add optional key column selector_search to kubernetes_pod table. Closes #63 #65

Merged
merged 3 commits into from
May 9, 2022

Conversation

bigdatasourav
Copy link
Contributor

@bigdatasourav bigdatasourav commented Apr 29, 2022

Column selector_query added in below tables

  • kubernetes_daemonset
  • kubernetes_deployment
  • kubernetes_job
  • kubernetes_replicaset
  • kubernetes_job
  • kubernetes_replication_controller

Example query results

Results
> select * from kubernetes_pod where selector_search in (select selector_query from kubernetes_daemonset)
+-------------------------+-------------+--------------------------------------+-------------------------------------------------------+--------------------------------------------------------------------
| name                    | namespace   | uid                                  | selector_search                                       | volumes                                                            
+-------------------------+-------------+--------------------------------------+-------------------------------------------------------+--------------------------------------------------------------------
| fluentbit-gke-7wldf     | kube-system | 89b7b452-714c-4bef-92f1-eca3622f31a6 | component=fluentbit-gke,k8s-app=fluentbit-gke         | [{"hostPath":{"path":"/var/run/google-fluentbit/pos-files","type":"
|                         |             |                                      |                                                       |                                                                    
| gke-metrics-agent-l2895 | kube-system | 0b37ab72-a044-428e-b9d6-08d93dd5467f | component=gke-metrics-agent,k8s-app=gke-metrics-agent | [{"configMap":{"defaultMode":420,"items":[{"key":"gke-metrics-agent
|                         |             |                                      |                                                       |                                                                    
| pdcsi-node-tn6df        | kube-system | 34c3e74a-2400-4b04-893d-ddb8c96fda0e | k8s-app=gcp-compute-persistent-disk-csi-driver        | [{"hostPath":{"path":"/var/lib/kubelet/plugins_registry/","type":"D
|                         |             |                                      |                                                       |                                                                    
+-------------------------+-------------+--------------------------------------+-------------------------------------------------------+--------------------------------------------------------------------
> select * from kubernetes_pod where selector_search in (select selector_query from kubernetes_deployment)
+------------------------------------------------+-------------+--------------------------------------+---------------------------------------+-------------------------------------------------------------
| name                                           | namespace   | uid                                  | selector_search                       | volumes                                                     
+------------------------------------------------+-------------+--------------------------------------+---------------------------------------+-------------------------------------------------------------
| konnectivity-agent-67f549dc86-m5kxp            | kube-system | f3428e8d-3bc6-4fe9-abd2-860dc0748b0a | k8s-app=konnectivity-agent            | [{"name":"konnectivity-agent-token","projected":{"defaultMod
|                                                |             |                                      |                                       |                                                             
| kube-dns-697dc8fc8b-pg4vr                      | kube-system | ccda5ae4-07c2-41e9-9dcd-5c71ac160237 | k8s-app=kube-dns                      | [{"configMap":{"defaultMode":420,"name":"kube-dns","optional
|                                                |             |                                      |                                       |                                                             
|                                                |             |                                      |                                       |                                                             
|                                                |             |                                      |                                       |                                                             
|                                                |             |                                      |                                       |                                                             
| kube-dns-autoscaler-844c9d9448-t8z4v           | kube-system | 0ffb3c73-b92c-45e9-b4b9-952a5e8d1c3f | k8s-app=kube-dns-autoscaler           | [{"name":"kube-api-access-bs8b2","projected":{"defaultMode":
| l7-default-backend-69fb9fd9f9-zmz65            | kube-system | 6844bf00-bcac-4a3b-8230-54a1eeb21063 | k8s-app=glbc                          | [{"name":"kube-api-access-2tbdf","projected":{"defaultMode":
| konnectivity-agent-autoscaler-5c49cb58bb-cldpv | kube-system | bca77a2f-3973-4e30-8c35-e505b6f2ac78 | k8s-app=konnectivity-agent-autoscaler | [{"name":"kube-api-access-fd6xq","projected":{"defaultMode":
| event-exporter-gke-5479fd58c8-rrzv2            | kube-system | 7d73a3ed-3ed7-4a0a-8846-cb720f3f406e | k8s-app=event-exporter                | [{"hostPath":{"path":"/etc/ssl/certs","type":""},"name":"ssl
|                                                |             |                                      |                                       |                                                             
| metrics-server-v0.4.5-bbb794dcc-9k5qc          | kube-system | 48bca893-42ff-44b9-81c9-f4116a42119f | k8s-app=metrics-server,version=v0.4.5 | [{"configMap":{"defaultMode":420,"name":"metrics-server-conf
|                                                |             |                                      |                                       |                                                             
+------------------------------------------------+-------------+--------------------------------------+---------------------------------------+-------------------------------------------------------------
> select * from kubernetes_pod where selector_search in (select selector_query from kubernetes_replicaset)
+------------------------------------------------+-------------+--------------------------------------+--------------------------------------------------------------------+--------------------------------
| name                                           | namespace   | uid                                  | selector_search                                                    | volumes                        
+------------------------------------------------+-------------+--------------------------------------+--------------------------------------------------------------------+--------------------------------
| metrics-server-v0.4.5-bbb794dcc-9k5qc          | kube-system | 48bca893-42ff-44b9-81c9-f4116a42119f | k8s-app=metrics-server,pod-template-hash=bbb794dcc,version=v0.4.5  | [{"configMap":{"defaultMode":42
|                                                |             |                                      |                                                                    |                                
| event-exporter-gke-5479fd58c8-rrzv2            | kube-system | 7d73a3ed-3ed7-4a0a-8846-cb720f3f406e | k8s-app=event-exporter,pod-template-hash=5479fd58c8                | [{"hostPath":{"path":"/etc/ssl/
|                                                |             |                                      |                                                                    |                                
| kube-dns-697dc8fc8b-pg4vr                      | kube-system | ccda5ae4-07c2-41e9-9dcd-5c71ac160237 | k8s-app=kube-dns,pod-template-hash=697dc8fc8b                      | [{"configMap":{"defaultMode":42
|                                                |             |                                      |                                                                    |                                
|                                                |             |                                      |                                                                    |                                
|                                                |             |                                      |                                                                    |                                
|                                                |             |                                      |                                                                    |                                
| konnectivity-agent-67f549dc86-m5kxp            | kube-system | f3428e8d-3bc6-4fe9-abd2-860dc0748b0a | k8s-app=konnectivity-agent,pod-template-hash=67f549dc86            | [{"name":"konnectivity-agent-to
|                                                |             |                                      |                                                                    |                                
| kube-dns-autoscaler-844c9d9448-t8z4v           | kube-system | 0ffb3c73-b92c-45e9-b4b9-952a5e8d1c3f | k8s-app=kube-dns-autoscaler,pod-template-hash=844c9d9448           | [{"name":"kube-api-access-bs8b2
| konnectivity-agent-autoscaler-5c49cb58bb-cldpv | kube-system | bca77a2f-3973-4e30-8c35-e505b6f2ac78 | k8s-app=konnectivity-agent-autoscaler,pod-template-hash=5c49cb58bb | [{"name":"kube-api-access-fd6xq
| l7-default-backend-69fb9fd9f9-zmz65            | kube-system | 6844bf00-bcac-4a3b-8230-54a1eeb21063 | k8s-app=glbc,pod-template-hash=69fb9fd9f9                          | [{"name":"kube-api-access-2tbdf
+------------------------------------------------+-------------+--------------------------------------+--------------------------------------------------------------------+--------------------------------
> select * from kubernetes_pod where selector_search in (select selector_query from kubernetes_replication_controller)
+------+-----------+-----+-----------------+---------+------------+----------------------+-----------------+----------------+----------------------------------+-------------------------+------------+-----
| name | namespace | uid | selector_search | volumes | containers | ephemeral_containers | init_containers | restart_policy | termination_grace_period_seconds | active_deadline_seconds | dns_policy | node
+------+-----------+-----+-----------------+---------+------------+----------------------+-----------------+----------------+----------------------------------+-------------------------+------------+-----
+------+-----------+-----+-----------------+---------+------------+----------------------+-----------------+----------------+----------------------------------+-------------------------+------------+-----
> select * from kubernetes_pod where selector_search in (select selector_query from kubernetes_job)
+------+-----------+-----+-----------------+---------+------------+----------------------+-----------------+----------------+----------------------------------+-------------------------+------------+-----
| name | namespace | uid | selector_search | volumes | containers | ephemeral_containers | init_containers | restart_policy | termination_grace_period_seconds | active_deadline_seconds | dns_policy | node
+------+-----------+-----+-----------------+---------+------------+----------------------+-----------------+----------------+----------------------------------+-------------------------+------------+-----
+------+-----------+-----+-----------------+---------+------------+----------------------+-----------------+----------------+----------------------------------+-------------------------+------------+-----

@bigdatasourav bigdatasourav self-assigned this Apr 29, 2022
@bigdatasourav bigdatasourav marked this pull request as draft April 29, 2022 14:48
@bigdatasourav bigdatasourav changed the title Add column selector_string_format to kubernetes_service table Add column selector_query to kubernetes_* tables and add optional key column selector_search to kubernetes_pod table May 4, 2022
@bigdatasourav bigdatasourav changed the title Add column selector_query to kubernetes_* tables and add optional key column selector_search to kubernetes_pod table Add column selector_query to kubernetes_* tables and add optional key column selector_search to kubernetes_pod table. Closes #63 May 4, 2022
@bigdatasourav bigdatasourav marked this pull request as ready for review May 4, 2022 12:39
{
Name: "selector_query",
Type: proto.ColumnType_STRING,
Description: "Route service traffic to pods with label keys and values matching this selector. String format representation.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This description should probably be consistent with the other selector_query descrptions

selector_map := d.Value.(map[string]string)

if len(selector_map) == 0 {
logger.Warn("selectorMapToString", "!!! selector is empty")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this warning was for debugging and should be removed

@bigdatasourav bigdatasourav merged commit 3afb96e into main May 9, 2022
@bigdatasourav bigdatasourav deleted the issue-63 branch May 9, 2022 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants