From 68b1434a3849158a7c6d3010259028836d5ef851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juraci=20Paix=C3=A3o=20Kr=C3=B6hling?= Date: Mon, 19 Mar 2018 17:02:53 +0100 Subject: [PATCH] Closes #74 - Changed Kubernetes Template to use DaemonSet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Juraci Paixão Kröhling --- README.md | 30 ++++++++++++++++---- jaeger-production-template.yml | 39 ++++++++++++++++++++++++++ production-elasticsearch/configmap.yml | 3 ++ production/configmap.yml | 3 ++ 4 files changed, 69 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index bf4bb46..df010e5 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,8 @@ If changes are required for the configuration, the `edit` command can be used: ### Jaeger components -The main production template deploys the Collector and the Query Service (with UI) as separate individually scalable services. +The main production template deploys the Collector and the Query Service (with UI) as separate individually scalable services, +as well as the Agent as `DaemonSet`. kubectl create -f https://raw.githubusercontent.com/jaegertracing/jaeger-kubernetes/master/jaeger-production-template.yml @@ -60,22 +61,39 @@ If the backing storage is not ready by the time the Collector/Agent start, they pod. It's advisable to either wait for the backing storage to stabilize, or to ignore such failures for the first few minutes. Once everything is ready, `kubectl get service jaeger-query` tells you where to find Jaeger URL, or -`minikube service jaeger-query --url` when using `minikube` +`minikube service jaeger-query --url` when using `minikube`. + +As the agent is deployed as a `DaemonSet`, the node's IP address can be stored as an environment variable and passed down +to the application as: + +```yaml +env: +- name: JAEGER_AGENT_HOST + valueFrom: + fieldRef: + fieldPath: status.hostIP +``` ### Deploying the agent as sidecar The Jaeger Agent is designed to be deployed local to your service, so that it can receive traces via UDP keeping your -application's load minimal. As such, it's ideal to have the Agent to be deployed as a sidecar to your application's component, -just add it as a container within any struct that supports `spec.containers`, like a `Pod`, `Deployment` and so on. +application's load minimal. By default, the template above installs the agent as a `DaemonSet`, but this means that all +pods running on a given node will send data to the same agent. If that's not suitable for your workload, an alternative +is to deploy the agent as a sidecar. To accomplish that, just add it as a container within any struct that supports +`spec.containers`, like a `Pod`, `Deployment` and so on. More about this be found on the blog post +[Deployment strategies for the Jaeger Agent](https://medium.com/jaegertracing/deployment-strategies-for-the-jaeger-agent-1d6f91796d09). -For instance, assuming that your application is named `myapp` and the image is for it is `mynamespace/hello-myimage`, your +Assuming that your application is named `myapp` and the image is for it is `mynamespace/hello-myimage`, your `Deployment` descriptor would be something like: ```yaml -- apiVersion: extensions/v1beta1 +- apiVersion: apps/v1 kind: Deployment metadata: name: myapp spec: + selector: + matchLabels: + app: myapp template: metadata: labels: diff --git a/jaeger-production-template.yml b/jaeger-production-template.yml index 390e81f..0a13ae0 100644 --- a/jaeger-production-template.yml +++ b/jaeger-production-template.yml @@ -163,3 +163,42 @@ items: selector: jaeger-infra: query-pod type: LoadBalancer +- apiVersion: extensions/v1beta1 + kind: DaemonSet + metadata: + name: jaeger-agent + labels: + app: jaeger + jaeger-infra: agent-daemonset + spec: + template: + metadata: + labels: + app: jaeger + jaeger-infra: agent-instance + spec: + containers: + - name: agent-instance + image: jaegertracing/jaeger-agent:1.2 + command: + - "/go/bin/agent-linux" + - "--config-file=/conf/agent.yaml" + volumeMounts: + - name: jaeger-configuration-volume + mountPath: /conf + ports: + - containerPort: 5775 + protocol: UDP + - containerPort: 6831 + protocol: UDP + - containerPort: 6832 + protocol: UDP + hostNetwork: true + dnsPolicy: ClusterFirstWithHostNet + volumes: + - configMap: + name: jaeger-configuration + items: + - key: agent + path: agent.yaml + name: jaeger-configuration-volume diff --git a/production-elasticsearch/configmap.yml b/production-elasticsearch/configmap.yml index a6b2605..0780730 100644 --- a/production-elasticsearch/configmap.yml +++ b/production-elasticsearch/configmap.yml @@ -36,3 +36,6 @@ data: password: changeme query: static-files: /go/jaeger-ui/ + agent: | + collector: + host-port: "jaeger-collector:14267" diff --git a/production/configmap.yml b/production/configmap.yml index 3575077..65a72ad 100644 --- a/production/configmap.yml +++ b/production/configmap.yml @@ -34,3 +34,6 @@ data: keyspace: jaeger_v1_dc1 query: static-files: /go/jaeger-ui/ + agent: | + collector: + host-port: "jaeger-collector:14267"