-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* create mechanism of enabling and disabling pluggable modules * setup tests for sc4s lite * make for sc4s lite available all the topcis that supporting sc4s * k8s setup for pluggable modules * add commented example to helm of pluggable modules * create pluggable modules * add docs for pluggable modules * test
- Loading branch information
1 parent
6e26eb8
commit a20752d
Showing
436 changed files
with
11,187 additions
and
1,027 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
10 changes: 10 additions & 0 deletions
10
charts/splunk-connect-for-syslog/templates/addon-configmap.yaml
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 @@ | ||
{{- if .Values.sc4s.addons }} | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ include "splunk-connect-for-syslog.fullname" . }}-addons | ||
labels: | ||
{{- include "splunk-connect-for-syslog.labels" . | nindent 4 }} | ||
data: | ||
{{ toYaml .Values.sc4s.addons | indent 2 }} | ||
{{- 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
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
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,57 @@ | ||
# Pluggable modules guide: | ||
|
||
Pluggable modules **it's predefined modules**, that you can **only** *enable/disable* by changing config file. | ||
After updating this config file with enabled addons you need to restart sc4s. | ||
|
||
This config file it's a yaml file with list of addons ([whole list of addons here](https://github.com/splunk/splunk-connect-for-syslog/blob/main/package/lite/etc/config.yaml)): | ||
``` | ||
--- | ||
addons: | ||
- cisco | ||
- paloalto | ||
- dell | ||
``` | ||
|
||
You don't need to rebuild docker image, you **need mount custom config** into */etc/syslog-ng/config.yaml*. | ||
|
||
|
||
## docker-compose: | ||
|
||
1. [Read guide](./gettingstarted/docker-compose.md) how to use *docker-compose* for SC4S | ||
|
||
2. Use *SC4S Lite image* instead of *SC4S* in docker-compose.yaml | ||
``` | ||
image: ghcr.io/splunk/splunk-connect-for-syslog/container3lite | ||
``` | ||
|
||
3. *Mount config file* with addons to */etc/syslog-ng/config.yaml*: | ||
|
||
``` | ||
volumes: | ||
- /path/to/your/config.yaml:/etc/syslog-ng/config.yaml | ||
``` | ||
|
||
|
||
|
||
## k8s: | ||
|
||
1. [Read guide](./gettingstarted/k8s-microk8s.md) how to use *k8s* for SC4S | ||
|
||
2. Use *SC4S Lite image* instead of *SC4S* in values.yaml: | ||
``` | ||
image: | ||
repository: ghcr.io/splunk/splunk-connect-for-syslog/container3lite | ||
``` | ||
|
||
3. Mount config file. Add *addons* section on *sc4s* section of values.yaml: | ||
|
||
``` | ||
sc4s: | ||
addons: | ||
config.yaml: |- | ||
--- | ||
addons: | ||
- cisco | ||
- paloalto | ||
- dell | ||
``` |
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
Empty file.
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 @@ | ||
from argparse import ArgumentParser | ||
from pathlib import Path | ||
|
||
from .addons import load_addons | ||
from .config import load_addons_config | ||
from .template_generator import template_generator | ||
|
||
|
||
def parse_cli_args(): | ||
cli_parser = ArgumentParser() | ||
cli_parser.add_argument("--config", type=Path) | ||
return cli_parser.parse_args() | ||
|
||
|
||
def generate_syslogng_config() -> None: | ||
cli_args = parse_cli_args() | ||
config = load_addons_config(cli_args.config) | ||
addons = load_addons(config.addons_path) | ||
|
||
syslogng_config = template_generator( | ||
config.syslog_path, | ||
config=config, | ||
addons=sorted(addons, key=lambda addon: addon.path), | ||
) | ||
print(syslogng_config) | ||
|
||
|
||
if __name__ == "__main__": | ||
generate_syslogng_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,50 @@ | ||
from dataclasses import dataclass | ||
from logging import getLogger | ||
from pathlib import Path | ||
|
||
import yaml | ||
|
||
|
||
logger = getLogger(__name__) | ||
|
||
|
||
@dataclass | ||
class AddonMetadata: | ||
name: str | ||
|
||
|
||
@dataclass | ||
class Addon: | ||
path: Path | ||
metadata: AddonMetadata | ||
|
||
|
||
def load_addons(addons_directory: Path) -> list[Addon]: | ||
addons: list[Addon] = [] | ||
|
||
for potential_addon in addons_directory.iterdir(): | ||
addon_full_path = addons_directory / potential_addon | ||
|
||
if ( | ||
addon_full_path.is_dir() and | ||
(addon_full_path / "addon_metadata.yaml").exists() | ||
): | ||
try: | ||
metadata = load_addon_metadata(addon_full_path) | ||
addons.append(Addon(path=addon_full_path, metadata=metadata)) | ||
except Exception as e: | ||
logger.error(f"Skipping invalid addon {potential_addon}") | ||
raise e | ||
|
||
return addons | ||
|
||
|
||
def load_addon_metadata(addon_path: Path) -> AddonMetadata: | ||
with open(addon_path / "addon_metadata.yaml", "r") as file_stream: | ||
try: | ||
metadata = yaml.safe_load(file_stream) | ||
return AddonMetadata(name=metadata["name"]) | ||
except yaml.YAMLError: | ||
logger.error(f"Metadata file of {addon_path} should be valid yaml") | ||
except KeyError: | ||
logger.error(f"Missing metadata in {addon_path}") |
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,26 @@ | ||
from dataclasses import dataclass | ||
from logging import getLogger | ||
from os.path import expandvars | ||
from pathlib import Path | ||
|
||
import yaml | ||
|
||
logger = getLogger(__name__) | ||
|
||
|
||
@dataclass | ||
class Config: | ||
addons: list[str] | ||
addons_path: Path = Path(expandvars("${SC4S_ETC}/addons")) | ||
syslog_path: Path = Path(expandvars("${SC4S_ETC}/syslog-ng.conf.jinja")) | ||
|
||
|
||
def load_addons_config(config_path: Path) -> Config: | ||
with open(config_path, "r") as file_stream: | ||
try: | ||
raw_config = yaml.safe_load(file_stream) | ||
return Config(**raw_config) | ||
except yaml.YAMLError: | ||
logger.error("Config should be correct yaml") | ||
except KeyError: | ||
logger.error("Field is missing in 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,12 @@ | ||
from pathlib import Path | ||
|
||
import jinja2 | ||
|
||
|
||
def template_generator(template_path: Path, **kwargs) -> str: | ||
env = jinja2.Environment( | ||
loader=jinja2.FileSystemLoader(template_path.parent), | ||
autoescape=False, | ||
) | ||
template = env.get_template(template_path.name) | ||
return template.render(**kwargs) |
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,2 @@ | ||
--- | ||
name: "a10networks" |
Oops, something went wrong.