pull/3580/merge
Chad Ostler 8 years ago committed by GitHub
commit 370e9df877
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -27,9 +27,14 @@ import (
"google.golang.org/grpc/keepalive" "google.golang.org/grpc/keepalive"
healthpb "google.golang.org/grpc/health/grpc_health_v1" healthpb "google.golang.org/grpc/health/grpc_health_v1"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/helm/pkg/chartutil" "k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/helm/portforwarder"
"k8s.io/helm/pkg/kube"
"k8s.io/helm/pkg/proto/hapi/chart" "k8s.io/helm/pkg/proto/hapi/chart"
rls "k8s.io/helm/pkg/proto/hapi/services" rls "k8s.io/helm/pkg/proto/hapi/services"
"k8s.io/helm/pkg/tiller/environment"
) )
// maxMsgSize use 20MB as the default message size limit. // maxMsgSize use 20MB as the default message size limit.
@ -41,6 +46,32 @@ type Client struct {
opts options opts options
} }
// TillerHost returns a port forwarded tiller hostname
func TillerHost(namespace, context string) (string, error) {
config, err := rest.InClusterConfig()
if err != nil {
config, err = kube.GetConfig(context).ClientConfig()
}
if err != nil {
return "", fmt.Errorf("could not get Kubernetes config for context %q: %s", context, err)
}
client, err := kubernetes.NewForConfig(config)
if err != nil {
return "", fmt.Errorf("could not get Kubernetes client: %s", err)
}
if namespace == "" {
namespace = environment.DefaultTillerNamespace
}
tunnel, err := portforwarder.New(namespace, client, config)
if err != nil {
return "", err
}
return fmt.Sprintf("127.0.0.1:%d", tunnel.Local), nil
}
// NewClient creates a new client. // NewClient creates a new client.
func NewClient(opts ...Option) *Client { func NewClient(opts ...Option) *Client {
var c Client var c Client

Loading…
Cancel
Save