osm_dashboards: bool
site_url: Optional[str]
cluster_issuer: Optional[str]
+ ingress_class: Optional[str]
ingress_whitelist_source_range: Optional[str]
tls_secret_name: Optional[str]
+ image_pull_policy: Optional[str]
@validator("max_file_size")
def validate_max_file_size(cls, v):
ip_network(v)
return v
+ @validator("image_pull_policy")
+ def validate_image_pull_policy(cls, v):
+ values = {
+ "always": "Always",
+ "ifnotpresent": "IfNotPresent",
+ "never": "Never",
+ }
+ v = v.lower()
+ if v not in values.keys():
+ raise ValueError("value must be always, ifnotpresent or never")
+ return values[v]
+
class GrafanaCharm(CharmedOsmBase):
"""GrafanaCharm Charm."""
files_builder = FilesV3Builder()
files_builder.add_file(
"dashboard_osm.yaml",
- Path("files/default_dashboards.yaml").read_text(),
+ Path("templates/default_dashboards.yaml").read_text(),
)
if config.osm_dashboards:
osm_dashboards_mapping = {
- "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",
+ "kafka_exporter_dashboard.json": "templates/kafka_exporter_dashboard.json",
+ "mongodb_exporter_dashboard.json": "templates/mongodb_exporter_dashboard.json",
+ "mysql_exporter_dashboard.json": "templates/mysql_exporter_dashboard.json",
+ "nodes_exporter_dashboard.json": "templates/nodes_exporter_dashboard.json",
+ "summary_dashboard.json": "templates/summary_dashboard.json",
}
for file_name, path in osm_dashboards_mapping.items():
files_builder.add_file(file_name, Path(path).read_text())
files_builder = FilesV3Builder()
files_builder.add_file(
"datasource_prometheus.yaml",
- Template(Path("files/default_datasources.yaml").read_text()).substitute(
+ Template(Path("templates/default_datasources.yaml").read_text()).substitute(
prometheus_host=self.prometheus_client.hostname,
prometheus_port=self.prometheus_client.port,
),
# Create Builder for the PodSpec
pod_spec_builder = PodSpecV3Builder()
# Build Container
- container_builder = ContainerV3Builder(self.app.name, image_info)
+ container_builder = ContainerV3Builder(
+ self.app.name, image_info, config.image_pull_policy
+ )
container_builder.add_port(name=self.app.name, port=PORT)
container_builder.add_http_readiness_probe(
"/api/health",
str(config.max_file_size) + "m"
if config.max_file_size > 0
else config.max_file_size
- ),
- "kubernetes.io/ingress.class": "public",
+ )
}
+ if config.ingress_class:
+ annotations["kubernetes.io/ingress.class"] = config.ingress_class
ingress_resource_builder = IngressResourceV3Builder(
f"{self.app.name}-ingress", annotations
)