> ## Documentation Index
> Fetch the complete documentation index at: https://docs.keephq.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Kubernetes

> Kubernetes provider to perform rollout restart or list pods action.

## Authentication

This provider requires authentication.

* **api\_server**: The kubernetes api server url (required: False, sensitive: False)
* **token**: Bearer token to access kubernetes (leave empty for in-cluster auth) (required: False, sensitive: True)
* **insecure**: Skip TLS verification (required: False, sensitive: False)
* **use\_in\_cluster\_config**: Use in-cluster configuration (ServiceAccount) (required: False, sensitive: False)

Certain scopes may be required to perform specific actions or queries via the provider. Below is a summary of relevant scopes and their use cases:

* **connect\_to\_kubernetes**: Check if the provided token can connect to the kubernetes server (mandatory)

## In workflows

This provider can be used in workflows.

As "step" to query data, example:

```yaml theme={null}
steps:
    - name: Query kubernetes
      provider: kubernetes
      config: "{{ provider.my_provider_name }}"
      with:
        command_type: {value}  # The type of query to perform. Supported queries are:
- get_logs: Get logs from a pod
- get_deployment_logs: Get logs from all pods in a deployment
- get_events: Get events for a namespace or pod
- get_nodes: List nodes
- get_pods: List pods
- get_node_pressure: Get node pressure conditions
- get_pvc: List persistent volume claims
- get_deployments: List deployments
- get_statefulsets: List statefulsets
- get_daemonsets: List daemonsets
- get_services: List services
- get_namespaces: List namespaces
- get_ingresses: List ingresses for a namespace or all namespaces
- get_jobs: List jobs
        # Additional arguments for the query.
```

As "action" to make changes or update data, example:

```yaml theme={null}
actions:
    - name: Query kubernetes
      provider: kubernetes
      config: "{{ provider.my_provider_name }}"
      with:
        action: {value}  # The action to perform. Supported actions are:
- rollout_restart: Restart a deployment/statefulset/daemonset
- restart_pod: Restart a specific pod
- cordon_node: Mark node as unschedulable
- uncordon_node: Mark node as schedulable
- drain_node: Safely evict pods from node
- scale_deployment: Scale deployment up/down
- scale_statefulset: Scale statefulset up/down
- exec_pod_command: Execute command in pod
        # Additional arguments for the action.
```

Check the following workflow example:

* [gke.yml](https://github.com/keephq/keep/blob/main/examples/workflows/gke.yml)

## Connecting with the Provider

To connect to Kubernetes, follow below steps:

1. Create a service account on Kubernetes.
2. Create role/clusterrole and bind to service account using rolebinding/clusterrolebinding.
3. Get the token of service account.

## Notes

* This provider allows you to interact with Kubernetes to perform rollout restart or pods listing actions.

## Useful Links

* [Access Kubernetes Cluster](https://kubernetes.io/docs/tasks/access-application-cluster/access-cluster/)
