Skip to content

Commit

Permalink
Added instructions for DaemonSets on OpenShift
Browse files Browse the repository at this point in the history
Closes #459

Signed-off-by: Juraci Paixão Kröhling <[email protected]>
  • Loading branch information
jpkrohling committed Jun 5, 2019
1 parent 4005a6b commit fcfd560
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 1 deletion.
27 changes: 27 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,33 @@ oc create \

After the role is granted, switch back to a non-privileged user.

Jaeger Agent can be configured to be deployed as a `DaemonSet` using a `HostPort` to allow Jaeger clients in the same node to discover the agent. In OpenShift, a `HostPort` can only be set when a special security context is set. A separate service account can be used by the Jaeger Agent with the permission to bind to `HostPort`, as follows:

[source,bash]
----
oc create -f https://raw.githubusercontent.com/jaegertracing/jaeger-operator/master/deploy/hostport-scc-daemonset.yaml # <1>
oc new-project myappnamespace
oc create -f https://raw.githubusercontent.com/jaegertracing/jaeger-operator/master/deploy/service_account_jaeger-agent-daemonset.yaml # <2>
oc adm policy add-scc-to-user daemonset-with-hostport -z jaeger-agent-daemonset # <3>
oc apply -f https://raw.githubusercontent.com/jaegertracing/jaeger-operator/master/deploy/examples/openshift/agent-as-daemonset.yaml # <4>
----
<1> The `SecurityContextConstraints` with the `allowHostPorts` policy
<2> The `ServiceAccount` to be used by the Jaeger Agent
<3> Adds the security policy to the service account
<4> Creates the Jaeger Instance using the `serviceAccount` created in the steps above

WARNING: without such a policy, errors like the following will prevent a `DaemonSet` to be created: `Warning FailedCreate 4s (x14 over 45s) daemonset-controller Error creating: pods "agent-as-daemonset-agent-daemonset-" is forbidden: unable to validate against any security context constraint: [spec.containers[0].securityContext.containers[0].hostPort: Invalid value: 5775: Host ports are not allowed to be used`

After a few seconds, the `DaemonSet` should be up and running:

[source,console]
----
$ oc get daemonset agent-as-daemonset-agent-daemonset
NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE
agent-as-daemonset-agent-daemonset 1 1 1 1 1
----

== Creating a new Jaeger instance

Example custom resources, for different configurations of Jaeger, can be found https://github.com/jaegertracing/jaeger-operator/tree/master/deploy/examples[here].
Expand Down
10 changes: 10 additions & 0 deletions deploy/examples/openshift/agent-as-daemonset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: jaegertracing.io/v1
kind: Jaeger
metadata:
name: agent-as-daemonset
spec:
agent:
strategy: DaemonSet
serviceAccount: jaeger-agent-daemonset
options:
log-level: debug
11 changes: 11 additions & 0 deletions deploy/hostport-scc-daemonset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
kind: SecurityContextConstraints
apiVersion: security.openshift.io/v1
metadata:
name: daemonset-with-hostport
annotations:
kubernetes.io/description: 'Allows DaemonSets to bind to a well-known host port'
runAsUser:
type: RunAsAny
seLinuxContext:
type: RunAsAny
allowHostPorts: true
4 changes: 4 additions & 0 deletions deploy/service_account_jaeger-agent-daemonset.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: jaeger-agent-daemonset
2 changes: 1 addition & 1 deletion pkg/cmd/start/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/runtime/signals"

"github.com/jaegertracing/jaeger-operator/pkg/apis"
"github.com/jaegertracing/jaeger-operator/pkg/apis/jaegertracing/v1"
v1 "github.com/jaegertracing/jaeger-operator/pkg/apis/jaegertracing/v1"
"github.com/jaegertracing/jaeger-operator/pkg/controller"
"github.com/jaegertracing/jaeger-operator/pkg/version"
)
Expand Down

0 comments on commit fcfd560

Please sign in to comment.