> For the complete documentation index, see [llms.txt](https://docs.octoxlabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.octoxlabs.com/adapters/o/openshift.md).

# Openshift

Openshift is a Kubernetes-based container platform. OctoXLabs uses it to add cluster nodes, their pods, optional virtual machines and optional network policy rules to the inventory.

## Use cases

* List every Openshift node that OctoXLabs has seen recently, to confirm that cluster capacity matches what you expect.

```
Adapters = openshift AND LastSeen last now-7d/d
```

* Find Openshift assets that are also reported by other adapters, to spot clusters that are not yet covered by your endpoint tools.

```
Adapters = openshift AND NOT Adapters = falcon-crowdstrike
```

* Review the virtual machines that Openshift Virtualization runs, by enabling **Fetch Virtual Machines** and filtering on the adapter.

```
Adapters = openshift AND Category = Server
```

## Before you begin

### Network

| Source              | Destination                  | Port               | Protocol |
| ------------------- | ---------------------------- | ------------------ | -------- |
| OctoXLabs connector | Openshift cluster API server | 443 (configurable) | HTTPS    |

### Required permissions

| Scope or role                        | Permission                                              | Needed for                                                                                                         |
| ------------------------------------ | ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| cluster-reader (Service Account)     | get, list on nodes, pods, namespaces                    | Nodes and pods                                                                                                     |
| `networking.k8s.io` API group        | list on `networkpolicies`                               | Network policies (**Fetch Network Policies**) and namespace enrichment. The built-in `view` ClusterRole grants it. |
| `kubevirt.io` API group              | list on `virtualmachines` and `virtualmachineinstances` | Virtual machines (**Fetch Virtual Machines**). The built-in `kubevirt.io:view` ClusterRole grants it.              |
| `subresources.kubevirt.io` API group | get on `virtualmachineinstances/guestosinfo`            | Guest hostname and OS of virtual machines                                                                          |

Without the pod permission, nodes are still collected but without their pods. Without the guestosinfo permission, virtual machines are identified by `namespace/name`.

Vendor documentation: [Openshift: Service Account Tokens](https://docs.openshift.com/container-platform/latest/authentication/using-service-accounts.html).

## Create credentials in Openshift

{% stepper %}
{% step %}

### Create a Service Account

Create a Service Account in Openshift for OctoXLabs.
{% endstep %}

{% step %}

### Grant read access

Bind the `cluster-reader` role to the Service Account. For network policies and virtual machines, make sure the permissions in the table above are also granted.
{% endstep %}

{% step %}

### Generate the token

Generate a bearer token for the Service Account and copy it. You paste it into the **Token** parameter.
{% endstep %}
{% endstepper %}

## Connection parameters

| Parameter               | Required | Type            | Default | Description                                                                                                                                                                                      |
| ----------------------- | -------- | --------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| IP                      | Yes      | String          |         | IP address of the Openshift cluster API server.                                                                                                                                                  |
| Port                    | No       | Integer         | 443     | Port of the API server.                                                                                                                                                                          |
| Token                   | Yes      | String          |         | Bearer token of the Service Account.                                                                                                                                                             |
| Fetch Namespace Details | No       | Boolean         | False   | Attaches namespace details and network policies to each pod. Richer data, larger payload.                                                                                                        |
| Fetch Network Policies  | No       | Boolean         | False   | Publishes each NetworkPolicy rule as a policy asset. Separate from Fetch Namespace Details.                                                                                                      |
| Fetch Virtual Machines  | No       | Boolean         | False   | Collects Openshift Virtualization virtual machines, running and stopped, as devices.                                                                                                             |
| Additional Pod Fields   | No       | List of strings | Empty   | Verbose pod fields to keep. By default volumes, volumeMounts, env, securityContext, conditions, containerStatuses, initContainers, serviceAccount, imagePullSecrets and annotations are removed. |
| Is Secure               | No       | Boolean         | True    | Use HTTPS.                                                                                                                                                                                       |
| Timeout                 | No       | Integer         | 30      | Seconds to wait for API responses.                                                                                                                                                               |

## Troubleshooting

| Error message                                                                                        | Cause                                                                                   | Fix                                                                            |
| ---------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ |
| Can not establish proper connection. Please check the request                                        | The nodes call returned an empty body, for example after a 403.                         | Check the token, the IP and port, and that the Service Account can list nodes. |
| Pod enrichment is not permitted (N request(s) answered 403); nodes are collected without their pods. | The token cannot list pods.                                                             | Grant list on pods, for example with the `cluster-reader` role.                |
| Virtual machines could not be collected, nodes are kept.                                             | Openshift Virtualization is missing or the token cannot list the kubevirt.io resources. | Install Openshift Virtualization and grant the `kubevirt.io:view` ClusterRole. |

## Change history
