# Kubernetes

## Fluent Bit K8S

If you are running a K8S cluster, you can use fluent-bit to send data to Ascent. Please see below for instructions,

### Managing multiple K8S clusters in a single Apica Ascent instance

Ascent has provided its own fluent-bit daemon for deploying on K8S clusters. It is available at <https://github.com/ApicaSystem/client-integrations/tree/master/fluent-bit>. It allows the administrator to pass a human-readable `CLUSTER_ID` or cluster identifier with all the log data.

{% hint style="success" %}
Providing a CLUSTER\_ID allows Apica Ascent to separate namespaces that may be conflicting in two separate K8S clusters.
{% endhint %}

### Running the fluent-bit daemonset

* Clone the repository to get the **`kubectl`** YAML files to start your daemonset

```
git clone git@github.com:ApicaSystem/client-integrations.git
```

* The files needed are under the folder **`fluent-bit`**

```
$ cd client-integrations/
$ cd fluentd-bit/
$ ls -la
total 64
drwxr-xr-x  8 user  staff   256 Aug  9 05:47 .
drwxr-xr-x  9 user  staff   288 Aug  9 05:20 ..
-rw-r--r--  1 user  staff  2446 Aug  9 05:47 README.md
-rw-r--r--  1 user  staff  8688 Aug  9 05:32 fluent-bit-config-apica-forward.yml
-rw-r--r--  1 user  staff  1670 Aug  9 05:29 fluent-bit-daemonset-apica-output.yml
-rw-r--r--  1 user  staff   269 Aug  9 05:26 fluent-bit-role-binding.yaml
-rw-r--r--  1 user  staff   194 Aug  9 04:49 fluent-bit-role.yaml
-rw-r--r--  1 user  staff    86 Aug  9 05:25 fluent-bit-service-account.yaml
```

To get started run the following commands to create the namespace, service account and role setup:

```bash
$ kubectl create namespace apica-logging
$ kubectl create -f fluent-bit-service-account.yaml
$ kubectl create -f fluent-bit-role-binding.yaml
$ kubectl create -f fluent-bit-role.yaml
```

#### Fluent Bit to Ascent

The next step is to create a ConfigMap that will be used by the Fluent Bit DaemonSet:

```
$ kubectl create -f fluent-bit-config-apica-forward.yml
```

#### Enabling TLS

You can enable TLS for Fluent Bit if you'd like to secure the data transferred through Fluent Bit to Apica Ascent. To do so, edit the `fluent-bit-config-apica-forward.yml` file as shown below.

```
output-ascent.conf: |
    [OUTPUT]
        Name          http
        Match         *
        Host          ${ASCENT_HOST}
        Port          ${ASCENT_PORT}
        URI           /v1/json_batch
        Format        json
        tls           on
        tls.verify    off
        net.keepalive off
        compress      gzip
        Header Authorization Bearer ${ASCENT_TOKEN}
```

Be sure to also configure the following:

* name: ASCENT\_HOST value: "YOUR\_ASCENT\_ENV\_URL"
  * (NOTE: Only include the base URL. Example: presales.apica.io)
* name: ASCENT\_PORT value: "443"
* name: CLUSTER\_ID value: "YOUR\_CLUSTER\_ID"
* name: ASCENT\_TOKEN value: "YOUR\_INGEST\_TOKEN"
  * (NOTE: You can find your ingest token [here](https://docs.apica.io/integrations/overview/generating-a-secure-ingest-token#obtaining-an-ingest-token-using-ui))

Fluent Bit DaemonSet is ready to be used with Apica Ascent on a regular Kubernetes Cluster, configure the following in deamonset `fluent-bit-daemonset-apica-output.yml`. If you do not have your ingest token, you can find yours using this [guide](https://docs.apica.io/integrations/overview/generating-a-secure-ingest-token#obtaining-an-ingest-token-using-ui)

* name: ASCENT\_HOST

  value: "YOUR\_ASCENT\_ENV\_URL"
* name: CLUSTER\_ID

  value: "YOUR\_CLUSTER\_ID"
* name: ASCENT\_TOKEN

  value: "YOUR\_INGEST\_TOKEN"

For Kubernetes version < 1.17, please change the apiVersion: "extensions/v1beta1" from "apps/v1" and remove selector attached to DaemonSet spec selector: matchLabels: k8s-app: fluent-bit-logging

```
kubectl create -f fluent-bit-daemonset-apica-output.yml
```

#### Verify Logs in Ascent

In Ascent, navigate to the Explore Tab -> Logs & Insights. You'll see your logs in the list of Sources and Applications named after your Cluster\_ID and Application:\ <br>

<figure><img src="https://2948796384-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmzGprckLqwd5v6bs6m%2Fuploads%2F32RJudWni9ItESDOsDm3%2Fimage.png?alt=media&#x26;token=2d87db54-8add-4417-a8ba-e1d3cec53abc" alt=""><figcaption></figcaption></figure>
