# pylint: disable=E0213
-import logging
-from typing import Optional, NoReturn
from ipaddress import ip_network
+import logging
+from pathlib import Path
+from string import Template
+from typing import NoReturn, Optional
+from urllib.parse import urlparse
from ops.main import main
-
from opslib.osm.charm import CharmedOsmBase, RelationsMissing
-
+from opslib.osm.interfaces.prometheus import PrometheusClient
from opslib.osm.pod import (
- IngressResourceV3Builder,
- FilesV3Builder,
ContainerV3Builder,
+ FilesV3Builder,
+ IngressResourceV3Builder,
PodSpecV3Builder,
)
+from opslib.osm.validator import ModelValidator, validator
-from opslib.osm.validator import (
- ModelValidator,
- validator,
-)
-
-from opslib.osm.interfaces.prometheus import PrometheusClient
-
-from urllib.parse import urlparse
-from string import Template
-from pathlib import Path
-
logger = logging.getLogger(__name__)
PORT = 3000
max_file_size: int
osm_dashboards: bool
site_url: Optional[str]
+ cluster_issuer: Optional[str]
ingress_whitelist_source_range: Optional[str]
tls_secret_name: Optional[str]
super().__init__(*args, oci_image="image")
self.prometheus_client = PrometheusClient(self, "prometheus")
- self.framework.observe(self.on["prometheus"].relation_changed, self.configure_pod)
- self.framework.observe(self.on["prometheus"].relation_broken, self.configure_pod)
+ self.framework.observe(
+ self.on["prometheus"].relation_changed, self.configure_pod
+ )
+ self.framework.observe(
+ self.on["prometheus"].relation_broken, self.configure_pod
+ )
def _build_dashboard_files(self, config: ConfigModel):
files_builder = FilesV3Builder()
)
if config.osm_dashboards:
osm_dashboards_mapping = {
- "kafka_exporter_dashboard.yaml": "files/kafka_exporter_dashboard.yaml",
- "mongodb_exporter_dashboard.yaml": "files/mongodb_exporter_dashboard.yaml",
- "mysql_exporter_dashboard.yaml": "files/mysql_exporter_dashboard.yaml",
- "nodes_exporter_dashboard.yaml": "files/nodes_exporter_dashboard.yaml",
- "summary_dashboard.yaml": "files/summary_dashboard.yaml",
+ "kafka_exporter_dashboard.json": "files/kafka_exporter_dashboard.json",
+ "mongodb_exporter_dashboard.json": "files/mongodb_exporter_dashboard.json",
+ "mysql_exporter_dashboard.json": "files/mysql_exporter_dashboard.json",
+ "nodes_exporter_dashboard.json": "files/nodes_exporter_dashboard.json",
+ "summary_dashboard.json": "files/summary_dashboard.json",
}
for file_name, path in osm_dashboards_mapping.items():
files_builder.add_file(file_name, Path(path).read_text())
"nginx.ingress.kubernetes.io/whitelist-source-range"
] = config.ingress_whitelist_source_range
+ if config.cluster_issuer:
+ annotations["cert-manager.io/cluster-issuer"] = config.cluster_issuer
+
if parsed.scheme == "https":
ingress_resource_builder.add_tls(
[parsed.hostname], config.tls_secret_name