88 "math/rand"
99 "os"
1010 "os/exec"
11- "strconv"
1211 "strings"
1312 "time"
1413
@@ -62,22 +61,25 @@ required binaries:
6261 case "monitoring" :
6362 installMonitoring ()
6463 return
64+ case "buildpacks" :
65+ installKpack ()
6566 case "kubernetes" :
6667 installKubernetes ()
6768 checkCluster ()
6869 return
6970 case "" :
7071 printInstallSteps ()
71- installKubernetes ()
72- checkCluster ()
73- installOLM ()
74- installIngress ()
75- installMetrics ()
76- installCertManager ()
77- installKuberoOperator ()
78- installMonitoring ()
79- installKuberoUi ()
80- writeCLIconfig ()
72+ installKubernetes () // 1
73+ checkCluster () //
74+ installOLM () // 2
75+ installKuberoOperator () // 3
76+ installIngress () // 4
77+ installMetrics () // 5
78+ installCertManager () // 6
79+ installMonitoring () // 7
80+ installKpack () // 8
81+ installKuberoUi () // 9
82+ writeCLIconfig () // 10
8183 printDNSinfo ()
8284 finalMessage ()
8385 return
@@ -103,7 +105,7 @@ var ingressControllerVersion = "v1.10.0" // https://github.com/kubernetes/ingres
103105var clusterTypeList = []string {"kind" , "linode" , "scaleway" , "gke" , "digitalocean" }
104106
105107func init () {
106- installCmd .Flags ().StringVarP (& arg_component , "component" , "c" , "" , "install component (kubernetes,olm,ingress,metrics,certmanager,kubero-operator,monitoring,kubero-ui)" )
108+ installCmd .Flags ().StringVarP (& arg_component , "component" , "c" , "" , "install component (kubernetes,olm,ingress,metrics,certmanager,kubero-operator,monitoring,buildpacks, kubero-ui)" )
107109 installCmd .Flags ().StringVarP (& arg_adminUser , "user" , "u" , "" , "Admin username for the kubero UI" )
108110 installCmd .Flags ().StringVarP (& arg_adminPassword , "user-password" , "U" , "" , "Password for the admin user" )
109111 installCmd .Flags ().StringVarP (& arg_apiToken , "apitoken" , "a" , "" , "API token for the admin user" )
@@ -143,13 +145,14 @@ func printInstallSteps() {
143145 Steps to install kubero:
144146 1. Create a kubernetes cluster {{(optional)}}::gray
145147 2. Install the OLM {{(optional)}}::gray
146- 3. Install the ingress controller {{(required)}}::gray
147- 4. Install the metrics server {{(optional, but recommended )}}::gray
148- 5. Install the cert-manager {{(optional)}}::gray
149- 6. Install the kubero operator {{(required )}}::gray
148+ 3. Install the kubero operator {{(required)}}::gray
149+ 4. Install the ingress controller {{(required )}}::gray
150+ 5. Install the metrics server {{(optional, but recommended )}}::gray
151+ 6. Install the cert-manager {{(optional )}}::gray
150152 7. Install the monitoring stack {{(optional, but recommended)}}::gray
151- 8. Install the kubero UI {{(optional, but highly recommended)}}::gray
152- 9. Write the kubero CLI config
153+ 8. Install the buildpacks for buildpacks.io {{(optional)}}::gray
154+ 9. Install the kubero UI {{(optional, but highly recommended)}}::gray
155+ 10. Write the kubero CLI config
153156` )
154157}
155158
@@ -324,14 +327,37 @@ func installOLM() {
324327 olmWaitCatalogSpinner .Success ("OLM Catalog is ready" )
325328}
326329
330+ func installKpack () {
331+
332+ kpackInstalled , _ := exec .Command ("kubectl" , "get" , "crd" , "builds.kpack.io" ).Output ()
333+ if len (kpackInstalled ) > 0 {
334+ cfmt .Println ("{{✓ Kpack is allredy installed}}::lightGreen" )
335+ return
336+ }
337+
338+ kpackInstall := promptLine ("8) Install Kpack for buildpacks.io" , "[y,n]" , "y" )
339+ if kpackInstall != "y" {
340+ return
341+ }
342+
343+ components := "https://github.com/buildpacks-community/kpack/releases/download/v0.13.3/release-0.13.3.yaml"
344+ _ , installErr := exec .Command ("kubectl" , "apply" , "-f" , components ).Output ()
345+
346+ if installErr != nil {
347+ fmt .Println ("failed to install kpack" )
348+ log .Fatal (installErr )
349+ }
350+ cfmt .Println ("{{✓ Kpack Operator installed}}::lightGreen" )
351+ }
352+
327353func installMetrics () {
328354
329355 installed , _ := exec .Command ("kubectl" , "get" , "deployments.apps" , "metrics-server" , "-n" , "kube-system" ).Output ()
330356 if len (installed ) > 0 {
331357 cfmt .Println ("{{✓ Metrics is allredy enabled}}::lightGreen" )
332358 return
333359 }
334- install := promptLine ("4 ) Install Kubernetes internal metrics service (required for HPA and stats )" , "[y,n]" , "y" )
360+ install := promptLine ("5 ) Install Kubernetes internal metrics service (required for HPA, Horizontal Pod Autoscaling )" , "[y,n]" , "y" )
335361 if install != "y" {
336362 return
337363 }
@@ -355,7 +381,7 @@ func installIngress() {
355381 return
356382 }
357383
358- ingressInstall := promptLine ("3 ) Install Ingress" , "[y,n]" , "y" )
384+ ingressInstall := promptLine ("4 ) Install Ingress" , "[y,n]" , "y" )
359385 if ingressInstall != "y" {
360386 return
361387 } else {
@@ -399,7 +425,7 @@ func installIngress() {
399425
400426func installKuberoOperator () {
401427
402- cfmt .Println ("\n {{6 ) Install Kubero Operator}}::bold" )
428+ cfmt .Println ("\n {{3 ) Install Kubero Operator}}::bold" )
403429
404430 kuberoInstalled , _ := exec .Command ("kubectl" , "get" , "operator" , "kubero-operator.operators" ).Output ()
405431 if len (kuberoInstalled ) > 0 {
@@ -450,14 +476,23 @@ func installKuberoOperatorSlim() {
450476 log .Fatal (kuberoErr )
451477 }
452478
453- kuberoSpinner .UpdateMessage ("Wait for Kubero Operator to be ready " )
479+ kuberoSpinner .UpdateMessage ("Wait for Kubero Operator CRD's to be installed " )
454480 var kuberoWait []byte
455481 for len (kuberoWait ) == 0 {
456482 // kubectl api-resources --api-group=application.kubero.dev --no-headers=true
457483 kuberoWait , _ = exec .Command ("kubectl" , "api-resources" , "--api-group=application.kubero.dev" , "--no-headers=true" ).Output ()
458484 time .Sleep (1 * time .Second )
459485 }
486+ kuberoSpinner .UpdateMessage ("Kubero Operator CRD's installed" )
460487
488+ time .Sleep (5 * time .Second )
489+ // kubectl wait --for=condition=available deployment/kubero -n kubero --timeout=180s
490+ kuberoSpinner .UpdateMessage ("Wait for Kubero Operator to be ready" )
491+ _ , olmWaitErr := exec .Command ("kubectl" , "wait" , "--for=condition=available" , "deployment/kubero-operator-controller-manager" , "-n" , "kubero-operator-system" , "--timeout=300s" ).Output ()
492+ if olmWaitErr != nil {
493+ kuberoSpinner .Error ("Failed to wait for Kubero UI to become ready" )
494+ log .Fatal (olmWaitErr )
495+ }
461496 kuberoSpinner .Success ("Kubero Operator installed sucessfully" )
462497
463498}
@@ -480,7 +515,7 @@ func createNamespace(namespace string) {
480515
481516func installKuberoUi () {
482517
483- ingressInstall := promptLine ("7 ) Install Kubero UI" , "[y,n]" , "y" )
518+ ingressInstall := promptLine ("9 ) Install Kubero UI" , "[y,n]" , "y" )
484519 if ingressInstall != "y" {
485520 return
486521 }
@@ -626,20 +661,26 @@ func installKuberoUi() {
626661 kuberoUIConfig .Spec .Registry .Enabled = true
627662
628663 kuberoUICreateRegistry := promptLine ("Create a local Registry for Kubero" , "[y/n]" , "n" )
629-
630664 if kuberoUICreateRegistry == "y" {
631665 kuberoUIConfig .Spec .Registry .Create = true
632- kuberoUIConfig .Spec .Registry .Host = "registry.local.kubero.net" // registry.local.kubero.net points to localhost 127.0.0.1
633- kuberoUIConfig .Spec .Registry .Port = 80
634- } else {
635666
636- kuberoUIRegistryPort := promptLine ("Registry port" , "" , "443" )
637- kuberoUIConfig .Spec .Registry .Port , _ = strconv .Atoi (kuberoUIRegistryPort )
667+ kuberoUIRegistryStorage := promptLine ("Registry storage size" , "" , "10Gi" )
668+ kuberoUIConfig .Spec .Registry .Storage = kuberoUIRegistryStorage
669+
670+ storageClassList := getAvailableStorageClasses ()
638671
639- kuberoUIRegistryHost := promptLine ("Registry domain " , "" , "registry.yourdomain.com " )
640- kuberoUIConfig .Spec .Registry .Host = kuberoUIRegistryHost
672+ kuberoUIRegistryStorageClassName := selectFromList ("Registry storage class " , storageClassList , "" )
673+ kuberoUIConfig .Spec .Registry .StorageClassName = kuberoUIRegistryStorageClassName
641674 }
642675
676+ kuberoUIRegistryHost := promptLine ("Registry" , "[registry.kubero.mydomain.com]" , "" )
677+ kuberoUIConfig .Spec .Registry .Host = kuberoUIRegistryHost
678+
679+ kuberoUIRegistrySubpath := promptLine ("Subpath (optional) " , "[example/foo/bar]" , "" )
680+ kuberoUIConfig .Spec .Registry .Subpath = kuberoUIRegistrySubpath
681+
682+ kuberoUIConfig .Spec .Registry .Port = 443
683+
643684 kuberoUIRegistryUsername := promptLine ("Registry username" , "" , "admin" )
644685 kuberoUIConfig .Spec .Registry .Account .Username = kuberoUIRegistryUsername
645686
@@ -648,14 +689,6 @@ func installKuberoUi() {
648689
649690 kuberoUIRegistryPasswordBytes , _ := bcrypt .GenerateFromPassword ([]byte (kuberoUIRegistryPassword ), 14 )
650691 kuberoUIConfig .Spec .Registry .Account .Hash = string (kuberoUIRegistryPasswordBytes )
651-
652- kuberoUIRegistryStorage := promptLine ("Registry storage size" , "" , "10Gi" )
653- kuberoUIConfig .Spec .Registry .Storage = kuberoUIRegistryStorage
654-
655- storageClassList := getAvailableStorageClasses ()
656-
657- kuberoUIRegistryStorageClassName := selectFromList ("Registry storage class" , storageClassList , "" )
658- kuberoUIConfig .Spec .Registry .StorageClassName = kuberoUIRegistryStorageClassName
659692 }
660693
661694 kuberoUIAudit := promptLine ("Enable Audit Logging" , "[y/n]" , "n" )
@@ -730,7 +763,7 @@ func installKuberoUi() {
730763
731764 time .Sleep (5 * time .Second )
732765 // kubectl wait --for=condition=available deployment/kubero -n kubero --timeout=180s
733- _ , olmWaitErr := exec .Command ("kubectl" , "wait" , "--for=condition=available" , "deployment/kubero" , "-n" , "kubero" , "--timeout=180s " ).Output ()
766+ _ , olmWaitErr := exec .Command ("kubectl" , "wait" , "--for=condition=available" , "deployment/kubero" , "-n" , "kubero" , "--timeout=300s " ).Output ()
734767 if olmWaitErr != nil {
735768 kuberoUISpinner .Error ("Failed to wait for Kubero UI to become ready" )
736769 log .Fatal (olmWaitErr )
@@ -742,7 +775,7 @@ func installKuberoUi() {
742775
743776func installMonitoring () {
744777
745- if promptLine ("Enable longterm metrics" , "[y/n]" , "y" ) == "y" {
778+ if promptLine ("7) Enable longterm metrics" , "[y/n]" , "y" ) == "y" {
746779 monitoringInstalled = true
747780 } else {
748781 monitoringInstalled = false
@@ -752,29 +785,30 @@ func installMonitoring() {
752785 createNamespace ("kubero" )
753786
754787 spinner := spinner .New ("enable metrics" )
755- if promptLine ("Create local Prometheus instance" , "[y/n]" , "y" ) == "y" {
788+ if promptLine ("7.1) Create local Prometheus instance" , "[y/n]" , "y" ) == "y" {
756789 URL := "https://raw.githubusercontent.com/kubero-dev/kubero-operator/main/config/samples/application_v1alpha1_kuberoprometheus.yaml"
757- cfmt .Println (" run command : kubectl apply -f " + URL )
790+ cfmt .Println (" run command : kubectl apply -n kubero - f " + URL )
758791 spinner .Start ("Installing Prometheus" )
759792 _ , ingressErr := exec .Command ("kubectl" , "apply" , "-n" , "kubero" , "-f" , URL ).Output ()
760793 if ingressErr != nil {
761794 spinner .Error ("Failed to run command. Try runnig this command manually: kubectl apply -f " + URL )
762795 log .Fatal (ingressErr )
763796 }
764-
765- spinner .UpdateMessage ("Waiting for Prometheus to be ready" )
766-
767- time .Sleep (5 * time .Second )
768- // kubectl wait --for=condition=available deployment/kubero -n kubero --timeout=180s
769- _ , olmWaitErr := exec .Command ("kubectl" , "wait" , "--for=condition=available" , "deployment/kubero-prometheus-server" , "-n" , "kubero" , "--timeout=180s" ).Output ()
770- if olmWaitErr != nil {
771- spinner .Error ("Failed to wait for Prometheus to become ready" )
772- log .Fatal (olmWaitErr )
773- }
797+ /*
798+ spinner.UpdateMessage("Waiting for Prometheus to be ready")
799+
800+ time.Sleep(5 * time.Second)
801+ // kubectl wait --for=condition=available deployment/kubero -n kubero --timeout=180s
802+ _, olmWaitErr := exec.Command("kubectl", "wait", "--for=condition=available", "deployment/kubero-prometheus-server", "-n", "kubero", "--timeout=300s").Output()
803+ if olmWaitErr != nil {
804+ spinner.Error("Failed to wait for Prometheus to become ready")
805+ log.Fatal(olmWaitErr)
806+ }
807+ */
774808 spinner .Success ("Prometheus installed sucessfully" )
775809 }
776810
777- if promptLine ("Enable Kubemetrtics" , "[y/n]" , "y" ) == "y" {
811+ if promptLine ("7.2) Enable Kubemetrtics" , "[y/n]" , "y" ) == "y" {
778812 cfmt .Println (" run command : kubectl patch kuberoes kubero -n kubero --type=merge" )
779813 spinner .Start ("Enabling Metrics" )
780814
@@ -865,7 +899,7 @@ func installMonitoring() {
865899
866900func installCertManager () {
867901
868- install := promptLine ("5 ) Install SSL Certmanager" , "[y,n]" , "y" )
902+ install := promptLine ("6 ) Install SSL Certmanager" , "[y,n]" , "y" )
869903 if install != "y" {
870904 return
871905 }
@@ -919,10 +953,10 @@ func installCertManagerClusterissuer(namespace string) {
919953 var certmanagerClusterIssuer CertmanagerClusterIssuer
920954 yaml .Unmarshal (kf .Body (), & certmanagerClusterIssuer )
921955
922- arg_certmanagerContact := promptLine (
"Letsencrypt ACME contact email" ,
"" ,
"[email protected] " )
956+ arg_certmanagerContact := promptLine (
"6.1) Letsencrypt ACME contact email" ,
"" ,
"[email protected] " )
923957 certmanagerClusterIssuer .Spec .Acme .Email = arg_certmanagerContact
924958
925- clusterissuer := promptLine ("Clusterissuer Name" , "" , "letsencrypt-prod" )
959+ clusterissuer := promptLine ("6.2) Clusterissuer Name" , "" , "letsencrypt-prod" )
926960 certmanagerClusterIssuer .Metadata .Name = clusterissuer
927961
928962 certmanagerClusterIssuerYaml , _ := yaml .Marshal (certmanagerClusterIssuer )
@@ -984,7 +1018,7 @@ func installOLMCertManager() {
9841018
9851019func writeCLIconfig () {
9861020
987- ingressInstall := promptLine ("8 ) Write the Kubero CLI config" , "[y,n]" , "n" )
1021+ ingressInstall := promptLine ("10 ) Write the Kubero CLI config" , "[y,n]" , "n" )
9881022 if ingressInstall != "y" {
9891023 return
9901024 }
@@ -1042,16 +1076,19 @@ func finalMessage() {
10421076 https://docs.kubero.dev
10431077 ` )
10441078
1045- if arg_domain != "" && arg_port != "" && arg_apiToken != "" && arg_adminPassword != "" {
1046- cfmt .Println (`
1079+ protocol := "https"
1080+ if arg_port == "80" {
1081+ protocol = "http"
1082+ }
1083+ cfmt .Println (`
10471084 Your Kubero UI :{{
1048- URL : ` + arg_domain + `:` + arg_port + `
1085+ URL : ` + protocol + "://" + arg_domain + ":" + arg_port + `
10491086 User: ` + arg_adminUser + `
10501087 Pass: ` + arg_adminPassword + `}}::lightBlue
10511088 ` )
1052- } else {
1053- cfmt .Println ("\n \n {{Done - you can now login to your Kubero UI}}::lightGreen\n \n " )
1054- }
1089+
1090+ cfmt .Println ("\n \n {{Done - you can now login to your Kubero UI}}::lightGreen\n \n " )
1091+
10551092}
10561093
10571094func generateRandomString (length int , chars string ) string {
0 commit comments