diff --git a/DistTestCore/Metrics/GrafanaContainerRecipe.cs b/DistTestCore/Metrics/GrafanaContainerRecipe.cs new file mode 100644 index 0000000..5e52965 --- /dev/null +++ b/DistTestCore/Metrics/GrafanaContainerRecipe.cs @@ -0,0 +1,19 @@ +using KubernetesWorkflow; + +namespace DistTestCore.Metrics +{ + public class GrafanaContainerRecipe : ContainerRecipeFactory + { + public override string AppName => "grafana"; + public override string Image => "grafana/grafana-oss:10.0.3"; + + protected override void Initialize(StartupConfig startupConfig) + { + //var config = startupConfig.Get(); + + //AddExposedPortAndVar("PROM_PORT"); + AddExposedPort(3000); + //AddEnvVar("PROM_CONFIG", config.PrometheusConfigBase64); + } + } +} diff --git a/DistTestCore/PrometheusStarter.cs b/DistTestCore/PrometheusStarter.cs index 1804b77..862907d 100644 --- a/DistTestCore/PrometheusStarter.cs +++ b/DistTestCore/PrometheusStarter.cs @@ -22,6 +22,10 @@ namespace DistTestCore var runningContainers = workflow.Start(1, Location.Unspecified, new PrometheusContainerRecipe(), startupConfig); if (runningContainers.Containers.Length != 1) throw new InvalidOperationException("Expected only 1 Prometheus container to be created."); + workflow = lifecycle.WorkflowCreator.CreateWorkflow(); + var grafanaContainers = workflow.Start(1, Location.Unspecified, new GrafanaContainerRecipe(), startupConfig); + if (grafanaContainers.Containers.Length != 1) throw new InvalidOperationException("should be 1"); + LogEnd("Metrics server started."); return runningContainers; diff --git a/KubernetesWorkflow/ContainerRecipeFactory.cs b/KubernetesWorkflow/ContainerRecipeFactory.cs index 470bd42..36fff5b 100644 --- a/KubernetesWorkflow/ContainerRecipeFactory.cs +++ b/KubernetesWorkflow/ContainerRecipeFactory.cs @@ -40,6 +40,13 @@ return p; } + protected Port AddExposedPort(int number, string tag = "") + { + var p = factory.CreatePort(number, tag); + exposedPorts.Add(p); + return p; + } + protected Port AddInternalPort(string tag = "") { var p = factory.CreatePort(tag); diff --git a/KubernetesWorkflow/RecipeComponentFactory.cs b/KubernetesWorkflow/RecipeComponentFactory.cs index cf1f67b..9644515 100644 --- a/KubernetesWorkflow/RecipeComponentFactory.cs +++ b/KubernetesWorkflow/RecipeComponentFactory.cs @@ -7,6 +7,11 @@ namespace KubernetesWorkflow { private NumberSource portNumberSource = new NumberSource(8080); + public Port CreatePort(int number, string tag) + { + return new Port(number, tag); + } + public Port CreatePort(string tag) { return new Port(portNumberSource.GetNextNumber(), tag);