-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite Honeycomb agent base in ksonnet
This commit will introduce a version of the Honeycomb agent DaemonSet, rewritten using ksonnet.
- Loading branch information
Showing
2 changed files
with
65 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
local honeycomb = import "honeycomb-agent-ds.json"; | ||
local honeycomb = import "honeycomb-agent-ds-base.libsonnet"; | ||
local custom = import "honeycomb-agent-ds-custom.libsonnet"; | ||
|
||
// Import DaemonSet JSON, append volume to it. The output of this | ||
// equivalent to `honeycomb-agent-ds-custom.json`. | ||
honeycomb + | ||
// Import Honeycomb agent DaemonSet, append volume to it. The output | ||
// of this equivalent to `honeycomb-agent-ds-custom.json`. | ||
honeycomb.base("honeycomb-agent-v1.1", "kube-system") + | ||
custom.daemonSet.configVolumeMixin("config") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
local k = import "ksonnet.beta.2/k.libsonnet"; | ||
|
||
// Destructuring imports. | ||
local ds = k.extensions.v1beta1.daemonSet; | ||
local container = k.extensions.v1beta1.daemonSet.mixin.spec.template.spec.containersType; | ||
local envVar = container.envType; | ||
local volume = ds.mixin.spec.template.spec.volumesType; | ||
local keyToPath = volume.mixin.configMap.itemsType; | ||
local volumeMount = container.volumeMountsType; | ||
|
||
// ---------------------------------------------------------------------------- | ||
// Honeycomb agent parts. Containers, volumes, etc. | ||
// ---------------------------------------------------------------------------- | ||
|
||
local honeycombLabels = { | ||
"k8s-app": "honeycomb-agent", | ||
"kubernetes.io/cluster-service": "true", | ||
version: "v1.1", | ||
}; | ||
|
||
local varlogVol = volume.fromHostPath("varlog", "/var/log"); | ||
local varlibVol = | ||
volume.fromHostPath("varlibdockercontainers", "/var/lib/docker/containers"); | ||
|
||
local dsContainer = | ||
container.new("honeycomb-agent", "honeycombio/fluentd-honeycomb:1.23") + | ||
container.command([ | ||
"/bin/sh", | ||
"-c", | ||
"/usr/sbin/td-agent 2>&1 >> /var/log/fluentd.log", | ||
]) + | ||
container.mixin.resources.limits({memory: "200Mi"}) + | ||
container.mixin.resources.requests({memory: "200Mi", cpu: "100m"}) + | ||
container.volumeMounts([ | ||
volumeMount.new(varlogVol.name, varlogVol.hostPath.path), | ||
volumeMount.new(varlibVol.name, varlibVol.hostPath.path, true) | ||
]) + | ||
container.env([ | ||
envVar.fromSecretRef("HONEYCOMB_WRITEKEY", "honeycomb-writekey", "key"), | ||
envVar.new("HONEYCOMB_DATASET", "kubernetes"), | ||
]); | ||
|
||
// ---------------------------------------------------------------------------- | ||
// App definition. Honeycomb agent DaemonDet | ||
// ---------------------------------------------------------------------------- | ||
|
||
{ | ||
// base takes a name and a namespace and outputs the default | ||
// DaemonSet for the Honeycomb agent. | ||
base(name, namespace):: | ||
ds.new() + | ||
// Metadata. | ||
ds.mixin.metadata.name(name) + | ||
ds.mixin.metadata.namespace(namespace) + | ||
ds.mixin.metadata.labels(honeycombLabels) + | ||
// Template. | ||
ds.mixin.spec.template.metadata.labels(honeycombLabels) + | ||
ds.mixin.spec.template.spec.containers(dsContainer) + | ||
ds.mixin.spec.template.spec.terminationGracePeriodSeconds(30) + | ||
ds.mixin.spec.template.spec.volumes([varlogVol, varlibVol]) | ||
} |