Skip to content

Commit

Permalink
complete Kubernetes support
Browse files Browse the repository at this point in the history
  • Loading branch information
jaxxstorm committed Oct 31, 2022
1 parent 75728b9 commit 569e68d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
27 changes: 14 additions & 13 deletions cmd/cli/connect/kubernetes/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (
)

var (
name string
tailnet string
apiKey string
routes []string
name string
tailnet string
apiKey string
routes []string
)

func Command() *cobra.Command {
Expand Down Expand Up @@ -44,18 +44,21 @@ func Command() *cobra.Command {
return fmt.Errorf("must specify a tailscale api key. See --help")
}


if name == "" {
name = randomname.Generate()
}

if len(routes) == 0 {
return fmt.Errorf("must specify at least one route. See --help")
}

ctx := context.Background()
program, err := kubernetes.Program(name, ctx, kubernetes.BastionArgs{
Name: name,
Routes: routes,
Tailnet: tailnet,
ApiKey: apiKey,
CreateNamespace: true, // FIXME: should we allow usage of an existing namespace?
Name: name,
Routes: routes,
Tailnet: tailnet,
ApiKey: apiKey,
CreateNamespace: true, // FIXME: should we allow usage of an existing namespace?
})
if err != nil {
return err
Expand Down Expand Up @@ -97,12 +100,10 @@ func Command() *cobra.Command {
command.Flags().StringVar(&apiKey, "api-key", "", "The tailnet api key to use. See: https://login.tailscale.com/admin/settings/keys")
command.Flags().StringSliceVar(&routes, "routes", nil, "The routes to advertise. This is likely the cluster Pod CIDR and Service CIDR.")


viper.BindPFlag("name", command.Flags().Lookup("name"))
viper.BindPFlag("tailnet", command.Flags().Lookup("tailnet"))
viper.BindPFlag("apiKey", command.Flags().Lookup("api-key"))
viper.BindPFlag("route", command.Flags().Lookup("route"))

viper.BindPFlag("routes", command.Flags().Lookup("routes"))

// Bind the env vars to the provider env vars
viper.BindEnv("tailnet", "TAILSCALE_TAILNET")
Expand Down
2 changes: 2 additions & 0 deletions cmd/cli/disconnect/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package disconnect
import (
"github.com/jaxxstorm/connecti/cmd/cli/disconnect/aws"
"github.com/jaxxstorm/connecti/cmd/cli/disconnect/azure"
"github.com/jaxxstorm/connecti/cmd/cli/disconnect/kubernetes"
"github.com/spf13/cobra"
)

Expand All @@ -15,6 +16,7 @@ func Command() *cobra.Command {

command.AddCommand(aws.Command())
command.AddCommand(azure.Command())
command.AddCommand(kubernetes.Command())

return command
}
2 changes: 1 addition & 1 deletion cmd/cli/disconnect/kubernetes/cli.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package azure
package kubernetes

import (
"context"
Expand Down

0 comments on commit 569e68d

Please sign in to comment.