Skip to content

Using Kubernetes pods containing WombatOAM

In this chapter we are going through how to set up a .yaml file that contains WombatOAM in a pod within its own namespace. In addition, a service setup will be shown in after the pod setup, so the UI of WombatOAM will be reachable from any internet browser.

Features

When starting the pod WombatOAM will start automatically. At that point based on the given environment variable WombatOAM will discover all elixir and erlang nodes with only 4 variables, NAMESPACE, CLUSTER_COOKIE, SERVICE_NAME and APPLICATION_NAME. If a pod/node dies during runtime WombatOAM it will be removed from the family and adds a new one if it is reachable. No additional configuration is needed. The service starts at start-up.

YAML Setup

Step 1: Creating the yaml

Creating the .yaml file is the easiest step. Run the following command in the terminal to create the wombat.yaml file. We will use this to create the namespace, pod and service as well.

1
touch wombat.yaml

Step 2 (Optional): Namespace setup

If you are not planning to define a namespace Kubernetes will add it to the default one. The following lines defines our namespace that we are putting the pod of WombatOAM inside. It's for just organization purposes. We are naming the namespace to monitoring but it can be anything you want. Be aware to remove all namespace items from the rest of the yaml if it is not defined.

1
2
3
4
apiVersion: v1
kind: Namespace
metadata:
  name: monitoring

Step 3: Pod setup

In Kubernetes applications run inside pods. Pods are populated with a single or multiple containers depends on the application. In our case we are going to run one container inside one pod. First and foremost, we have to define its kind and metadata. We are naming the pod to wombat which will run inside the given namespace, which can be left out from the file. After them comes the label which is necessary for the service when we are selecting the pods that the service should apply its configuration.

1
2
3
4
5
6
7
apiVersion: v1
kind: Pod
metadata:
  name: wombat
  namespace: monitoring
  labels:
    app: wombat
Secondly, comes the container setup under the spec section. I'm going to break it into two parts. First we are going through the resources part than the environment part. The first item is the name. If it is not defined than Kubernetes assings a randomly generated one to the pod. Then comes the resources part. Here we are setting up all cpu, memory, storage etc. We are focusing on the cpu and memory only. Firstly, the limits has to be defined which is the maximum resources that the pod can receive. It follows the requests section which defines the minimum demand. Lastly, we define the image of the container.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
spec:
  containers:
  - name: wombat
    resources:
      limits:
        cpu: 1
        memory: 1Gi
      requests:
        cpu: 500m
        memory: 1Gi
    image: erlangsolutions/wombatoam:latest
Let's setup the environment of the pod. The first item is the containerPort under the ports section. It is important to set the value to 8080 where the communication with the api happens. Next and last step is the environment variables. All three variables should be defined in order to start WombatOAM. NAMESPACE, SERVICE_NAME, CLUSTER_COOKIE and APPLICATION_NAME are necessary for WombatOAM to discover all applications inside the given service with the given cookie. Also keep in mind, that the NAMESPACE environment variable should be the name of the namespace that the service is inside. No node has to be added manually. WombatOAM will check if it is running inside Kubernetes and then adds all nodes to itself. If a node or pod terminates it will be removed automatically.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
    ports:
    - containerPort: 8080
    env:
    - name: WOMBAT_NODENAME
      value: wombat@0.0.0.0
    - name: SERVICE_NAME
      value: <SERVICENAME>
    - name: CLUSTER_COOKIE
      value: <COOKIE>
    - name: APPLICATION_NAME
      value: <APP_NAME>
    - name: NAMESPACE
      value: <NAMESPACE>

Step 4: Service setup

Last step in the yaml is the service setup. We are going to use a LoadBalancer. Here we define under the selector which applications it should affect. In our case it is only the wombat application. We are exporting the port 8080 so that it is reachable through localhost:8080 when trying to access the UI from a browser.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
kind: Service
apiVersion: v1
metadata:
  name: wombat
  namespace: monitoring
spec:
  selector:
    app: wombat
  type: LoadBalancer
  ports:
    - name: http
      port: 8080
That's it. This is the whole wombat.yaml file.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
apiVersion: v1
kind: Namespace
metadata:
  name: monitoring
---
apiVersion: v1
kind: Pod
metadata:
  name: wombat
  namespace: monitoring
  labels:
    app: wombat
spec:
  containers:
  - name: wombat
    resources:
      limits:
        cpu: 1
        memory: 1Gi
      requests:
        cpu: 500m
        memory: 1Gi
    image: erlangsolutions/wombatoam:latest
    ports:
    - containerPort: 8080
    env:
    - name: WOMBAT_NODENAME
      value: wombat@0.0.0.0
    - name: SERVICE_NAME
      value: el-kube-private
    - name: CLUSTER_COOKIE
      value: el-kube-secret-cookie
    - name: APPLICATION_NAME
      value: <APP_NAME>
    - name: NAMESPACE
      value: <NAMESPACE>
---
kind: Service
apiVersion: v1
metadata:
  name: wombat
  namespace: monitoring
spec:
  selector:
    app: wombat
  type: LoadBalancer
  ports:
    - name: http
      port: 8080

Creating the pod and service

After finishing the yaml setup we are ready to start it. Run the following command to start the pod and the service. We are using a file so that's why we are adding the -f flag to the command. Also apply can be used as well.

1
kubectl create -f wombat.yaml
If everything is set up correctly that WombatOAM's UI can be accessed through localhost:8080 and setup it with its setup wizard. No additional configuration is needed from here. When arriving to the Topology page you should see all the nodes that has been discovered by WombatOAM. Take into account we are running the applications inside a pod so it is not as fast as inside local environment. Patience needed for WombatOAM to load all of its plugins. It should not take more than 5 minutes.

Stopping the pod and service

If you did not setup a namespace leave out the namespace flag. To stop the pod run the following command.

1
kubectl delete pod wombat --namespace=monitoring
To delete the service you can run the following somewhat similar command.
1
kubectl delete service wombat --namespace=monitoring
If you created a namespace you can delete it as well. To delete the service you can run the following somewhat similar command.
1
kubectl delete namespace monitoring