Skip to main content

k8s

Open source container management platform.

Provider Summary (v23.03.00121)
total services: 5
total methods: 267
total resources: 33
total selectable resources: 24

See also:
[SHOW] [DESCRIBE] [REGISTRY]


Installation

To pull the latest version of the k8s provider, run the following command:

REGISTRY PULL k8s;

To view previous provider versions or to pull a specific provider version, see here.

Authentication

note

cluster_addr is a required paramter for all operations using the k8s provider, for example:

SELECT name, namespace, uid, creationTimestamp 
FROM k8s.core_v1.service_account
WHERE cluster_addr = '35.244.65.136' AND namespace = 'kube-system'
ORDER BY name ASC;

Example using kubectl proxy

kubectl proxy is the default authentication method for the k8s provider, no other variables or configuration is necessary to query the k8s provider if you are using this method.

note

The protocol parameter is required when accessing a Kubernetes cluster via kubectl proxy, see the example below:

select name, namespace, uid, creationTimestamp 
from k8s.core_v1.pod
where protocol = 'http'
and cluster_addr = 'localhost:8080'
order by name asc limit 3;

Example using direct cluster access

If you are using an access token to access the k8s API, follow the instructions below (use exec instead of shell for non interactive operations):

export K8S_TOKEN='eyJhbGciOiJ...'
AUTH='{ "k8s": { "type": "bearer", "credentialsenvvar": "K8S_TOKEN" } }'
stackql shell --auth="${AUTH}" --tls.CABundle k8s_cert_bundle.pem
note

You will need to generate a certificate bundle for your cluster (k8s_cert_bundle.pem in the preceeding example), you can use the following code to generate this (for MacOS or Linux):

kubectl get secret -o jsonpath="{.items[?(@.type=="kubernetes.io/service-account-token")].data['ca\.crt']}" | base64 -i --decode > k8s_cert_bundle.pem

Alternatively, you could add the --tls.allowInsecure=true argument to the stackql command, it is not recommended however.

Server Parameters

The following parameters may be required for the k8s provider:

  • protocol - https or http (default: https)
  • cluster_addr - The hostname of the Kubernetes cluster (default: localhost)

This parameter would be supplied to the WHERE clause of each SELECT statement.

Services