# Interaction with the deployment on a specific server

The product is installed as a set of pods running on a k3s deployment in a namespace called mediakind.

In the following paragraphs, more information is provided about how to interact with the different microservices composing the product as well as where to find useful information about the installation.

Interaction is possible using either the kubectl command line tool or the k9s environment tool.

- For more details about the usage of the kubectl tool, please refer to the official documentation available here: [kubectl documentation](https://kubernetes.io/docs/reference/kubectl/)

- For more details about the usage of the k9s tool, please refer to the official documentation available here: [k9s documentation](https://k9scli.io)

## Monitor the status of microservices

The product is composed of a set of microservices. Faults in any of them may result in misbehavior and affect customer operations.

1. Login on the server where the product is installed.
2. Switch to user mediakind (for password information, ask MediaKind support): `su - mediakind`

1. Type `kubectl get pods -n mediakind | grep stream-processor`. A list of pods appears with some information associated to each of them: name, ready, status, restarts, age.

The installation of the stream-processor-asi and the stream-processor-simulcrypt controls is optional. They should not be present on your system unless you have chosen to install them and executed the additional installation steps as described in the installation guides.

2. Verify that the status is “Running” for all the pods. If this is not the case, the system may not behave as expected.

If any of the pods is not in “Running” state, type any or all of these commands to help you understand what is wrong:

- `kubectl get pods -n mediakind`: Get the status of all the pods running on the server. It may be that some other microservice is also not in “Running” state.
- `kubectl describe pod -n mediakind <pod_name>`: Check the last part of the information. It can contain a list of warning or error events.

1. Type `k9s`. An interactive user interface appears.
2. Type `:namespaces`.
3. Press **Enter**.

4. Use the **down arrow** key to highlight the line containing the string mediakind.
5. Press **Enter**. The user interface shows the complete list of pods running in the mediakind namespace.

6. Verify that the status is “Running” for all the pods. If this is not the case, the system may not behave as expected.

If any of the pods is not in “Running” state, try the following:

1. Use the **up arrow** and **down arrow** keys to scroll the list of all the pods and check if any other microservice is also not in “Running” state.
2. When the line containing the name of the pod is highlighted, press the **d** key. A description of the pod appears.
3. Use the **down arrow** key to scroll down and check the last part of the information. It can contain a list of warning or error events.
4. To exit from the pod description, press the **Esc** key.

## Get the logs from a specific service

1. Login on the server where the product is installed.
2. Switch to user mediakind (for password information, ask MediaKind support): `su - mediakind`

2. Type `kubectl logs -n mediakind <pod name>` where `<pod_name>` is the name of the pod associated to the microservice of interest.
   - For most microservices, the output contains the logs for the (single) container running in the pod.
   - The output of the kubectl logs command can be easily used as input into less, grep, sed or other string/stream manipulation commands.
   - It is possible to also use the bark utility installed by default with the host application: `kubectl logs -n mediakind <pod name>| bark` to increase readability of the kubectl logs output.

1. Type `k9s`. An interactive user interface appears.
2. Type `:pods`.
3. Press **Enter**.
4. Use the **up arrow** and **down arrow** keys to scroll through the list and highlight the microservice of interest.
5. Press **Enter**. The list of containers running in the pod appears.
6. Press the **l** key. The logs for the microservice appear.
7. To exit the logs screen, press the **Esc** key. To return to the pods list, press the **Esc** key again.

## Restart a microservice

The product microservices run as pods on the k3s deployment. The k3s framework ensures that all the required pods are always running. To restart a microservice, you only need to delete the corresponding pod. The k3s framework will restart it.

1. Login on the server where the product is installed.
2. Switch to user mediakind (for password information, ask MediaKind support): `su - mediakind`

2. Verify that the status is “Running” for all the pods. If this is not the case, the system may not behave as expected.

3. Type `kubectl delete pod <pod name> -n mediakind` where `<pod_name>` is the name of the pod associated to the microservice of interest as it appears in the output of the previous command.

4. Type `kubectl get pods -n mediakind | grep stream-processor` again to check that a new pod for the microservice is running.

## Check and edit the configuration of microservices

The behavior of each stream-processor microservice depends not only on the configuration chosen for the Multiplexing service but also on a set of microservice-specific configuration parameters.

In this deployment, for each microservice, these parameters are stored in the corresponding configmap. To view and change them, you can use either the kubectl command line tool or the k9s environment tool.

### To view a specific microservice configuration:

1. Type `kubectl get configmap -n mediakind | grep stream-processor`. A list of configmaps appears with some information associated to each of them.

2. Type `kubectl get configmap -n mediakind <configmap> -o yaml` where `<configmap>` is the name of the configmap associated to the microservice of interest as it appears in the output of the previous command.

### To edit a specific microservice configuration:

1. Type `kubectl edit configmap -n mediakind <configmap>` where `<configmap>` is the name of the configmap associated to the microservice of interest as it appears in the output of the previous command. The configmap is now open in vi editor and can be edited.

2. Apply your changes and save the configmap.

## Further interaction with your k3s deployment

You can use kubectl or k9s to get additional information about your deployment status and configuration.

Here are a few examples of useful operations:

- Check the version of a specific microservice: `kubectl get deployments -n mediakind` 
- Save the deployment or configmap for a microservice as yaml to file for later comparison with configuration on other servers.

## Check latest installation options

1. Check the version of the product currently running on your server.
2. Navigate to the `/var/install` folder and list its content:

```
cd /var/install

ls
```

3. Navigate to the `stream-processor-xxx` folder corresponding to the version currently running. It contains a subfolder called either standalone, controller, compact or server.

4. Read the previous installation parameters from the `last_configure.sh` file:

```
cat last_configure.sh
```
