Skip to content
This repository has been archived by the owner on Jul 16, 2018. It is now read-only.

Commit

Permalink
Merge pull request #253 from jstrachan/changes
Browse files Browse the repository at this point in the history
  • Loading branch information
fusesource-ci committed Oct 22, 2016
2 parents b9798a4 + 14f2e73 commit d65d129
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 39 deletions.
74 changes: 41 additions & 33 deletions cmds/deploy.go
Expand Up @@ -370,6 +370,7 @@ func deploy(f *cmdutil.Factory, d DefaultFabric8Deployment) {
// TODO this can go soon when we migrate to the new jenkins-openshift image?
printAddClusterRoleToUser(oc, f, "cluster-admin", "system:serviceaccount:"+ns+":jenkins")

printAddClusterRoleToUser(oc, f, "cluster-admin", "system:serviceaccount:"+ns+":configmapcontroller")
printAddClusterRoleToUser(oc, f, "cluster-admin", "system:serviceaccount:"+ns+":exposecontroller")
/*
printAddClusterRoleToUser(oc, f, "cluster-reader", "system:serviceaccount:"+ns+":metrics")
Expand Down Expand Up @@ -399,6 +400,8 @@ func deploy(f *cmdutil.Factory, d DefaultFabric8Deployment) {
format := "yaml"
createTemplate(yamlData, format, packageName, ns, domain, apiserver, c, oc, pv)

updateExposeControllerConfig(c, ns, apiserver, domain, mini, d.useLoadbalancer)

createMissingPVs(c, ns)
} else {
consoleVersion := f8ConsoleVersion(mavenRepo, d.versionConsole, typeOfMaster)
Expand Down Expand Up @@ -524,6 +527,8 @@ func deploy(f *cmdutil.Factory, d DefaultFabric8Deployment) {
printError("Ignoring the deploy of templates", nil)
}

runTemplate(c, oc, "exposecontroller", ns, domain, apiserver, pv)

externalNodeName := ""
if typeOfMaster == util.Kubernetes {
if !mini && d.useIngress {
Expand All @@ -533,39 +538,7 @@ func deploy(f *cmdutil.Factory, d DefaultFabric8Deployment) {
}
}

// create a populate the exposecontroller config map
cfgms := c.ConfigMaps(ns)

_, err := cfgms.Get(exposecontrollerCM)
if err == nil {
util.Infof("\nRecreating configmap %s \n", exposecontrollerCM)
err = cfgms.Delete(exposecontrollerCM)
if err != nil {
printError("\nError deleting ConfigMap: "+exposecontrollerCM, err)
}
}

domainData := "domain: " + domain + "\n"
exposeData := exposeRule + ": " + defaultExposeRule(c, mini, d.useLoadbalancer) + "\n"
apiserverData := "apiserver: " + apiserver + "\n"
configFile := map[string]string{
"config.yml": domainData + exposeData + apiserverData,
}
configMap := kapi.ConfigMap{
ObjectMeta: kapi.ObjectMeta{
Name: exposecontrollerCM,
Labels: map[string]string{
"provider": "fabric8",
},
},
Data: configFile,
}
_, err = cfgms.Create(&configMap)
if err != nil {
printError("Failed to create ConfigMap: "+exposecontrollerCM, err)
}

runTemplate(c, oc, "exposecontroller", ns, domain, apiserver, pv)
updateExposeControllerConfig(c, ns, apiserver, domain, mini, d.useLoadbalancer)

if len(d.appToRun) > 0 {
runTemplate(c, oc, d.appToRun, ns, domain, apiserver, pv)
Expand Down Expand Up @@ -594,6 +567,7 @@ func deploy(f *cmdutil.Factory, d DefaultFabric8Deployment) {

// lets ensure that there is a `fabric8-environments` ConfigMap so that the current namespace
// shows up as a Team page in the console
cfgms := c.ConfigMaps(ns)
_, err = cfgms.Get(fabric8Environments)
if err != nil {
configMap := kapi.ConfigMap{
Expand Down Expand Up @@ -634,6 +608,40 @@ func deploy(f *cmdutil.Factory, d DefaultFabric8Deployment) {
}
}

func updateExposeControllerConfig(c *k8sclient.Client, ns string, apiserver string, domain string, mini bool, useLoadBalancer bool) {
// create a populate the exposecontroller config map
cfgms := c.ConfigMaps(ns)

_, err := cfgms.Get(exposecontrollerCM)
if err == nil {
util.Infof("\nRecreating configmap %s \n", exposecontrollerCM)
err = cfgms.Delete(exposecontrollerCM)
if err != nil {
printError("\nError deleting ConfigMap: "+exposecontrollerCM, err)
}
}

domainData := "domain: " + domain + "\n"
exposeData := exposeRule + ": " + defaultExposeRule(c, mini, useLoadBalancer) + "\n"
apiserverData := "apiserver: " + apiserver + "\n"
configFile := map[string]string{
"config.yml": domainData + exposeData + apiserverData,
}
configMap := kapi.ConfigMap{
ObjectMeta: kapi.ObjectMeta{
Name: exposecontrollerCM,
Labels: map[string]string{
"provider": "fabric8",
},
},
Data: configFile,
}
_, err = cfgms.Create(&configMap)
if err != nil {
printError("Failed to create ConfigMap: "+exposecontrollerCM, err)
}
}

func createMissingPVs(c *k8sclient.Client, ns string) {
found, pvcs, pendingClaimNames := findPendingPVs(c, ns)
if found {
Expand Down
2 changes: 1 addition & 1 deletion cmds/docker_env.go
Expand Up @@ -45,7 +45,7 @@ func NewCmdDockerEnv(f *cmdutil.Factory) *cobra.Command {
command = "minikube"
cargs = []string{"docker-env"}

} else if context == util.Minishift {
} else if util.IsMiniShift(context) {
command = "minishift"
cargs = []string{"docker-env"}

Expand Down
2 changes: 1 addition & 1 deletion cmds/status.go
Expand Up @@ -45,7 +45,7 @@ func NewCmdStatus(f *cmdutil.Factory) *cobra.Command {
command = "minikube"
cargs = []string{"status"}

} else if context == util.Minishift {
} else if util.IsMiniShift(context) {
command = "minishift"
cargs = []string{"status"}

Expand Down
2 changes: 1 addition & 1 deletion cmds/stop.go
Expand Up @@ -45,7 +45,7 @@ func NewCmdStop(f *cmdutil.Factory) *cobra.Command {
command = "minikube"
cargs = []string{"stop"}

} else if context == util.Minishift {
} else if util.IsMiniShift(context) {
command = "minishift"
cargs = []string{"stop"}

Expand Down
13 changes: 10 additions & 3 deletions util/util.go
Expand Up @@ -15,7 +15,10 @@
*/
package util

import "k8s.io/kubernetes/pkg/client/unversioned/clientcmd"
import (
"k8s.io/kubernetes/pkg/client/unversioned/clientcmd"
"strings"
)

const (
// Minikube context name
Expand All @@ -34,12 +37,16 @@ func IsMini() (bool, error) {
return false, err
}

if currentContext == Minikube || currentContext == Minishift {
if currentContext == Minikube || IsMiniShift(currentContext) {
return true, nil
}
return false, nil
}

func IsMiniShift(currentContext string) bool {
return currentContext == Minishift || strings.Contains(currentContext, "/minishift/")
}

// GetMiniType returns whether this is a minishift or minikube including which one
func GetMiniType() (string, bool, error) {
currentContext, err := GetCurrentContext()
Expand All @@ -48,7 +55,7 @@ func GetMiniType() (string, bool, error) {
return "", false, err
}

if currentContext == Minikube || currentContext == Minishift {
if currentContext == Minikube || IsMiniShift(currentContext) {
return currentContext, true, nil
}
return currentContext, false, nil
Expand Down

0 comments on commit d65d129

Please sign in to comment.