Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into feat-restore-certs
Browse files Browse the repository at this point in the history
  • Loading branch information
pagottoo committed Jul 19, 2022
2 parents 6663f10 + 01cb61a commit 3430cdd
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 37 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ go run . init --admin-email $ADMIN_EMAIL --cloud $CLOUD_PROVIDER --hosted-zone-n
At this point, everything is ready to start provisioning the cloud services, and for that we can run:

```bash
go run . create
go run . cluster create
```

## Access ArgoCD
Expand All @@ -71,11 +71,11 @@ rm ~/.flare
Kubefirst provides extra tooling for handling the provisioning work.

| Command | Description |
|------------|-----------------------------------------------------------|
| argocdSync | Request ArgoCD to synchronize applications |
| checktools | use to check compatibility of .kubefirst/tools |
| clean | removes all kubefirst resources locally for new execution |
| create | create a kubefirst management cluster |
|:------------|:-----------------------------------------------------------|
| argocdSync | Request ArgoCD to synchronize applications |
| checktools | use to check compatibility of .kubefirst/tools |
| clean | removes all kubefirst resources locally for new execution |
| cluster create | create a kubefirst management cluster |
| destroy | destroy the kubefirst management cluster |
| info | provides general Kubefirst setup data |
| init | initialize your local machine to execute `create` |
Expand Down
35 changes: 35 additions & 0 deletions cmd/cluster.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
Copyright © 2022 NAME HERE <EMAIL ADDRESS>
*/
package cmd

import (
"fmt"

"github.com/spf13/cobra"
)

// clusterCmd represents the cluster command
var clusterCmd = &cobra.Command{
Use: "cluster",
Short: "Used to manage cluster level operations",
Long: `Cluster Level operations like create a new cluster provisioned with all kubefirst goodies.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("cluster called")
},
}

func init() {
rootCmd.AddCommand(clusterCmd)

// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// clusterCmd.PersistentFlags().String("foo", "", "A help for foo")

// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// clusterCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}
2 changes: 1 addition & 1 deletion cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ to quickly create a Cobra application.`,
}

func init() {
rootCmd.AddCommand(createCmd)
clusterCmd.AddCommand(createCmd)

// todo: make this an optional switch and check for it or viper
createCmd.Flags().Bool("destroy", false, "destroy resources")
Expand Down
66 changes: 41 additions & 25 deletions cmd/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@ package cmd

import (
"bytes"
"log"
"os"
"os/exec"
"syscall"

"fmt"
"github.com/kubefirst/kubefirst/configs"
"github.com/kubefirst/kubefirst/internal/aws"
"github.com/kubefirst/kubefirst/internal/gitlab"
"github.com/kubefirst/kubefirst/internal/k8s"
"github.com/kubefirst/kubefirst/internal/terraform"
"github.com/spf13/cobra"
"log"
"os/exec"
"syscall"
)

// destroyCmd represents the destroy command
Expand Down Expand Up @@ -45,34 +44,50 @@ if the registry has already been deleted.`,
log.Panic(err)
}

var kPortForwardOutb, kPortForwardErrb bytes.Buffer
kPortForward := exec.Command(config.KubectlClientPath, "--kubeconfig", config.KubeConfigPath, "-n", "gitlab", "port-forward", "svc/gitlab-webservice-default", "8888:8080")
kPortForward.Stdout = os.Stdout
kPortForward.Stderr = os.Stderr
defer kPortForward.Process.Signal(syscall.SIGTERM)
kPortForward.Stdout = &kPortForwardOutb
kPortForward.Stderr = &kPortForwardErrb
defer func() {
_ = kPortForward.Process.Signal(syscall.SIGTERM)
}()
err = kPortForward.Start()
if err != nil {
log.Printf("warning: failed to port-forward to gitlab in main thread %s", err)
log.Printf("Commad Execution STDOUT: %s", kPortForwardOutb.String())
log.Printf("Commad Execution STDERR: %s", kPortForwardErrb.String())

}

if !skipDeleteRegistryApplication {
var kPortForwardArgocdOutb, kPortForwardArgocdErrb bytes.Buffer
kPortForwardArgocd := exec.Command(config.KubectlClientPath, "--kubeconfig", config.KubeConfigPath, "-n", "argocd", "port-forward", "svc/argocd-server", "8080:80")
kPortForwardArgocd.Stdout = &kPortForwardArgocdOutb
kPortForwardArgocd.Stderr = &kPortForwardArgocdErrb
err = kPortForwardArgocd.Start()
defer func() {
_ = kPortForwardArgocd.Process.Signal(syscall.SIGTERM)
}()
if err != nil {
log.Printf("error: failed to port-forward to argocd in main thread %s", err)
log.Printf("Commad Execution STDOUT: %s", kPortForwardArgocdOutb.String())
log.Printf("Commad Execution STDERR: %s", kPortForwardArgocdErrb.String())
}
}

var kPortForwardArgocdOutb, kPortForwardArgocdErrb bytes.Buffer
kPortForwardArgocd := exec.Command(config.KubectlClientPath, "--kubeconfig", config.KubeConfigPath, "-n", "argocd", "port-forward", "svc/argocd-server", "8080:80")
kPortForwardArgocd.Stdout = &kPortForwardArgocdOutb
kPortForwardArgocd.Stderr = &kPortForwardArgocdErrb
err = kPortForwardArgocd.Start()
defer kPortForwardArgocd.Process.Signal(syscall.SIGTERM)
var kPortForwardVaultOutb, kPortForwardVaultErrb bytes.Buffer
kPortForwardVault := exec.Command(config.KubectlClientPath, "--kubeconfig", config.KubeConfigPath, "-n", "vault", "port-forward", "svc/vault", "8200:8200")
kPortForwardVault.Stdout = &kPortForwardVaultOutb
kPortForwardVault.Stderr = &kPortForwardVaultErrb
err = kPortForwardVault.Start()
defer func() {
_ = kPortForwardVault.Process.Signal(syscall.SIGTERM)
}()
if err != nil {
log.Printf("Commad Execution STDOUT: %s", kPortForwardArgocdOutb.String())
log.Printf("Commad Execution STDERR: %s", kPortForwardArgocdErrb.String())
log.Panicf("error: failed to port-forward to argocd in main thread %s", err)
log.Printf("error: failed to port-forward to vault in main thread %s", err)
log.Printf("Commad Execution STDOUT: %s", kPortForwardVaultOutb.String())
log.Printf("Commad Execution STDERR: %s", kPortForwardVaultErrb.String())
}
// kPortForwardVault := exec.Command(config.KubectlClientPath, "--kubeconfig", config.KubeConfigPath, "-n", "vault", "port-forward", "svc/vault", "8200:8200")
// kPortForwardVault.Stdout = os.Stdout
// kPortForwardVault.Stderr = os.Stderr
// err = kPortForwardVault.Start()
// defer kPortForwardVault.Process.Signal(syscall.SIGTERM)
// if err != nil {
// log.Panicf("error: failed to port-forward to vault in main thread %s", err)
// }
log.Println("destroying gitlab terraform")

gitlab.DestroyGitlabTerraform(skipGitlabTerraform)
Expand All @@ -87,6 +102,7 @@ if the registry has already been deleted.`,
log.Println("terraform base destruction complete")
//TODO: move this step to `kubefirst clean` command and empty buckets and delete
aws.DestroyBucketsInUse(destroyBuckets)
fmt.Println("End of execution destroy")
},
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ to quickly create a Cobra application.`,
// todo: this doesn't default to testing the dns check
skipHostedZoneCheck := viper.GetBool("init.hostedzonecheck.enabled")
if !skipHostedZoneCheck {
log.Println("skipping hosted zone check")
} else {
aws.TestHostedZoneLiveness(dryRun, hostedZoneName, hostedZoneId)
} else {
log.Println("skipping hosted zone check")
}
trackers[pkg.TestHostedZoneLiveness].Tracker.Increment(1)

Expand Down
6 changes: 3 additions & 3 deletions internal/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func TestHostedZoneLiveness(dryRun bool, hostedZoneName, hostedZoneId string) {
count := 0
// todo need to exit after n number of minutes and tell them to check ns records
// todo this logic sucks
for count <= 25 {
for count <= 100 {
count++
//tracker.Increment(1)
//log.Println(text.Faint.Sprintf("[INFO] dns test %d of 25", count))
Expand All @@ -190,10 +190,10 @@ func TestHostedZoneLiveness(dryRun bool, hostedZoneName, hostedZoneId string) {
// todo check ip against route53RecordValue in some capacity so we can pivot the value for testing
log.Println(fmt.Sprintf("%s. in TXT record value: %s\n", route53RecordName, ip))
//tracker.MarkAsDone()
count = 26
count = 101
}
}
if count == 25 {
if count == 100 {
//tracker.MarkAsErrored()
//pw.Stop()
log.Panicf("unable to resolve hosted zone dns record. please check your domain registrar")
Expand Down

0 comments on commit 3430cdd

Please sign in to comment.