Unverified Commit 3156594f authored by Konstantinos Tsakalozos's avatar Konstantinos Tsakalozos Committed by GitHub
Browse files

The Jaeger Operator addon (#232)

* The Jaeger Operator addon
parent e686a882
......@@ -92,6 +92,7 @@ With `microk8s.status` you can see the list of available addons and which ones a
- **metrics-server**: Deploy the [Metrics Server](https://kubernetes.io/docs/tasks/debug-application-cluster/core-metrics-pipeline/#metrics-server).
- **prometheus**: Deploy the [Prometheus Operator](https://github.com/coreos/prometheus-operator) v0.25.
- **fluentd**: Deploy [Elasticsearch-Kibana-Fluentd](https://kubernetes.io/docs/tasks/debug-application-cluster/logging-elasticsearch-kibana/) logging and monitoring solution.
- **jaeger**: Deploy the [Jaeger Operator](https://github.com/jaegertracing/jaeger-operator) v1.8.2 in the "simplest" configuration.
### Stopping and Restarting MicroK8s
......
#!/usr/bin/env bash
set -e
source $SNAP/actions/common/utils.sh
echo "Disabling Jaeger"
"$SNAP/kubectl" "--kubeconfig=$SNAP/client.config" delete -f "${SNAP}/actions/jaeger"
"$SNAP/kubectl" "--kubeconfig=$SNAP/client.config" delete -f "${SNAP}/actions/jaeger/crds"
echo "The Jaeger operator is disabled"
\ No newline at end of file
#!/usr/bin/env bash
set -e
source $SNAP/actions/common/utils.sh
echo "Enabling Jaeger"
"$SNAP/microk8s-enable.wrapper" dns ingress
"$SNAP/kubectl" "--kubeconfig=$SNAP/client.config" apply -f "${SNAP}/actions/jaeger/crds"
n=0
until [ $n -ge 10 ]
do
sleep 3
("$SNAP/kubectl" "--kubeconfig=$SNAP/client.config" apply -f "${SNAP}/actions/jaeger/") && break
n=$[$n+1]
if [ $n -ge 10 ]; then
echo "Jaeger operator failed to install"
exit 1
fi
done
echo "Jaeger is enabled"
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: jaegers.io.jaegertracing
spec:
group: io.jaegertracing
names:
kind: Jaeger
listKind: JaegerList
plural: jaegers
singular: jaeger
scope: Namespaced
version: v1alpha1
apiVersion: apps/v1
kind: Deployment
metadata:
name: jaeger-operator
spec:
replicas: 1
selector:
matchLabels:
name: jaeger-operator
template:
metadata:
labels:
name: jaeger-operator
spec:
serviceAccountName: jaeger-operator
containers:
- name: jaeger-operator
image: jaegertracing/jaeger-operator:1.8.1
ports:
- containerPort: 60000
name: metrics
args: ["start"]
imagePullPolicy: Always
env:
- name: WATCH_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: OPERATOR_NAME
value: "jaeger-operator"
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
creationTimestamp: null
name: jaeger-operator
rules:
- apiGroups:
- ""
resources:
- pods
- services
- endpoints
- persistentvolumeclaims
- events
- configmaps
- secrets
verbs:
- '*'
- apiGroups:
- apps
resources:
- deployments
- daemonsets
- replicasets
- statefulsets
verbs:
- '*'
- apiGroups:
- monitoring.coreos.com
resources:
- servicemonitors
verbs:
- get
- create
- apiGroups:
- io.jaegertracing
resources:
- '*'
verbs:
- '*'
- apiGroups:
- extensions
resources:
- ingresses
verbs:
- "*"
- apiGroups:
- batch
resources:
- jobs
verbs:
- "*"
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: jaeger-operator
subjects:
- kind: ServiceAccount
name: jaeger-operator
roleRef:
kind: Role
name: jaeger-operator
apiGroup: rbac.authorization.k8s.io
apiVersion: v1
kind: ServiceAccount
metadata:
name: jaeger-operator
apiVersion: io.jaegertracing/v1alpha1
kind: Jaeger
metadata:
name: simplest
......@@ -21,6 +21,7 @@ addon[istio]="pod/istio"
addon[gpu]="daemonset.apps/nvidia-device-plugin-daemonset"
addon[prometheus]="pod/prometheus-k8s-0"
addon[fluentd]="daemonset.apps/fluentd-es-v2.2.0"
addon[jaeger]="pod/jaeger-operator"
function show_help() {
......
......@@ -12,6 +12,7 @@ from validators import (
validate_metrics_server,
validate_prometheus,
validate_fluentd,
validate_jaeger,
)
from utils import microk8s_enable, wait_for_pod_state, microk8s_disable, microk8s_reset
from subprocess import Popen, PIPE, STDOUT, CalledProcessError
......@@ -120,3 +121,27 @@ class TestAddons(object):
print("Disabling metrics-server")
microk8s_disable("metrics-server")
def test_monitorin_addons(self):
"""
Test jaeger, prometheus and fluentd.
"""
print("Enabling fluentd")
microk8s_enable("fluentd")
print("Enabling prometheus")
microk8s_enable("prometheus")
print("Enabling jaeger")
microk8s_enable("jaeger")
print("Validating the Jaeger operator")
validate_jaeger()
print("Validating Prometheus")
validate_prometheus()
print("Validating the Fluentd")
validate_fluentd()
print("Disabling jaeger")
microk8s_disable("jaeger")
print("Disabling fluentd")
microk8s_disable("fluentd")
print("Disabling prometheus")
microk8s_disable("prometheus")
......@@ -8,6 +8,7 @@ from validators import (
validate_metrics_server,
validate_prometheus,
validate_fluentd,
validate_jaeger,
)
from utils import wait_for_pod_state
......@@ -66,3 +67,10 @@ class TestLiveAddons(object):
"""
validate_metrics_server()
def test_jaeger(self):
"""
Validates jaeger operator.
"""
validate_jaeger()
......@@ -10,6 +10,7 @@ from validators import (
validate_metrics_server,
validate_prometheus,
validate_fluentd,
validate_jaeger,
)
from subprocess import check_call, CalledProcessError, check_output
from utils import (
......@@ -123,6 +124,14 @@ class TestUpgrade(object):
except:
print('Will not test the fluentd')
try:
enable = microk8s_enable("jaeger", timeout_insec=30)
assert "Nothing to do for" not in enable
validate_jaeger()
test_matrix['jaeger'] = validate_jaeger
except:
print('Will not test the jaeger addon')
# Refresh the snap to the target
if upgrade_to.endswith('.snap'):
cmd = "sudo snap install {} --classic --dangerous".format(upgrade_to)
......
......@@ -220,7 +220,6 @@ def validate_metrics_server():
assert attempt > 0
def validate_prometheus():
"""
Validate the prometheus operator
......@@ -244,3 +243,21 @@ def validate_fluentd():
wait_for_pod_state("elasticsearch-logging-0", "kube-system", "running")
wait_for_pod_state("", "kube-system", "running", label="k8s-app=fluentd-es")
wait_for_pod_state("", "kube-system", "running", label="k8s-app=kibana-logging")
def validate_jaeger():
"""
Validate the jaeger operator
"""
wait_for_pod_state("", "default", "running", label="name=jaeger-operator")
attempt = 30
while attempt > 0:
try:
output = kubectl("get ingress")
if "simplest-query" in output:
break
except:
pass
time.sleep(2)
attempt -= 1
assert attempt > 0
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment