Example #1
0
        public static async Task ExecuteGenerateAsync(OutputContext output, ApplicationBuilder application, string environment, bool interactive)
        {
            await application.ProcessExtensionsAsync(ExtensionContext.OperationKind.Deploy);

            var steps = new List <ServiceExecutor.Step>()
            {
                new CombineStep()
                {
                    Environment = environment,
                },
                new PublishProjectStep(),
                new BuildDockerImageStep()
                {
                    Environment = environment,
                },                                                         // Make an image but don't push it
            };

            steps.Add(new GenerateKubernetesManifestStep()
            {
                Environment = environment,
            });

            Program.ApplyRegistryAndDefaults(output, application, interactive, requireRegistry: false);

            var executor = new ServiceExecutor(output, application, steps);

            foreach (var service in application.Services)
            {
                await executor.ExecuteAsync(service);
            }

            await GenerateApplicationManifestAsync(output, application, environment);
        }
Example #2
0
        private static async Task ExecutePushAsync(OutputContext output, ApplicationBuilder application, string environment, bool interactive, bool force)
        {
            await application.ProcessExtensionsAsync(options : null, output, ExtensionContext.OperationKind.Deploy);

            ApplyRegistry(output, application, interactive, requireRegistry: true);

            var executor = new ApplicationExecutor(output)
            {
                ServiceSteps =
                {
                    new ApplyContainerDefaultsStep(),
                    new CombineStep()
                    {
                        Environment = environment,
                    },
                    new PublishProjectStep(),
                    new BuildDockerImageStep()
                    {
                        Environment = environment,
                    },
                    new PushDockerImageStep()
                    {
                        Environment = environment,
                    },
                },
            };

            await executor.ExecuteAsync(application);
        }
Example #3
0
        private static async Task ExecutePushAsync(OutputContext output, ApplicationBuilder application, string environment, bool interactive, bool force)
        {
            await application.ProcessExtensionsAsync(output, ExtensionContext.OperationKind.Deploy);

            var steps = new List <ServiceExecutor.Step>()
            {
                new CombineStep()
                {
                    Environment = environment,
                },
                new PublishProjectStep(),
                new BuildDockerImageStep()
                {
                    Environment = environment,
                },
                new PushDockerImageStep()
                {
                    Environment = environment,
                },
            };

            ApplyRegistryAndDefaults(output, application, interactive, requireRegistry: true);

            var executor = new ServiceExecutor(output, application, steps);

            foreach (var service in application.Services)
            {
                await executor.ExecuteAsync(service);
            }
        }
Example #4
0
        private static async Task ExecuteDeployAsync(OutputContext output, ApplicationBuilder application, string environment, bool interactive, bool force)
        {
            if (!await KubectlDetector.Instance.IsKubectlInstalled.Value)
            {
                throw new CommandException($"Cannot apply manifests because kubectl is not installed.");
            }

            if (!await KubectlDetector.Instance.IsKubectlConnectedToCluster.Value)
            {
                throw new CommandException($"Cannot apply manifests because kubectl is not connected to a cluster.");
            }

            await application.ProcessExtensionsAsync(output, ExtensionContext.OperationKind.Deploy);

            var steps = new List <ServiceExecutor.Step>()
            {
                new CombineStep()
                {
                    Environment = environment,
                },
                new PublishProjectStep(),
                new BuildDockerImageStep()
                {
                    Environment = environment,
                },
                new PushDockerImageStep()
                {
                    Environment = environment,
                },
                new ValidateSecretStep()
                {
                    Environment = environment, Interactive = interactive, Force = force,
                },
            };

            steps.Add(new GenerateKubernetesManifestStep()
            {
                Environment = environment,
            });
            steps.Add(new DeployServiceYamlStep()
            {
                Environment = environment,
            });

            ApplyRegistryAndDefaults(output, application, interactive, requireRegistry: true);

            var executor = new ServiceExecutor(output, application, steps);

            foreach (var service in application.Services)
            {
                await executor.ExecuteAsync(service);
            }

            await DeployApplicationManifestAsync(output, application, application.Source.Directory.Name);
        }
Example #5
0
        public static async Task ExecuteGenerateAsync(OutputContext output, ApplicationBuilder application, string environment, bool interactive)
        {
            await application.ProcessExtensionsAsync(output, ExtensionContext.OperationKind.Deploy);

            Program.ApplyRegistry(output, application, interactive, requireRegistry: false);

            var executor = new ApplicationExecutor(output)
            {
                ServiceSteps =
                {
                    new ApplyContainerDefaultsStep(),
                    new CombineStep()
                    {
                        Environment = environment,
                    },
                    new PublishProjectStep(),
                    new BuildDockerImageStep()
                    {
                        Environment = environment,
                    },                                                         // Make an image but don't push it
                    new GenerateServiceKubernetesManifestStep()
                    {
                        Environment = environment,
                    },
                },

                IngressSteps =
                {
                    new GenerateIngressKubernetesManifestStep(),
                },

                ApplicationSteps =
                {
                    new GenerateApplicationKubernetesManifestStep()
                    {
                        Environment = environment,
                    },
                }
            };

            await executor.ExecuteAsync(application);
        }
Example #6
0
        private static async Task ExecuteDeployAsync(OutputContext output, ApplicationBuilder application, string environment, bool interactive, bool force)
        {
            var watch = System.Diagnostics.Stopwatch.StartNew();

            if (!await KubectlDetector.IsKubectlInstalledAsync(output))
            {
                throw new CommandException($"Cannot apply manifests because kubectl is not installed.");
            }

            if (!await KubectlDetector.IsKubectlConnectedToClusterAsync(output))
            {
                throw new CommandException($"Cannot apply manifests because kubectl is not connected to a cluster.");
            }

            await application.ProcessExtensionsAsync(options : null, output, ExtensionContext.OperationKind.Deploy);

            ApplyRegistry(output, application, interactive, requireRegistry: true);

            var executor = new ApplicationExecutor(output)
            {
                ServiceSteps =
                {
                    new ApplyContainerDefaultsStep(),
                    new CombineStep()
                    {
                        Environment = environment,
                    },
                    new PublishProjectStep(),
                    new BuildDockerImageStep()
                    {
                        Environment = environment,
                    },
                    new PushDockerImageStep()
                    {
                        Environment = environment,
                    },
                    new ValidateSecretStep()
                    {
                        Environment = environment,   Interactive= interactive, Force = force,
                    },
                    new GenerateServiceKubernetesManifestStep()
                    {
                        Environment = environment,
                    },
                },

                IngressSteps =
                {
                    new ValidateIngressStep()
                    {
                        Environment = environment, Interactive = interactive, Force = force,
                    },
                    new GenerateIngressKubernetesManifestStep(),
                },

                ApplicationSteps =
                {
                    new DeployApplicationKubernetesManifestStep(),
                }
            };

            await executor.ExecuteAsync(application);

            watch.Stop();

            TimeSpan elapsedTime = watch.Elapsed;

            output.WriteAlwaysLine($"Time Elapsed: {elapsedTime.Hours:00}:{elapsedTime.Minutes:00}:{elapsedTime.Seconds:00}:{elapsedTime.Milliseconds / 10:00}");
        }
Example #7
0
        private static async Task ExecuteDeployAsync(OutputContext output, ApplicationBuilder application, string environment, bool interactive, bool force)
        {
            if (!await KubectlDetector.Instance.IsKubectlInstalled.Value)
            {
                throw new CommandException($"Cannot apply manifests because kubectl is not installed.");
            }

            if (!await KubectlDetector.Instance.IsKubectlConnectedToCluster.Value)
            {
                throw new CommandException($"Cannot apply manifests because kubectl is not connected to a cluster.");
            }

            await application.ProcessExtensionsAsync(output, ExtensionContext.OperationKind.Deploy);

            ApplyRegistry(output, application, interactive, requireRegistry: true);

            var executor = new ApplicationExecutor(output)
            {
                ServiceSteps =
                {
                    new ApplyContainerDefaultsStep(),
                    new CombineStep()
                    {
                        Environment = environment,
                    },
                    new PublishProjectStep(),
                    new BuildDockerImageStep()
                    {
                        Environment = environment,
                    },
                    new PushDockerImageStep()
                    {
                        Environment = environment,
                    },
                    new ValidateSecretStep()
                    {
                        Environment = environment,   Interactive= interactive, Force = force,
                    },
                    new GenerateServiceKubernetesManifestStep()
                    {
                        Environment = environment,
                    },
                },

                IngressSteps =
                {
                    new ValidateIngressStep()
                    {
                        Environment = environment, Interactive = interactive, Force = force,
                    },
                    new GenerateIngressKubernetesManifestStep(),
                },

                ApplicationSteps =
                {
                    new DeployApplicationKubernetesManifestStep(),
                }
            };

            await executor.ExecuteAsync(application);
        }