Skip to content

Commit

Permalink
Merge pull request #257 from AmitKumarDas/1184-insecure-conn
Browse files Browse the repository at this point in the history
fixes 1184: allow maya api server to connect to K8s API using kubeconfig or K8s master address
  • Loading branch information
kmova authored Feb 3, 2018
2 parents 44065e9 + 12e1167 commit 3dbccef
Show file tree
Hide file tree
Showing 602 changed files with 140,579 additions and 23,604 deletions.
374 changes: 345 additions & 29 deletions Gopkg.lock

Large diffs are not rendered by default.

37 changes: 6 additions & 31 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,18 @@ required = ["k8s.io/code-generator/cmd/client-gen"]

ignored = ["github.com/aws/aws-sdk-go/aws/credentials/endpointcreds","github.com/emicklei/go-restful/swagger","k8s.io/client-go/pkg/api/v1"]

[[constraint]]
name = "github.com/dustin/go-humanize"

[[constraint]]
name = "github.com/golang/glog"

[[constraint]]
name = "github.com/google/gofuzz"
#[[override]]
# name = "golang.org/x/crypto/ssh/terminal"
# branch = "master"

[[constraint]]
name = "github.com/hashicorp/go-getter"
[[override]]
name = "golang.org/x/sys"
branch = "master"

[[constraint]]
name = "github.com/hashicorp/nomad"
version = "0.5.5"

[[constraint]]
name = "github.com/mitchellh/cli"

[[constraint]]
name = "github.com/mitchellh/colorstring"

[[constraint]]
name = "github.com/onsi/ginkgo"
version = "1.4.0"
Expand All @@ -53,25 +43,10 @@ ignored = ["github.com/aws/aws-sdk-go/aws/credentials/endpointcreds","github.com
name = "github.com/onsi/gomega"
version = "1.2.0"

#[[constraint]]
# name = "github.com/rancher/go-rancher"

[[constraint]]
name = "github.com/ryanuber/columnize"
version = "2.1.0"

[[constraint]]
name = "github.com/spf13/cobra"

[[constraint]]
name = "github.com/spf13/pflag"

[[constraint]]
name = "gopkg.in/inf.v0"

[[constraint]]
name = "gopkg.in/yaml.v2"

[[constraint]]
name = "k8s.io/api"
branch = "release-1.8"
Expand Down
30 changes: 20 additions & 10 deletions orchprovider/k8s/v1/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
k8sApisExtnsBeta1 "k8s.io/api/extensions/v1beta1"

"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
)

// OpenEBSImage represents an OpenEBS container image
Expand Down Expand Up @@ -948,18 +949,29 @@ func (k *k8sUtil) getOEClientSet() (*versioned.Clientset, error) {
return cs, nil
}

func getK8sConfig() (config *rest.Config, err error) {
k8sMaster := v1.K8sMasterENV()
kubeConfig := v1.KubeConfigENV()

if len(k8sMaster) != 0 || len(kubeConfig) != 0 {
// creates the config from k8sMaster or kubeConfig
return clientcmd.BuildConfigFromFlags(k8sMaster, kubeConfig)
}

// creates the in-cluster config making use of the Pod's ENV & secrets
return rest.InClusterConfig()
}

// getInClusterCS is used to initialize and return a new http client capable
// of invoking K8s APIs.
func (k *k8sUtil) getInClusterCS() (*kubernetes.Clientset, error) {

// creates the in-cluster config
config, err := rest.InClusterConfig()
func (k *k8sUtil) getInClusterCS() (clientset *kubernetes.Clientset, err error) {
config, err := getK8sConfig()
if err != nil {
return nil, err
}

// creates the in-cluster clientset
clientset, err := kubernetes.NewForConfig(config)
clientset, err = kubernetes.NewForConfig(config)
if err != nil {
return nil, err
}
Expand All @@ -969,16 +981,14 @@ func (k *k8sUtil) getInClusterCS() (*kubernetes.Clientset, error) {

// getInClusterOECS is used to initialize and return a new http client capable
// of invoking OpenEBS CRD APIs.
func (k *k8sUtil) getInClusterOECS() (*versioned.Clientset, error) {

// creates the in-cluster config
config, err := rest.InClusterConfig()
func (k *k8sUtil) getInClusterOECS() (clientset *versioned.Clientset, err error) {
config, err := getK8sConfig()
if err != nil {
return nil, err
}

// creates the in-cluster OE clientset
clientset, err := versioned.NewForConfig(config)
clientset, err = versioned.NewForConfig(config)
if err != nil {
return nil, err
}
Expand Down
16 changes: 16 additions & 0 deletions types/v1/envs.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ const (

// MonitorImageENVK is the ENV key to fetch the volume monitoring image
MonitorImageENVK ENVKey = "OPENEBS_IO_VOLUME_MONITOR_IMAGE"

// KubeConfigENVK is the ENV key to fetch the kubeconfig
KubeConfigENVK ENVKey = "OPENEBS_IO_KUBE_CONFIG"

// K8sMasterENVK is the ENV key to fetch the K8s Master's Address
K8sMasterENVK ENVKey = "OPENEBS_IO_K8S_MASTER"
)

// ENVKeyToDefaults maps the ENV keys to corresponding default
Expand Down Expand Up @@ -159,6 +165,16 @@ func MonitorENV() string {
return val
}

func KubeConfigENV() string {
val := GetEnv(KubeConfigENVK)
return val
}

func K8sMasterENV() string {
val := GetEnv(K8sMasterENVK)
return val
}

// GetEnv fetches the environment variable value from the machine's
// environment
func GetEnv(envKey ENVKey) string {
Expand Down
11 changes: 11 additions & 0 deletions vendor/github.com/howeyc/gopass/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions vendor/github.com/howeyc/gopass/LICENSE.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3dbccef

Please sign in to comment.