From 731ab90ce12279d4be3a0ae65a21fd74cf96048f Mon Sep 17 00:00:00 2001 From: benbierens Date: Tue, 27 Jun 2023 08:29:39 +0200 Subject: [PATCH] Easier local deployments --- CodexNetDeployer/Configuration.cs | 24 ++++++++---------------- CodexNetDeployer/Deployer.cs | 16 ++++++++++++---- CodexNetDeployer/Program.cs | 2 +- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/CodexNetDeployer/Configuration.cs b/CodexNetDeployer/Configuration.cs index 2e7f232..b25e483 100644 --- a/CodexNetDeployer/Configuration.cs +++ b/CodexNetDeployer/Configuration.cs @@ -8,16 +8,16 @@ namespace CodexNetDeployer public class Configuration { [Uniform("codex-image", "ci", "CODEXIMAGE", true, "Docker image of Codex.")] - public string CodexImage { get; set; } = string.Empty; + public string CodexImage { get; set; } = CodexContainerRecipe.DockerImage; [Uniform("geth-image", "gi", "GETHIMAGE", true, "Docker image of Geth.")] - public string GethImage { get; set; } = string.Empty; + public string GethImage { get; set; } = GethContainerRecipe.DockerImage; [Uniform("contracts-image", "oi", "CONTRACTSIMAGE", true, "Docker image of Codex Contracts.")] - public string ContractsImage { get; set; } = string.Empty; + public string ContractsImage { get; set; } = CodexContractsContainerRecipe.DockerImage; - [Uniform("kube-config", "kc", "KUBECONFIG", true, "Path to Kubeconfig file.")] - public string KubeConfigFile { get; set; } = string.Empty; + [Uniform("kube-config", "kc", "KUBECONFIG", false, "Path to Kubeconfig file. Use 'null' (default) to use local cluster.")] + public string KubeConfigFile { get; set; } = "null"; [Uniform("kube-namespace", "kn", "KUBENAMESPACE", true, "Kubernetes namespace to be used for deployment.")] public string KubeNamespace { get; set; } = string.Empty; @@ -32,18 +32,10 @@ namespace CodexNetDeployer public int? StorageQuota { get; set; } [Uniform("log-level", "l", "LOGLEVEL", true, "Log level used by each Codex node. [Trace, Debug*, Info, Warn, Error]")] - public CodexLogLevel CodexLogLevel { get; set; } + public CodexLogLevel CodexLogLevel { get; set; } = CodexLogLevel.Debug; public TestRunnerLocation RunnerLocation { get; set; } = TestRunnerLocation.InternalToCluster; - public class Defaults - { - public string CodexImage { get; set; } = CodexContainerRecipe.DockerImage; - public string GethImage { get; set; } = GethContainerRecipe.DockerImage; - public string ContractsImage { get; set; } = CodexContractsContainerRecipe.DockerImage; - public CodexLogLevel CodexLogLevel { get; set; } = CodexLogLevel.Debug; - } - public List Validate() { var errors = new List(); @@ -74,7 +66,7 @@ namespace CodexNetDeployer { if (value == null || value.Value < 1) { - errors.Add($"{variable} is must be set and must be greater than 0."); + errors.Add($"{variable} must be set and must be greater than 0."); } } @@ -82,7 +74,7 @@ namespace CodexNetDeployer { if (string.IsNullOrWhiteSpace(value)) { - errors.Add($"{variable} is must be set."); + errors.Add($"{variable} must be set."); } } } diff --git a/CodexNetDeployer/Deployer.cs b/CodexNetDeployer/Deployer.cs index 5745dd9..ba0ecc5 100644 --- a/CodexNetDeployer/Deployer.cs +++ b/CodexNetDeployer/Deployer.cs @@ -51,9 +51,11 @@ namespace CodexNetDeployer private (WorkflowCreator, TestLifecycle) CreateFacilities() { + var kubeConfig = GetKubeConfig(config.KubeConfigFile); + var lifecycleConfig = new DistTestCore.Configuration ( - kubeConfigFile: config.KubeConfigFile, + kubeConfigFile: kubeConfig, logPath: "null", logDebug: false, dataFilesPath: "notUsed", @@ -61,18 +63,24 @@ namespace CodexNetDeployer runnerLocation: config.RunnerLocation ); - var kubeConfig = new KubernetesWorkflow.Configuration( + var kubeFlowConfig = new KubernetesWorkflow.Configuration( k8sNamespacePrefix: config.KubeNamespace, - kubeConfigFile: config.KubeConfigFile, + kubeConfigFile: kubeConfig, operationTimeout: timeset.K8sOperationTimeout(), retryDelay: timeset.WaitForK8sServiceDelay()); - var workflowCreator = new WorkflowCreator(log, kubeConfig, testNamespacePostfix: string.Empty); + var workflowCreator = new WorkflowCreator(log, kubeFlowConfig, testNamespacePostfix: string.Empty); var lifecycle = new TestLifecycle(log, lifecycleConfig, timeset, workflowCreator); return (workflowCreator, lifecycle); } + private string? GetKubeConfig(string kubeConfigFile) + { + if (string.IsNullOrEmpty(kubeConfigFile) || kubeConfigFile.ToLowerInvariant() == "null") return null; + return kubeConfigFile; + } + private DeploymentMetadata CreateMetadata() { return new DeploymentMetadata( diff --git a/CodexNetDeployer/Program.cs b/CodexNetDeployer/Program.cs index bc38c80..4ac3a2f 100644 --- a/CodexNetDeployer/Program.cs +++ b/CodexNetDeployer/Program.cs @@ -17,7 +17,7 @@ public class Program return; } - var uniformArgs = new ArgsUniform(new Configuration.Defaults(), args); + var uniformArgs = new ArgsUniform(args); var config = uniformArgs.Parse(true); if (args.Any(a => a == "--external"))