-
Notifications
You must be signed in to change notification settings - Fork 589
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NMS-16149: Added confd to Sentinel #6820
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
dfb99f4
NMS-16149: Altered Dockerfile
christianpape 4063bc8
NMS-16149: Added confd to Sentinel
christianpape 5a8c13b
NMS-16149: Review changes
christianpape 8b63174
Apply suggestions from code review
christianpape fc3a1c6
Update .gitignore
christianpape 62aa978
NMS-16149: Fix build
christianpape File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 +1,2 @@ | ||
sentinel-config-schema.yml | ||
/tarball-root |
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,77 @@ | ||
# Configuring Sentinel via confd | ||
(instructions for testing/developing confd templates are given at the end of this document) | ||
## Mounting | ||
When starting the Sentinel container, mount a yaml file to the following path `/opt/sentinel/sentinel-config.yaml`. | ||
|
||
Any configuration provided to confd will overwrite configuration specified as environment variables. Direct overlay of | ||
specific configuration files will overwrite the corresponding config provided by confd. | ||
|
||
## Contents | ||
The following describes the keys that can be specified in `sentinel-config.yaml` to configure the Sentinel via confd. | ||
|
||
### Sentinel Controller Config | ||
```yaml | ||
--- | ||
broker-url: "<broker url>" | ||
id: "<id>" | ||
location: "<location>" | ||
``` | ||
Config specified will be written to `etc/org.opennms.sentinel.controller.cfg`. | ||
|
||
#### User/Password | ||
Supplying the broker username/password via yaml file for configuration via confd is not supported. | ||
|
||
### Sentinel Elasticsearch Config | ||
```yaml | ||
--- | ||
elasticsearch: | ||
url: "http://elastic-ip:9200" | ||
index-strategy: "hourly" | ||
replicas: 0 | ||
conn-timeout: 30000 | ||
read-timeout: 60000 | ||
``` | ||
Config specified will be written to `etc/org.opennms.features.flows.persistence.elastic.cfg`. | ||
|
||
### Sentinel Datasource Config | ||
```yaml | ||
--- | ||
datasource: | ||
url: "jdbc:postgresql://localhost:5432/opennms" | ||
username: "postgres" | ||
password: "postgres" | ||
database-name: "opennms" | ||
``` | ||
Config specified will be written to `etc/org.opennms.netmgt.distributed.datasource.cfg`. | ||
|
||
### Sentinel Kafka Config | ||
```yaml | ||
--- | ||
ipc: | ||
kafka: | ||
bootstrap.servers: "my-kafka-ip-1:9092,my-kafka-ip-2:9092" | ||
group.id: "OpenNMS" | ||
``` | ||
Config specified will be written to `etc/org.opennms.core.ipc.sink.kafka.cfg` and `etc/org.opennms.core.ipc.sink.kafka.consumer.cfg`. | ||
|
||
### Telemetry Flow Adapters | ||
Individual flow adapters can be configured. See the example below for how to specify parameters and parsers. Any number | ||
of uniquely named listeners can be defined. | ||
```yaml | ||
--- | ||
telemetry: | ||
flows: | ||
adapters: | ||
NetFlow-5: | ||
class-name: "org.opennms.netmgt.telemetry.protocols.netflow.adapter.netflow5.Netflow5Adapter" | ||
parameters: | ||
some-key: "some-value" | ||
``` | ||
Config specified will be written to `deploy/confd-flows-feature.xml`. | ||
|
||
### Instance Id | ||
```yaml | ||
--- | ||
org.opennms.instance.id: "<instance id>" | ||
``` | ||
Config specified will be written to `etc/custom.system.properties`. |
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
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
8 changes: 8 additions & 0 deletions
8
opennms-container/sentinel/container-fs/confd/conf.d/confd-flows-feature.xml.toml
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,8 @@ | ||
[template] | ||
src = "confd-flows-feature.xml.tmpl" | ||
dest = "/opt/sentinel/deploy/confd-flows-feature.xml" | ||
keys = [ | ||
"/telemetry/flows/adapters" | ||
] | ||
|
||
reload_cmd = "/opt/sentinel/confd/scripts/remove-if-empty /opt/sentinel/deploy/confd-flows-feature.xml" |
7 changes: 7 additions & 0 deletions
7
opennms-container/sentinel/container-fs/confd/conf.d/custom.system.properties.toml
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,7 @@ | ||
[template] | ||
src = "custom.system.properties.tmpl" | ||
dest = "/opt/sentinel/etc/custom.system.properties" | ||
keys = [ | ||
"/org.opennms.instance.id", | ||
] | ||
reload_cmd = "/opt/sentinel/confd/scripts/remove-if-empty /opt/sentinel/etc/custom.system.properties" |
7 changes: 7 additions & 0 deletions
7
opennms-container/sentinel/container-fs/confd/conf.d/ipc-strategy.boot.toml
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,7 @@ | ||
[template] | ||
src = "ipc-strategy.boot.tmpl" | ||
dest = "/opt/sentinel/etc/featuresBoot.d/ipc-strategy.boot" | ||
keys = [ | ||
"/ipc/kafka/bootstrap-servers" | ||
] | ||
reload_cmd = "/opt/sentinel/confd/scripts/remove-if-empty /opt/sentinel/etc/featuresBoot.d/ipc-strategy.boot" |
7 changes: 7 additions & 0 deletions
7
...nms-container/sentinel/container-fs/confd/conf.d/org.opennms.core.ipc.sink.kafka.cfg.toml
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,7 @@ | ||
[template] | ||
src = "org.opennms.core.ipc.sink.kafka.cfg.tmpl" | ||
dest = "/opt/sentinel/etc/org.opennms.core.ipc.sink.kafka.cfg" | ||
keys = [ | ||
"/ipc/kafka" | ||
] | ||
reload_cmd = "/opt/sentinel/confd/scripts/remove-if-empty /opt/sentinel/etc/org.opennms.core.ipc.sink.kafka.cfg" |
7 changes: 7 additions & 0 deletions
7
...iner/sentinel/container-fs/confd/conf.d/org.opennms.core.ipc.sink.kafka.consumer.cfg.toml
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,7 @@ | ||
[template] | ||
src = "org.opennms.core.ipc.sink.kafka.consumer.cfg.tmpl" | ||
dest = "/opt/sentinel/etc/org.opennms.core.ipc.sink.kafka.consumer.cfg" | ||
keys = [ | ||
"/ipc/kafka" | ||
] | ||
reload_cmd = "/opt/sentinel/confd/scripts/remove-if-empty /opt/sentinel/etc/org.opennms.core.ipc.sink.kafka.consumer.cfg" |
11 changes: 11 additions & 0 deletions
11
...entinel/container-fs/confd/conf.d/org.opennms.features.flows.persistence.elastic.cfg.toml
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,11 @@ | ||
[template] | ||
src = "org.opennms.features.flows.persistence.elastic.cfg.tmpl" | ||
dest = "/opt/sentinel/etc/org.opennms.features.flows.persistence.elastic.cfg" | ||
keys = [ | ||
"/elasticsearch/url", | ||
"/elasticsearch/index-strategy", | ||
"/elasticsearch/replicas", | ||
"/elasticsearch/conn-timeout", | ||
"/elasticsearch/read-timeout", | ||
] | ||
reload_cmd = "/opt/sentinel/confd/scripts/remove-if-empty /opt/sentinel/etc/org.opennms.features.flows.persistence.elastic.cfg" |
10 changes: 10 additions & 0 deletions
10
...ner/sentinel/container-fs/confd/conf.d/org.opennms.netmgt.distributed.datasource.cfg.toml
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,10 @@ | ||
[template] | ||
src = "org.opennms.netmgt.distributed.datasource.cfg.tmpl" | ||
dest = "/opt/sentinel/etc/org.opennms.netmgt.distributed.datasource.cfg" | ||
keys = [ | ||
"/datasource/url", | ||
"/datasource/username", | ||
"/datasource/password", | ||
"/datasource/database-name", | ||
] | ||
reload_cmd = "/opt/sentinel/confd/scripts/remove-if-empty /opt/sentinel/etc/org.opennms.netmgt.distributed.datasource.cfg" |
9 changes: 9 additions & 0 deletions
9
...nms-container/sentinel/container-fs/confd/conf.d/org.opennms.sentinel.controller.cfg.toml
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,9 @@ | ||
[template] | ||
src = "org.opennms.sentinel.controller.cfg.tmpl" | ||
dest = "/opt/sentinel/etc/org.opennms.sentinel.controller.cfg" | ||
keys = [ | ||
"/location", | ||
"/id", | ||
"/broker-url" | ||
] | ||
reload_cmd = "/opt/sentinel/confd/scripts/remove-if-empty /opt/sentinel/etc/org.opennms.sentinel.controller.cfg" |
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,4 @@ | ||
confdir = "/opt/sentinel/confd" | ||
backend = "file" | ||
file = [ "/opt/sentinel/sentinel-config.yaml" ] | ||
log-level = "debug" |
Empty file.
19 changes: 19 additions & 0 deletions
19
opennms-container/sentinel/container-fs/confd/scripts/confd_lib.sh
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,19 @@ | ||
SENTINEL_ETC_DIR="/opt/sentinel/etc" | ||
STATIC_DIR="/opt/sentinel/confd/static" | ||
|
||
# Checks if the given file is empty and if so deletes it. | ||
removeIfEmpty() { | ||
local file="$1" | ||
|
||
if [ -z "$file" ]; then | ||
echo "No rendered template was specified" | ||
exit 1 | ||
fi | ||
|
||
if [ -s "$file" ]; then | ||
return 1 | ||
fi | ||
|
||
rm "$file" | ||
return 0 | ||
} |
6 changes: 6 additions & 0 deletions
6
opennms-container/sentinel/container-fs/confd/scripts/remove-if-empty
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,6 @@ | ||
#!/usr/bin/env bash | ||
. "/opt/sentinel/confd/scripts/confd_lib.sh" | ||
|
||
if removeIfEmpty "$1"; then | ||
echo "Removed file '$1' since it was empty after rendering" | ||
fi |
29 changes: 29 additions & 0 deletions
29
opennms-container/sentinel/container-fs/confd/templates/confd-flows-feature.xml.tmpl
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,29 @@ | ||
{{- /* Upon updating this file please ensure that the schema sentinel-config-schema.yml accurately reflects the keys that | ||
are used by this template. */ -}} | ||
{{if ls "/telemetry/flows/adapters"}} | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<features name="flows-features" xmlns="http://karaf.apache.org/xmlns/features/v1.3.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.3.0 http://karaf.apache.org/xmlns/features/v1.3.0"> | ||
|
||
<feature name="confd-flows-auto" version="1.0" install="auto"> | ||
|
||
{{$flowsPath := "/telemetry/flows" -}} | ||
{{range lsdir (print $flowsPath "/adapters") -}} | ||
{{$adaptersPath := (print $flowsPath "/adapters/" .) -}} | ||
{{$adapterName := base $adaptersPath -}} | ||
<config name="org.opennms.features.telemetry.adapters-{{$adapterName}}"> | ||
name={{$adapterName}} | ||
class-name={{getv (print $adaptersPath "/class-name")}} | ||
{{range gets (print $adaptersPath "/parameters/*") -}} | ||
parameters.{{base .Key}}={{.Value}} | ||
{{end -}} | ||
</config> | ||
{{end -}} | ||
|
||
</feature> | ||
<feature>sentinel-flows</feature> | ||
<feature>sentinel-jsonstore-postgres</feature> | ||
<feature>sentinel-blobstore-noop</feature> | ||
|
||
</features> | ||
{{end -}} |
5 changes: 5 additions & 0 deletions
5
opennms-container/sentinel/container-fs/confd/templates/custom.system.properties.tmpl
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,5 @@ | ||
{{- /* Upon updating this file please ensure that the schema sentinel-config-schema.yml accurately reflects the keys that | ||
are used by this template. */ -}} | ||
{{if exists "/org.opennms.instance.id" -}} | ||
org.opennms.instance.id = {{getv "/org.opennms.instance.id"}} | ||
{{end -}} |
9 changes: 9 additions & 0 deletions
9
opennms-container/sentinel/container-fs/confd/templates/ipc-strategy.boot.tmpl
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,9 @@ | ||
{{- /* Upon updating this file please ensure that the schema sentinel-config-schema.yml accurately reflects the keys that | ||
are used by this template. */ -}} | ||
{{if (exists "/ipc/kafka/bootstrap.servers") -}} | ||
!sentinel-jms | ||
sentinel-kafka | ||
{{else}} | ||
sentinel-jms | ||
!sentinel-kafka | ||
{{end -}} |
5 changes: 5 additions & 0 deletions
5
...-container/sentinel/container-fs/confd/templates/org.opennms.core.ipc.sink.kafka.cfg.tmpl
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,5 @@ | ||
{{- /* Upon updating this file please ensure that the schema sentinel-config-schema.yml accurately reflects the keys that | ||
are used by this template. */ -}} | ||
{{range gets "/ipc/kafka/*" -}} | ||
{{base .Key}} = {{.Value}} | ||
{{end -}} |
5 changes: 5 additions & 0 deletions
5
...r/sentinel/container-fs/confd/templates/org.opennms.core.ipc.sink.kafka.consumer.cfg.tmpl
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,5 @@ | ||
{{- /* Upon updating this file please ensure that the schema sentinel-config-schema.yml accurately reflects the keys that | ||
are used by this template. */ -}} | ||
{{range gets "/ipc/kafka/*" -}} | ||
{{base .Key}} = {{.Value}} | ||
{{end -}} |
17 changes: 17 additions & 0 deletions
17
...inel/container-fs/confd/templates/org.opennms.features.flows.persistence.elastic.cfg.tmpl
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,17 @@ | ||
{{- /* Upon updating this file please ensure that the schema sentinel-config-schema.yml accurately reflects the keys that | ||
are used by this template. */ -}} | ||
{{if exists "/elasticsearch/url" -}} | ||
elasticUrl = {{getv "/elasticsearch/url"}} | ||
{{end -}} | ||
{{if exists "/elasticsearch/index-strategy" -}} | ||
elasticIndexStrategy = {{getv "/elasticsearch/index-strategy"}} | ||
{{end -}} | ||
{{if exists "/elasticsearch/replicas" -}} | ||
settings.index.number_of_replicas = {{getv "/elasticsearch/replicas"}} | ||
{{end -}} | ||
{{if exists "/elasticsearch/conn-timeout" -}} | ||
connTimeout = {{getv "/elasticsearch/conn-timeout"}} | ||
{{end -}} | ||
{{if exists "/elasticsearch/read-timeout" -}} | ||
readTimeout = {{getv "/elasticsearch/read-timeout"}} | ||
{{end -}} |
14 changes: 14 additions & 0 deletions
14
.../sentinel/container-fs/confd/templates/org.opennms.netmgt.distributed.datasource.cfg.tmpl
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,14 @@ | ||
{{- /* Upon updating this file please ensure that the schema sentinel-config-schema.yml accurately reflects the keys that | ||
are used by this template. */ -}} | ||
{{if exists "/datasource/url" -}} | ||
datasource.url = {{getv "/datasource/url"}} | ||
{{end -}} | ||
{{if exists "/datasource/username" -}} | ||
datasource.username = {{getv "/datasource/username"}} | ||
{{end -}} | ||
{{if exists "/datasource/password" -}} | ||
datasource.password = {{getv "/datasource/password"}} | ||
{{end -}} | ||
{{if exists "/datasource/database-name" -}} | ||
datasource.databaseName = {{getv "/datasource/database-name"}} | ||
{{end -}} |
11 changes: 11 additions & 0 deletions
11
...-container/sentinel/container-fs/confd/templates/org.opennms.sentinel.controller.cfg.tmpl
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,11 @@ | ||
{{- /* Upon updating this file please ensure that the schema sentinel-config-schema.yml accurately reflects the keys that | ||
are used by this template. */ -}} | ||
{{if exists "/location" -}} | ||
location = {{getv "/location"}} | ||
{{end -}} | ||
{{if exists "/id" -}} | ||
id = {{getv "/id"}} | ||
{{end -}} | ||
{{if exists "/broker-url" -}} | ||
broker-url = {{getv "/broker-url"}} | ||
{{end -}} |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can drop this one as well, -1 line 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done