Skip to content

Commit

Permalink
feat: grafana helm support
Browse files Browse the repository at this point in the history
  • Loading branch information
tfoldi committed Jun 13, 2023
1 parent 51cc655 commit 22b59dd
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 0 deletions.
1 change: 1 addition & 0 deletions deployment/kubernetes/Pulumi.github-actions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ config:
lm-sensors: true
monitoring: true
influxdb2: true
grafana: true
antares-idl-k8s:config:
cloud:
type: aws
Expand Down
1 change: 1 addition & 0 deletions deployment/kubernetes/Pulumi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ config:
antares-idl-k8s:components.growatt: false
antares-idl-k8s:components.lm-sensors: false
antares-idl-k8s:components.influxdb2: false
antares-idl-k8s:components.grafana: false
# Monitoring includes Prometheus, Grafana and Etcd on a separate
# namespace
antares-idl-k8s:components.monitoring: false
Expand Down
4 changes: 4 additions & 0 deletions deployment/kubernetes/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import postgresql
import emqx
import influxdb2
import grafana
import cert_manager
import growatt
import lm_sensors
Expand Down Expand Up @@ -100,6 +101,9 @@
if component_enabled("influxdb2"):
influxdb2.deploy()

if component_enabled("grafana"):
grafana.deploy()

if component_enabled("growatt"):
growatt.deploy()

Expand Down
85 changes: 85 additions & 0 deletions deployment/kubernetes/grafana.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
"""
MIT License
Copyright (c) 2023 HCLTech
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""

import pulumi
from pulumi_kubernetes.helm.v3 import (
Release,
ReleaseArgs,
RepositoryOptsArgs,
)
from pulumi_kubernetes.core.v1 import Secret, SecretInitArgs
from pulumi_kubernetes.meta.v1 import ObjectMetaArgs
from antares_common.resources import resources, component_enabled
from antares_common.config import config


def deploy():
grafana_helm_values = {"securityContext": {"runAsUser": 1000, "runAsGroup": 1000}}

if component_enabled("efs-eks"):
grafana_helm_values["persistence"] = {
"enabled": True,
"storageClass": "efs-sc-user-1000",
"accessModes": ["ReadWriteMany"],
}

admin_password_secret = Secret(
"grafana-admin",
SecretInitArgs(
string_data={
"admin-password": config.get("/grafana/admin-password", "antares12"),
"admin-user": "admin",
},
metadata=ObjectMetaArgs(
namespace=resources["namespace"].metadata["name"],
name="grafana-admin",
),
),
)

resources["grafana-admin-password"] = admin_password_secret
grafana_helm_values["admin"] = {
"existingSecret": "grafana-admin",
}

grafana_release = Release(
"grafana",
ReleaseArgs(
chart="grafana",
name="grafana",
repository_opts=RepositoryOptsArgs(
repo="https://grafana.github.io/helm-charts",
),
namespace=resources["namespace"].metadata["name"],
values={
**grafana_helm_values,
**(config.get("/grafana/helm-values", {})),
},
),
opts=pulumi.ResourceOptions(depends_on=[resources["grafana-admin-password"]]),
)

resources["grafana"] = grafana_release

return

0 comments on commit 22b59dd

Please sign in to comment.