Skip to content

Commit

Permalink
Allow setting custom kibana host (#34)
Browse files Browse the repository at this point in the history
* Allow setting custom kibana host

* Document kibana_host parameter

* Set default for kibana_host

* Allow RL to set host
  • Loading branch information
bastjan authored Dec 23, 2021
1 parent d5d8477 commit 74354cc
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 1 deletion.
1 change: 1 addition & 0 deletions class/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ parameters:
namespace: openshift-logging
channel: 'stable'
alerts: 'master'
kibana_host: null
predict_elasticsearch_storage_alert:
enabled: true
lookback_range: 72h
Expand Down
47 changes: 47 additions & 0 deletions component/kibana-host.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
local common = import 'common.libsonnet';
local kap = import 'lib/kapitan.libjsonnet';
local kube = import 'lib/kube.libjsonnet';
local resourceLocker = import 'lib/resource-locker.libjsonnet';
local inv = kap.inventory();
// The hiera parameters for the component
local params = inv.parameters.openshift4_logging;

local routeToPatch = kube._Object('route.openshift.io/v1', 'Route', 'kibana') {
metadata+: {
namespace: params.namespace,
},
};

local patch = resourceLocker.Patch(routeToPatch, {
spec: {
host: params.kibana_host,
},
});

// OpenShift has custom RBAC permissions on routes if you want to set a host ┻━┻︵ヽ(`Д´)ノ︵ ┻━┻
local patchWithAdditionalPermissions = std.map(
function(obj)
if obj.apiVersion == 'rbac.authorization.k8s.io/v1' && obj.kind == 'Role' then
obj {
rules+: [
{
apiGroups: [
'route.openshift.io',
],
resources: [
'routes/custom-host',
],
verbs: [
'*',
],
},
],
}
else
obj
, patch
);

{
[if params.kibana_host != null then '32_kibana_host']: patchWithAdditionalPermissions,
}
2 changes: 1 addition & 1 deletion component/main.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,4 @@ local namespace_groups = (
},
},
'60_prometheus_rules': alert_rules.rules,
}
} + (import 'kibana-host.libsonnet')
10 changes: 10 additions & 0 deletions docs/modules/ROOT/pages/references/parameters.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ default:: `master`
Release version of the alerting rules.
Should be adjusted according to the channel: If you specify `channel: stable-5.2` use `alerts: release-5.2`.

== `kibana_host`

[horizontal]
type:: string
default:: `null`
example:: `kibana.apps.cluster.syn.tools`

Host name of the Kibana route.


== `predict_elasticsearch_storage_alert`

[horizontal]
Expand Down

0 comments on commit 74354cc

Please sign in to comment.