Exemple #1
0
        public void InstallCertificates(InstallerProcess installerProcess)
        {
            this.logger.LogInformation("Validate if you trust all needed helm repos");
            var urls = new List <string>();

            urls.Add("kubernetes-charts.storage.googleapis.com");
            urls.Add("charts.jetstack.io");
            urls.Add("releases.rancher.com");
            foreach (var url in urls)
            {
                this.logger.LogDebug($"Validate {url}");

                // check
                if (!this.SSLTrust(url))
                {
                    this.logger.LogInformation($"It looks you do not trust {url}.");
                    if (this.consoleService.AskFormConfirmation("Should we try to fix this?", "y"))
                    {
                        File.WriteAllText("install.sh",
                                          $"openssl s_client -showcerts -verify 5 -connect " + url +
                                          ":443 < /dev/null | awk '/BEGIN/,/END/{ if(/BEGIN/){a++}; out=\"cert\"a\".crt\"; print >out}' && for cert in *.crt; do newname=$(openssl x509 -noout -subject -in $cert | sed -n 's/^.*CN=\\(.*\\)$/\\1/; s/[ ,.*]/_/g; s/__/_/g; s/^_//g;p').crt; mv $cert /usr/local/share/ca-certificates/$newname; done && update-ca-certificates");
                        this.processHelper.Run("bash", "install.sh");
                    }
                }
            }
        }
Exemple #2
0
 public void CheckKubeCtl(InstallerProcess installerProcess)
 {
     try
     {
         try
         {
             var hostAddress = Dns.GetHostEntry("host.docker.internal").AddressList.First().ToString();
             this.logger.LogInformation("Running inside Docker");
             this.logger.LogDebug($"Add {hostAddress} {this.options.Dns} to host");
             File.AppendAllText("/etc/hosts", $"{hostAddress} {this.options.Dns}{Environment.NewLine}");
         }
         catch
         {
             installerProcess.InsideDocker = false;
             this.logger.LogInformation("Running outside Docker");
         }
         var currentCluster = this.processHelper.Read("kubectl", "get nodes").Split(Environment.NewLine)[1];
         this.logger.LogInformation($"The following cluster will be used to install starterkit: {currentCluster}");
     }
     catch
     {
         installerProcess.InsideDocker = true;
         this.logger.LogError("Kube folder is not mapped. Please start this container with:");
         this.logger.LogError("-v $HOME/.kube:/root/.kube");
         throw;
     }
 }
Exemple #3
0
 public void Dispose()
 {
     if (!IsDisposed)
     {
         if (WebResponse != null)
         {
             WebResponse.Close();
             WebResponse = null;
         }
         if (ResponseStream != null)
         {
             ResponseStream.Dispose();
             ResponseStream = null;
         }
         Buffer = null;
         if (InstallerFileStream != null)
         {
             InstallerFileStream.Dispose();
             InstallerFileStream = null;
         }
         if (InstallerProcess != null)
         {
             InstallerProcess.Dispose();
         }
         if (_waitHandle != null)
         {
             _waitHandle.Set();
             _waitHandle = null;
         }
         IsDisposed = true;
     }
 }
Exemple #4
0
        public void InstallStarterkitCommon(InstallerProcess installerProcess)
        {
            this.logger.LogInformation("Install Starterkit Commons");

            this.kubernetesHelper.CreateNameSpace("starterkit");
            // this.processHelper.Run("kubectl", "apply -f ./../components/common/cert.yaml");
            installerProcess.AddExecutedTask("InstallStarterkitCommon");
        }
Exemple #5
0
        public void InstallStorage(InstallerProcess installerProcess)
        {
            this.logger.LogInformation("Install Storage");
            if (!installerProcess.ExecutedActions.Contains("InstallStarterkitCommon"))
            {
                InstallStarterkitCommon(installerProcess);
            }

            // this.KubernetesHelper.InstallResourceIfNotExists("longhorn-system", "namespace");
            // this.KubernetesHelper.InstallApplicationeIfNotExists(
            //     "longhorn",
            //     "",
            //     "longhorn-system",
            //     $"./../components/longhorn --set ingress.host=storage.{this.options.Dns}",
            //     "deployment.apps/longhorn-driver-deployer",
            //     "deployment.apps/longhorn-ui"
            //     );
        }
Exemple #6
0
        public void InstallRancher(InstallerProcess installerProcess)
        {
            this.InstallIngress();
            this.InstallCertManager();
            this.InstallRancher();

            ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, errors) => true;

            this.WaitUntilIsUpAndReady();
            this.Login();
            this.ChangePassword();
            this.SetServerUrl();
            this.WaitUntilRancherIsActive();
            this.ExecuteUpdatesForDockerDesktop();
            installerProcess.AddExecutedTask("InstallRancher");

            ServicePointManager.ServerCertificateValidationCallback = null;
        }
Exemple #7
0
 public void OnInstallerProcessExited(object sender, EventArgs e)
 {
     InstallerExitCode = InstallerProcess.ExitCode;
     InstallerProcess.Dispose();
     InstallerProcess = null;
     Monitor?.Report(new OperationProgress("Completed.")
     {
         IsCompleted = true
     });
     try
     {
         File.Delete(InstallerFileName);
     }
     catch
     {
     }
     Dispose();
 }
Exemple #8
0
        public void InstallJenkins(InstallerProcess installerProcess)
        {
            this.logger.LogInformation("Install Jenkins");
            if (!installerProcess.ExecutedActions.Contains("InstallStarterkitCommon"))
            {
                InstallStarterkitCommon(installerProcess);
            }

            this.kubernetesHelper.InstallResourceIfNotExists(
                "starterkit",
                "configmap",
                "starterkit",
                "--from-file=./../components/jenkins/config");
            this.kubernetesHelper.InstallApplicationeIfNotExists(
                "jenkins",
                "stable/jenkins",
                "starterkit",
                $"-f ./../components/jenkins/values.yaml",
                "deploy/jenkins");

            installerProcess.AddExecutedTask("InstallJenkins");
        }
Exemple #9
0
        public void InstallLdap(InstallerProcess installerProcess)
        {
            this.logger.LogInformation("Install LDAP");
            if (!installerProcess.ExecutedActions.Contains("InstallStarterkitCommon"))
            {
                InstallStarterkitCommon(installerProcess);
            }

            this.kubernetesHelper.InstallApplicationeIfNotExists(
                "ldap",
                "stable/openldap",
                "starterkit",
                $"-f ./../components/openldap/values.yaml --set adminPassword=admin --set configPassword=admin",
                "deploy/ldap-openldap");
            this.kubernetesHelper.InstallApplicationeIfNotExists(
                "ldap-ui",
                "",
                "starterkit",
                $"./../components/openldapui",
                "deploy/ldap-ui-openldapui");
            installerProcess.AddExecutedTask("InstallLdap");
        }
Exemple #10
0
        public void ShowInfo(InstallerProcess installerProcess)
        {
            this.logger.LogInformation("StarterKit installation is done");

            if (installerProcess.ExecutedActions.Contains("InstallRancher"))
            {
                this.logger.LogInformation($"RancherUi: https://{this.options.Dns}");
                this.logger.LogInformation($"Credentials: admin:admin");
            }

            if (installerProcess.ExecutedActions.Contains("InstallLdap"))
            {
                this.logger.LogInformation($"UserManagement: https://ldap.{this.options.Dns}");
                this.logger.LogInformation($"Credentials: cn=admin,dc=starterkit,dc=home:admin");
            }

            if (installerProcess.ExecutedActions.Contains("InstallJenkins"))
            {
                this.logger.LogInformation($"Jenkins: https://jenkins.{this.options.Dns}");
                this.logger.LogInformation($"Credentials: devops:devops");
            }
        }
Exemple #11
0
        public void CheckHelm(InstallerProcess installerProcess)
        {
            if (!this.processHelper.Read("helm", "repo list", throwOnError: false).Contains("stable"))
            {
                this.processHelper.Run("helm", "repo add stable https://kubernetes-charts.storage.googleapis.com/");
            }

            if (!this.processHelper.Read("helm", "repo list", throwOnError: false).Contains("rancher-latest"))
            {
                this.processHelper.Run("helm", "repo add rancher-latest https://releases.rancher.com/server-charts/latest");
            }

            if (!this.processHelper.Read("helm", "repo list", throwOnError: false).Contains("ingress-nginx"))
            {
                this.processHelper.Run("helm", "repo add ingress-nginx https://kubernetes.github.io/ingress-nginx");
            }

            if (!this.processHelper.Read("helm", "repo list", throwOnError: false).Contains("jetstack"))
            {
                this.processHelper.Run("helm", "repo add jetstack https://charts.jetstack.io");
            }

            this.processHelper.Run("helm", "repo update");
        }