Skip to content

Commit

Permalink
Improvements based upon PR feedback.
Browse files Browse the repository at this point in the history
Signed-off-by: Greg Schohn <[email protected]>
  • Loading branch information
gregschohn committed Jan 10, 2025
1 parent 98d4fa3 commit 98a3385
Show file tree
Hide file tree
Showing 15 changed files with 63 additions and 153 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)


class ConfigMapWatcher:
def __init__(self, label_selector: str, namespace: str, output_file: str):
self.label_selector = label_selector
Expand Down Expand Up @@ -101,6 +102,7 @@ def watch_configmaps(self) -> None:
logger.error(f"Error watching ConfigMaps: {e}")
raise


def parse_args():
parser = argparse.ArgumentParser(
description='Watch Kubernetes ConfigMaps and update a YAML file'
Expand All @@ -122,10 +124,12 @@ def parse_args():
)
return parser.parse_args()


def sigterm_handler(signum, frame):
# Clean exit without traceback
sys.exit(0)


if __name__ == "__main__":
args = parse_args()

Expand All @@ -143,4 +147,4 @@ def sigterm_handler(signum, frame):
sys.exit(0)
except Exception as e:
logger.error(f"Fatal error: {e}")
sys.exit(1)
sys.exit(1)
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/python3
import os
import yaml
import sys


# Parse YAML and extract value using dot notation
def yaml_extract(yaml_str, path):
data = yaml.safe_load(yaml_str)
Expand All @@ -12,6 +12,7 @@ def yaml_extract(yaml_str, path):
result = result[key]
return result


if __name__ == "__main__":
# Parse args like yq does: script.py '.foo.bar' file.yaml
path = sys.argv[1]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
import yaml
from jinja2 import Environment, FileSystemLoader


def to_yaml_filter(value):
"""Custom filter to convert value to YAML format."""
if value is None:
return ''
return yaml.dump(value, default_flow_style=False).rstrip()


def pop_value(dictionary, key, default=None):
"""Remove and return a value from a nested dictionary using dot notation."""
keys = key.split('.')
Expand Down Expand Up @@ -49,6 +51,7 @@ def convert(self, inStream, outStream):
template = env.get_template(self.template_file)
outStream.write(template.render(values=values))


def main():
template_path = sys.argv[1] if len(sys.argv) > 1 else 'template.yaml.j2'
template_dir = os.path.dirname(template_path) or '.'
Expand All @@ -63,5 +66,6 @@ def main():
print(f"Error: {e}", file=sys.stderr)
sys.exit(1)


if __name__ == '__main__':
main()
main()
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
import os
import shlex


# Export environment variables to sourceable shell script
def export_env():
for key, value in sorted(os.environ.items()):
print(f"export {key}={shlex.quote(value)}")


# Main logic to handle both cases
if __name__ == "__main__":
# No args - export env vars
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
source_cluster:
endpoint: "https://capture-proxy:9201"
endpoint: "https://capture-proxy:9200"
allow_insecure: true
basic_auth:
username: "admin"
password: "admin"
target_cluster:
endpoint: "https://opensearch-cluster-master:9200"
endpoint: "https://opensearchtarget:9200"
allow_insecure: true
basic_auth:
username: "admin"
Expand All @@ -19,14 +19,14 @@ backfill:
replay:
docker:
snapshot:
snapshot_name: "rfs-snapshot"
snapshot_name: "snapshot_2023_01_01"
fs:
repo_path: "/storage/snapshot"
otel_endpoint: "http://localhost:4317"
repo_path: "/snapshot/test-console"
otel_endpoint: "http://otel-collector:4317"
metadata_migration:
from_snapshot:
min_replicas: 0
otel_endpoint: "http://localhost:4317"
otel_endpoint: "http://otel-collector:4317"
kafka:
broker_endpoints: "kafka-cluster-kafka-bootstrap:9092"
standard: ""
broker_endpoints: "kafka:9092"
standard: ""
41 changes: 41 additions & 0 deletions deployment/k8s/charts/aggregates/migrationAssistant/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,44 @@ captured-traffic-kafka-cluster:
dedicatedController:
replicas: 1
storageSize: 10Gi

jaeger:
allInOne:
enabled: true
provisionDataStore:
cassandra: false
storage:
type: memory
agent:
enabled: false
collector:
enabled: false
query:
enabled: false

grafana:
## Grafana data sources configuration
datasources:
datasources.yaml:
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
access: proxy
url: http://prometheus-server.prometheus.svc.cluster.local:9090
isDefault: true
editable: true
- name: Jaeger
type: jaeger
access: proxy
url: http://jaeger-query.jaeger.svc.cluster.local:16686
isDefault: false
editable: true

## Set up the sidecar to import data sources (usually enabled by default)
sidecar:
datasources:
enabled: true
dashboards:
enabled: true
label: grafana_dashboard

This file was deleted.

32 changes: 0 additions & 32 deletions deployment/k8s/charts/components/migrationConsole/sample.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions deployment/k8s/helmValues/localTesting/captureProxy.yaml

This file was deleted.

25 changes: 0 additions & 25 deletions deployment/k8s/helmValues/localTesting/grafana.yaml

This file was deleted.

13 changes: 0 additions & 13 deletions deployment/k8s/helmValues/localTesting/jaeger.yaml

This file was deleted.

2 changes: 0 additions & 2 deletions deployment/k8s/helmValues/localTesting/kafka.yaml

This file was deleted.

Empty file.

This file was deleted.

This file was deleted.

0 comments on commit 98a3385

Please sign in to comment.