protected void UpdateDeployment(KubernetesExtensionPackage package)
        {
            Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
            _package = package;

            var appName     = MakeDeploymentName(_package.GetCurrentProject().Name);
            var projectDir  = Path.GetDirectoryName(package.GetCurrentProject().FullName);
            var yamlDir     = $"{projectDir}\\{_package.GetKubeOptions().KubeDir}";
            var knamespace  = GetNameSpaceFromYaml();
            var kubeCommand = $"set image deployment {appName} {appName}-pod={_package.GetKubeOptions().DockerHubAccount}/{appName}:latest --namespace {knamespace}";

            Utils.RunProcess("kubectl.exe", kubeCommand, yamlDir, true, Process_OutputDataReceived, Process_ErrorDataReceived);
            kubeCommand = $"set image deployment {appName} {appName}-pod={_package.GetKubeOptions().DockerHubAccount}/{appName} --namespace {knamespace}";
            Utils.RunProcess("kubectl.exe", kubeCommand, yamlDir, false, Process_OutputDataReceived, Process_ErrorDataReceived);
        }
        public bool HasDeploymentConfiguration(KubernetesExtensionPackage package)
        {
            Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
            _package = package;

            var item = GetProjectItem(_package.GetCurrentProject().ProjectItems, _package.GetKubeOptions().KubeDir);

            return(item != null && VSConstants.GUID_ItemType_PhysicalFolder == new Guid(item.Kind));
        }
        public void BuildAndDeployToCluster(KubernetesExtensionPackage package)
        {
            Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
            _package = package;
            var appName    = MakeDeploymentName(package.GetCurrentProject().Name);
            var projectDir = Path.GetDirectoryName(package.GetCurrentProject().FullName);

            BuildDockerandPublishDockerImage(appName, projectDir, _package.GetKubeOptions().KubeDir);
        }
        public void RemoveDeploymentFiles(KubernetesExtensionPackage package)
        {
            Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
            _package = package;
            var project    = package.GetCurrentProject();
            var projectDir = Path.GetDirectoryName(project.FullName);
            var item       = GetProjectItem(project.ProjectItems, _package.GetKubeOptions().KubeDir);

            item.Delete();
        }
        protected void DeployAllToCluster(KubernetesExtensionPackage package)
        {
            Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
            _package = package;
            var projectDir  = Path.GetDirectoryName(package.GetCurrentProject().FullName);
            var yamlDir     = $"{projectDir}\\{_package.GetKubeOptions().KubeDir}";
            var kubeCommand = "apply -f deployment.yaml";

            Utils.RunProcess("kubectl.exe", kubeCommand, yamlDir, false, Process_OutputDataReceived, Process_ErrorDataReceived);
        }
        public void CheckDeploymentStatus(KubernetesExtensionPackage package)
        {
            Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
            _package = package;

            var appName     = MakeDeploymentName(_package.GetCurrentProject().Name);
            var projectDir  = Path.GetDirectoryName(package.GetCurrentProject().FullName);
            var yamlDir     = $"{projectDir}\\{_package.GetKubeOptions().KubeDir}";
            var knamespace  = GetNameSpaceFromYaml();
            var kubeCommand = $"rollout status deploy/{appName} --namespace {knamespace}";

            Utils.RunProcess("kubectl.exe", kubeCommand, yamlDir, false, Process_OutputDataReceived, Process_ErrorDataReceived);
        }
Exemple #7
0
        protected string GetNameSpaceFromYaml()
        {
            var retval = string.Empty;

            var projectDir = Path.GetDirectoryName(_package.GetCurrentProject().FullName);
            var filename   = $"{projectDir}\\{_package.GetKubeOptions().KubeDir}\\deployment.yaml";

            GetValueFromFile file = new GetValueFromFile();

            retval = file.GetValue(filename, "namespace");

            return(retval);
        }
        public void CreateDeploymentFiles(KubernetesExtensionPackage package)
        {
            Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
            _package = package;
            var projectDir = Path.GetDirectoryName(package.GetCurrentProject().FullName);

            Directory.CreateDirectory($"{projectDir}\\{_package.GetKubeOptions().KubeDir}");

            string deployYaml = GetKubeYamlText(_package.GetKubeOptions().AddConfig);
            string configYaml = GetSettingsForScript();

            deployYaml = deployYaml.Replace("NAMEGOESHERE", MakeDeploymentName(package.GetCurrentProject().Name));
            deployYaml = deployYaml.Replace("NAMESPACEGOESHERE", _package.GetKubeOptions().KubernetesNamespace);

            configYaml = configYaml.Replace("NAMEGOESHERE", MakeDeploymentName(package.GetCurrentProject().Name));
            configYaml = configYaml.Replace("NAMESPACEGOESHERE", _package.GetKubeOptions().KubernetesNamespace);

            File.WriteAllText($"{projectDir}\\{_package.GetKubeOptions().KubeDir}\\deployment.yaml", deployYaml);
            File.WriteAllText($"{projectDir}\\{_package.GetKubeOptions().KubeDir}\\createconfigs.ps1", configYaml);
            File.WriteAllText($"{projectDir}\\{_package.GetKubeOptions().KubeDir}\\deploy.ps1", GetPowerShellDeployScript());
            File.WriteAllText($"{projectDir}\\{_package.GetKubeOptions().KubeDir}\\createnamespace.ps1", GetNamespaceScript());
            package.GetCurrentProject().ProjectItems.AddFolder($"{projectDir}\\{_package.GetKubeOptions().KubeDir}");
        }