From 24000c1129e40de3cc1e0369cd09677e81e80029 Mon Sep 17 00:00:00 2001 From: Adrian Liechti Date: Sun, 18 Sep 2022 11:25:43 +0200 Subject: [PATCH 1/2] use filepath instead path --- app/cluster/cluster_create.go | 4 ++-- app/flag_cluster.go | 4 ++-- provider/azure/azure.go | 6 +++--- provider/digitalocean/digitalocean.go | 6 +++--- provider/linode/linode.go | 6 +++--- provider/vultr/vultr.go | 6 +++--- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/cluster/cluster_create.go b/app/cluster/cluster_create.go index eb0700b..72fdeff 100644 --- a/app/cluster/cluster_create.go +++ b/app/cluster/cluster_create.go @@ -2,7 +2,7 @@ package cluster import ( "os" - "path" + "path/filepath" "github.com/adrianliechti/devkube/app" "github.com/adrianliechti/devkube/pkg/cli" @@ -54,7 +54,7 @@ func CreateCommand() *cli.Command { defer os.RemoveAll(dir) - kubeconfig := path.Join(dir, "kubeconfig") + kubeconfig := filepath.Join(dir, "kubeconfig") if err := provider.Create(c.Context, cluster, kubeconfig); err != nil { return err diff --git a/app/flag_cluster.go b/app/flag_cluster.go index 66358e2..c2918c7 100644 --- a/app/flag_cluster.go +++ b/app/flag_cluster.go @@ -3,7 +3,7 @@ package app import ( "errors" "os" - "path" + "path/filepath" "strings" "github.com/adrianliechti/devkube/pkg/cli" @@ -150,7 +150,7 @@ func MustClusterKubeconfig(c *cli.Context, provider provider.Provider, name stri os.RemoveAll(dir) } - path := path.Join(dir, "kubeconfig") + path := filepath.Join(dir, "kubeconfig") if err := provider.Export(c.Context, name, path); err != nil { closer() diff --git a/provider/azure/azure.go b/provider/azure/azure.go index afc1a88..c385740 100644 --- a/provider/azure/azure.go +++ b/provider/azure/azure.go @@ -4,7 +4,7 @@ import ( "context" "errors" "os" - "path" + "path/filepath" "strings" "github.com/adrianliechti/devkube/pkg/to" @@ -200,13 +200,13 @@ func (p *Provider) Export(ctx context.Context, name, kubeconfig string) error { return err } - dir := path.Join(home, ".kube") + dir := filepath.Join(home, ".kube") if err := os.MkdirAll(dir, 0700); err != nil { return err } - kubeconfig = path.Join(home, ".kube", "config") + kubeconfig = filepath.Join(home, ".kube", "config") } resourcegroup := groupName(name) diff --git a/provider/digitalocean/digitalocean.go b/provider/digitalocean/digitalocean.go index 5a65efc..86193d5 100644 --- a/provider/digitalocean/digitalocean.go +++ b/provider/digitalocean/digitalocean.go @@ -5,7 +5,7 @@ import ( "errors" "fmt" "os" - "path" + "path/filepath" "strings" "time" @@ -150,13 +150,13 @@ func (p *Provider) Export(ctx context.Context, name, kubeconfig string) error { return err } - dir := path.Join(home, ".kube") + dir := filepath.Join(home, ".kube") if err := os.MkdirAll(dir, 0700); err != nil { return err } - kubeconfig = path.Join(home, ".kube", "config") + kubeconfig = filepath.Join(home, ".kube", "config") } id, err := p.clusterID(ctx, name) diff --git a/provider/linode/linode.go b/provider/linode/linode.go index 95c071a..48f63fd 100644 --- a/provider/linode/linode.go +++ b/provider/linode/linode.go @@ -7,7 +7,7 @@ import ( "fmt" "net/http" "os" - "path" + "path/filepath" "strings" "github.com/linode/linodego" @@ -158,13 +158,13 @@ func writeKubeconfig(kubeconfig string, config *linodego.LKEClusterKubeconfig) e return err } - dir := path.Join(home, ".kube") + dir := filepath.Join(home, ".kube") if err := os.MkdirAll(dir, 0700); err != nil { return err } - kubeconfig = path.Join(home, ".kube", "config") + kubeconfig = filepath.Join(home, ".kube", "config") } data, err := base64.StdEncoding.DecodeString(config.KubeConfig) diff --git a/provider/vultr/vultr.go b/provider/vultr/vultr.go index aefc96c..475194c 100644 --- a/provider/vultr/vultr.go +++ b/provider/vultr/vultr.go @@ -7,7 +7,7 @@ import ( "fmt" "net/http" "os" - "path" + "path/filepath" "strings" "time" @@ -171,13 +171,13 @@ func writeKubeconfig(kubeconfig string, config *govultr.KubeConfig) error { return err } - dir := path.Join(home, ".kube") + dir := filepath.Join(home, ".kube") if err := os.MkdirAll(dir, 0700); err != nil { return err } - kubeconfig = path.Join(home, ".kube", "config") + kubeconfig = filepath.Join(home, ".kube", "config") } data, err := base64.StdEncoding.DecodeString(config.KubeConfig) From 75e781093dd4b5bf3d6502382886689a59f19c60 Mon Sep 17 00:00:00 2001 From: Adrian Liechti Date: Sun, 18 Sep 2022 15:35:03 +0200 Subject: [PATCH 2/2] use local ca issuer --- app/cluster/cluster_create.go | 2 ++ extension/certmanager/certmanager.go | 24 ++++++++++-------------- extension/certmanager/manifest.yaml | 6 +++--- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/app/cluster/cluster_create.go b/app/cluster/cluster_create.go index 72fdeff..c74921f 100644 --- a/app/cluster/cluster_create.go +++ b/app/cluster/cluster_create.go @@ -60,6 +60,8 @@ func CreateCommand() *cli.Command { return err } + kubectl.Invoke(c.Context, []string{"create", "namespace", DefaultNamespace}, kubectl.WithKubeconfig(kubeconfig)) + if err := observability.InstallCRD(c.Context, kubeconfig, DefaultNamespace); err != nil { return err } diff --git a/extension/certmanager/certmanager.go b/extension/certmanager/certmanager.go index b4930a4..368b11a 100644 --- a/extension/certmanager/certmanager.go +++ b/extension/certmanager/certmanager.go @@ -14,8 +14,8 @@ import ( ) const ( - certmanagerRepo = "https://charts.jetstack.io" - certmanagerNamespace1 = "cert-manager" + certmanagerRepo = "https://charts.jetstack.io" + certmanagerNamespace = "cert-manager" certmanager = "cert-manager" certmanagerChart = "cert-manager" @@ -28,11 +28,9 @@ var ( ) func Install(ctx context.Context, kubeconfig, namespace string) error { - // if namespace == "" { - // namespace = "default" - // } - - namespace = certmanagerNamespace1 + if namespace == "" { + namespace = "default" + } client, err := kubernetes.NewFromConfig(kubeconfig) @@ -63,7 +61,7 @@ func Install(ctx context.Context, kubeconfig, namespace string) error { } } - if err := helm.Install(ctx, certmanager, certmanagerRepo, certmanagerChart, certmanagerVersion, values, helm.WithKubeconfig(kubeconfig), helm.WithNamespace(namespace), helm.WithWait(true), helm.WithDefaultOutput()); err != nil { + if err := helm.Install(ctx, certmanager, certmanagerRepo, certmanagerChart, certmanagerVersion, values, helm.WithKubeconfig(kubeconfig), helm.WithNamespace(certmanagerNamespace), helm.WithWait(true), helm.WithDefaultOutput()); err != nil { return err } @@ -75,17 +73,15 @@ func Install(ctx context.Context, kubeconfig, namespace string) error { } func Uninstall(ctx context.Context, kubeconfig, namespace string) error { - // if namespace == "" { - // namespace = "default" - // } - - namespace = certmanagerNamespace1 + if namespace == "" { + namespace = "default" + } if err := kubectl.Invoke(ctx, []string{"delete", "-f", "-"}, kubectl.WithKubeconfig(kubeconfig), kubectl.WithNamespace(namespace), kubectl.WithInput(strings.NewReader(manifest)), kubectl.WithDefaultOutput()); err != nil { // return err } - if err := helm.Uninstall(ctx, certmanager, helm.WithKubeconfig(kubeconfig), helm.WithNamespace(namespace)); err != nil { + if err := helm.Uninstall(ctx, certmanager, helm.WithKubeconfig(kubeconfig), helm.WithNamespace(certmanagerNamespace)); err != nil { //return err } diff --git a/extension/certmanager/manifest.yaml b/extension/certmanager/manifest.yaml index 4b26d99..2084f9a 100644 --- a/extension/certmanager/manifest.yaml +++ b/extension/certmanager/manifest.yaml @@ -1,12 +1,12 @@ apiVersion: cert-manager.io/v1 -kind: ClusterIssuer +kind: Issuer metadata: name: selfsigned spec: selfSigned: {} --- apiVersion: cert-manager.io/v1 -kind: ClusterIssuer +kind: Issuer metadata: name: platform spec: @@ -27,7 +27,7 @@ spec: size: 256 issuerRef: name: selfsigned - kind: ClusterIssuer + kind: Issuer group: cert-manager.io --- apiVersion: apps/v1