Commit b1e0c8fc authored by Adam Reese's avatar Adam Reese
Browse files

Merge pull request #759 from adamreese/feat/tunnel2

feat(tunnel): wire in the tunnel setup and teardown
parents d16e7881 f0a15743
main Release add-codeql dependabot/go_modules/github.com/docker/distribution-2.8.2incompatible dependabot/go_modules/github.com/lib/pq-1.10.9 dependabot/go_modules/github.com/rubenv/sql-migrate-1.4.0 dependabot/go_modules/golang.org/x/crypto-0.9.0 dependabot/go_modules/golang.org/x/term-0.8.0 dependabot/go_modules/k8s.io/klog/v2-2.100.1 dev-v2 feat-v3/event-emitter-lua kube-update-test release-2.0 release-2.1 release-2.10 release-2.11 release-2.12 release-2.13 release-2.14 release-2.15 release-2.16 release-2.17 release-2.2 release-2.3 release-2.4 release-2.5 release-2.6 release-2.7 release-2.8 release-2.9 release-3.0 release-3.1 release-3.10 release-3.11 release-3.12 release-3.2 release-3.3 release-3.4 release-3.5 release-3.6 release-3.6.1 release-3.6.2 release-3.7 release-3.8 release-3.9 release-v3.0.0-beta.4 v3.12.0 v3.12.0-rc.1 v3.12.0-dev.1 v3.11.3 v3.11.2 v3.11.1 v3.11.0 v3.11.0-rc.2 v3.11.0-rc.1 v3.10.3 v3.10.2 v3.10.1 v3.10.0 v3.10.0-rc.1 v3.9.4 v3.9.3 v3.9.2 v3.9.1 v3.9.0 v3.9.0-rc.1 v3.8.2 v3.8.1 v3.8.0 v3.8.0-rc.2 v3.8.0-rc.1 v3.7.2 v3.7.1 v3.7.0 v3.7.0-rc.3 v3.7.0-rc.2 v3.7.0-rc.1 v3.6.3 v3.6.2 v3.6.1 v3.6.0 v3.6.0-rc.1 v3.5.4 v3.5.3 v3.5.2 v3.5.1 v3.5.0 v3.5.0-rc.2 v3.5.0-rc.1 v3.4.2 v3.4.1 v3.4.0 v3.4.0-rc.1 v3.3.4 v3.3.3 v3.3.2 v3.3.1 v3.3.0 v3.3.0-rc.2 v3.3.0-rc.1 v3.2.4 v3.2.3 v3.2.2 v3.2.1 v3.2.0 v3.2.0-rc.1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v2.0.0-alpha.3 v2.0.0-alpha.2 v2.0.0-alpha.1
No related merge requests found
Showing with 66 additions and 38 deletions
+66 -38
......@@ -18,12 +18,13 @@ deleting them.
var deleteDryRun bool
var deleteCommand = &cobra.Command{
Use: "delete [flags] RELEASE_NAME",
Aliases: []string{"del"},
SuggestFor: []string{"remove", "rm"},
Short: "Given a release name, delete the release from Kubernetes",
Long: deleteDesc,
RunE: delRelease,
Use: "delete [flags] RELEASE_NAME",
Aliases: []string{"del"},
SuggestFor: []string{"remove", "rm"},
Short: "Given a release name, delete the release from Kubernetes",
Long: deleteDesc,
RunE: delRelease,
PersistentPreRunE: setupConnection,
}
func init() {
......
......@@ -46,10 +46,11 @@ var getOut = ""
var errReleaseRequired = errors.New("release name is required")
var getCommand = &cobra.Command{
Use: "get [flags] RELEASE_NAME",
Short: "Download a named release",
Long: getHelp,
RunE: getCmd,
Use: "get [flags] RELEASE_NAME",
Short: "Download a named release",
Long: getHelp,
RunE: getCmd,
PersistentPreRunE: setupConnection,
}
var getValuesCommand = &cobra.Command{
......
......@@ -35,22 +35,22 @@ It will also set up any necessary local configuration.
Common actions from this point include:
- helm search: search for charts
- helm fetch: download a chart to your local directory to view
- helm install: upload the chart to Kubernetes
- helm list: list releases of charts
- helm search: search for charts
- helm fetch: download a chart to your local directory to view
- helm install: upload the chart to Kubernetes
- helm list: list releases of charts
Environment:
$HELM_HOME Set an alternative location for Helm files. By default, these are stored in ~/.helm
$HELM_HOST Set an alternative Tiller host. The format is host:port (default ":44134").
$HELM_HOME Set an alternative location for Helm files. By default, these are stored in ~/.helm
$HELM_HOST Set an alternative Tiller host. The format is host:port (default ":44134").
`
// RootCommand is the top-level command for Helm.
var RootCommand = &cobra.Command{
Use: "helm",
Short: "The Helm package manager for Kubernetes.",
Long: globalUsage,
PersistentPreRun: bootstrap,
Use: "helm",
Short: "The Helm package manager for Kubernetes.",
Long: globalUsage,
PersistentPostRun: teardown,
}
func init() {
......@@ -59,9 +59,6 @@ func init() {
home = "$HOME/.helm"
}
thost := os.Getenv(hostEnvVar)
if thost == "" {
thost = defaultHost
}
p := RootCommand.PersistentFlags()
p.StringVar(&helmHome, "home", home, "location of your Helm config. Overrides $HELM_HOME.")
p.StringVar(&tillerHost, "host", thost, "address of tiller. Overrides $HELM_HOST.")
......@@ -74,12 +71,32 @@ func main() {
}
}
func bootstrap(c *cobra.Command, args []string) {
func setupConnection(c *cobra.Command, args []string) error {
if tillerHost == "" {
// Should failure fall back to default host?
tunnel, err := newTillerPortForwarder()
if err != nil {
return err
}
tillerHost = fmt.Sprintf(":%d", tunnel.Local)
if flagVerbose {
fmt.Printf("Created tunnel using local port: '%d'\n", tunnel.Local)
}
}
// Set up the gRPC config.
helm.Config.ServAddr = tillerHost
if flagVerbose {
fmt.Printf("Server: %q\n", helm.Config.ServAddr)
}
return nil
}
func teardown(c *cobra.Command, args []string) {
if tunnel != nil {
tunnel.Close()
}
}
func checkArgsLength(expectedNum, actualNum int, requiredArgs ...string) error {
......
......@@ -35,10 +35,11 @@ var (
)
var installCmd = &cobra.Command{
Use: "install [CHART]",
Short: "install a chart archive.",
Long: installDesc,
RunE: runInstall,
Use: "install [CHART]",
Short: "install a chart archive.",
Long: installDesc,
RunE: runInstall,
PersistentPreRunE: setupConnection,
}
func init() {
......
......@@ -37,11 +37,12 @@ flag with the '--offset' flag allows you to page through results.
`
var listCommand = &cobra.Command{
Use: "list [flags] [FILTER]",
Short: "List releases",
Long: listHelp,
RunE: listCmd,
Aliases: []string{"ls"},
Use: "list [flags] [FILTER]",
Short: "List releases",
Long: listHelp,
RunE: listCmd,
Aliases: []string{"ls"},
PersistentPreRunE: setupConnection,
}
var (
......
......@@ -13,10 +13,11 @@ This command shows the status of a named release.
`
var statusCommand = &cobra.Command{
Use: "status [flags] RELEASE_NAME",
Short: "Displays the status of the named release",
Long: statusHelp,
RunE: status,
Use: "status [flags] RELEASE_NAME",
Short: "Displays the status of the named release",
Long: statusHelp,
RunE: status,
PersistentPreRunE: setupConnection,
}
func init() {
......
......@@ -9,12 +9,17 @@ import (
"github.com/kubernetes/helm/pkg/kube"
)
// TODO refactor out this global var
var tunnel *kube.Tunnel
func newTillerPortForwarder() (*kube.Tunnel, error) {
podName, err := getTillerPodName("helm")
if err != nil {
return nil, err
}
return kube.New(nil).ForwardPort("helm", podName, 44134)
// FIXME use a constain that is accessable on init
const tillerPort = 44134
return kube.New(nil).ForwardPort("helm", podName, tillerPort)
}
func getTillerPodName(namespace string) (string, error) {
......@@ -23,6 +28,7 @@ func getTillerPodName(namespace string) (string, error) {
return "", err
}
// TODO use a const for labels
selector := labels.Set{"app": "helm", "name": "tiller"}.AsSelector()
options := api.ListOptions{LabelSelector: selector}
pods, err := client.Pods(namespace).List(options)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment