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 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 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 DeploymentV1 GetDeploymentInfo(KubernetesExtensionPackage package) { Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread(); _package = package; KuberntesConnection kubeConnection = new KuberntesConnection(); var deployments = kubeConnection.GetAllDeployments(); var appName = MakeDeploymentName(_package.GetCurrentProject().Name); return(deployments.Items.Where(exp => exp.Metadata.Name.ToUpper() == appName.ToUpper()).FirstOrDefault()); }
public void ScaleDeployment(KubernetesExtensionPackage package, int numberOfReplicas) { Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread(); _package = package; string kNameSpace = GetNameSpaceFromYaml(); string deploymentName = MakeDeploymentName(package.GetCurrentProject().Name); KuberntesConnection kubernetesConnection = new KuberntesConnection(); kubernetesConnection.ScaleDeployment(deploymentName, numberOfReplicas, kNameSpace); }
public bool HasDeploymnet(KubernetesExtensionPackage package) { Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread(); _package = package; bool retval = false; KuberntesConnection kubeConnection = new KuberntesConnection(); var appName = MakeDeploymentName(_package.GetCurrentProject().Name); var deployments = kubeConnection.GetAllDeployments(); retval = deployments.Items.Any(exp => exp.Metadata.Name.ToUpper() == appName.ToUpper()); return(retval); }
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); }
public async void DeployToCluster(KubernetesExtensionPackage package) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); _package = package; if (!HasDeploymnet(_package)) { DeployAllToCluster(_package); } else { UpdateDeployment(_package); } }
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 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}"); }