Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
helm3
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
helm3
Commits
6869258c
Commit
6869258c
authored
May 09, 2016
by
Matt Butcher
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #660 from technosophos/feat/tiller-ns-flag
feat(tiller): allow specifying namespace on cli
parents
9e7000fc
37cf3eab
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
10 deletions
+50
-10
helm.go
cmd/helm/helm.go
+4
-0
init.go
cmd/helm/init.go
+6
-3
release_server.go
cmd/tiller/release_server.go
+4
-1
tiller.go
cmd/tiller/tiller.go
+22
-1
install.go
pkg/client/install.go
+14
-5
No files found.
cmd/helm/helm.go
View file @
6869258c
...
...
@@ -11,6 +11,9 @@ import (
var
stdout
=
os
.
Stdout
var
helmHome
string
// flagVerbose is a signal that the user wants additional output.
var
flagVerbose
bool
var
globalUsage
=
`The Kubernetes package manager
To begin working with Helm, run the 'helm init' command:
...
...
@@ -41,6 +44,7 @@ var RootCommand = &cobra.Command{
func
init
()
{
RootCommand
.
PersistentFlags
()
.
StringVar
(
&
helmHome
,
"home"
,
"$HOME/.helm"
,
"location of you Helm files [$HELM_HOME]"
)
RootCommand
.
PersistentFlags
()
.
BoolVarP
(
&
flagVerbose
,
"verbose"
,
"v"
,
false
,
"enable verbose output"
)
}
func
main
()
{
...
...
cmd/helm/init.go
View file @
6869258c
...
...
@@ -15,13 +15,15 @@ Kubernetes Cluster and sets up local configuration in $HELM_HOME (default: ~/.he
`
var
(
tillerImg
string
clientOnly
bool
tillerImg
string
clientOnly
bool
tillerNamespace
string
)
func
init
()
{
initCmd
.
Flags
()
.
StringVarP
(
&
tillerImg
,
"tiller-image"
,
"i"
,
""
,
"override tiller image"
)
initCmd
.
Flags
()
.
BoolVarP
(
&
clientOnly
,
"client-only"
,
"c"
,
false
,
"If set does not install tiller"
)
initCmd
.
Flags
()
.
StringVarP
(
&
tillerNamespace
,
"namespace"
,
"n"
,
"helm"
,
"set the tiller namespace"
)
RootCommand
.
AddCommand
(
initCmd
)
}
...
...
@@ -57,7 +59,8 @@ func runInit(cmd *cobra.Command, args []string) error {
func
installTiller
()
error
{
i
:=
client
.
NewInstaller
()
i
.
Tiller
[
"Image"
]
=
tillerImg
err
:=
i
.
Install
()
i
.
Tiller
[
"Namespace"
]
=
tillerNamespace
err
:=
i
.
Install
(
flagVerbose
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"error installing: %s"
,
err
)
...
...
cmd/tiller/release_server.go
View file @
6869258c
...
...
@@ -15,10 +15,13 @@ import (
ctx
"golang.org/x/net/context"
)
var
srv
*
releaseServer
func
init
()
{
srv
:
=
&
releaseServer
{
srv
=
&
releaseServer
{
env
:
env
,
}
srv
.
env
.
Namespace
=
namespace
services
.
RegisterReleaseServiceServer
(
rootServer
,
srv
)
}
...
...
cmd/tiller/tiller.go
View file @
6869258c
...
...
@@ -21,6 +21,7 @@ var rootServer = grpc.NewServer()
var
env
=
environment
.
New
()
var
addr
=
":44134"
var
namespace
=
""
const
globalUsage
=
`The Kubernetes Helm server.
...
...
@@ -37,11 +38,14 @@ var rootCommand = &cobra.Command{
}
func
main
()
{
rootCommand
.
PersistentFlags
()
.
StringVarP
(
&
addr
,
"listen"
,
"l"
,
":44134"
,
"The address:port to listen on"
)
pf
:=
rootCommand
.
PersistentFlags
()
pf
.
StringVarP
(
&
addr
,
"listen"
,
"l"
,
":44134"
,
"The address:port to listen on"
)
pf
.
StringVarP
(
&
namespace
,
"namespace"
,
"n"
,
""
,
"The namespace Tiller calls home"
)
rootCommand
.
Execute
()
}
func
start
(
c
*
cobra
.
Command
,
args
[]
string
)
{
setNamespace
()
lstn
,
err
:=
net
.
Listen
(
"tcp"
,
addr
)
if
err
!=
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"Server died: %s
\n
"
,
err
)
...
...
@@ -55,3 +59,20 @@ func start(c *cobra.Command, args []string) {
os
.
Exit
(
1
)
}
}
// setNamespace sets the namespace.
//
// It checks for the --namespace flag first, then checks the environment
// (set by Downward API), then goes to default.
func
setNamespace
()
{
if
len
(
namespace
)
!=
0
{
fmt
.
Printf
(
"Setting namespace to %q
\n
"
,
namespace
)
srv
.
env
.
Namespace
=
namespace
}
else
if
ns
:=
os
.
Getenv
(
"DEFAULT_NAMESPACE"
);
len
(
ns
)
!=
0
{
fmt
.
Printf
(
"Inhereting namespace %q from Downward API
\n
"
,
ns
)
srv
.
env
.
Namespace
=
ns
}
else
{
fmt
.
Printf
(
"Using default namespace %q"
,
environment
.
DefaultNamespace
)
srv
.
env
.
Namespace
=
environment
.
DefaultNamespace
}
}
pkg/client/install.go
View file @
6869258c
...
...
@@ -2,6 +2,7 @@ package client
import
(
"bytes"
"fmt"
"text/template"
"github.com/Masterminds/sprig"
...
...
@@ -32,7 +33,7 @@ func NewInstaller() *Installer {
//
// Returns the string output received from the operation, and an error if the
// command failed.
func
(
i
*
Installer
)
Install
()
error
{
func
(
i
*
Installer
)
Install
(
verbose
bool
)
error
{
var
b
bytes
.
Buffer
err
:=
template
.
Must
(
template
.
New
(
"manifest"
)
.
Funcs
(
sprig
.
TxtFuncMap
())
.
...
...
@@ -43,19 +44,23 @@ func (i *Installer) Install() error {
return
err
}
if
verbose
{
fmt
.
Println
(
b
.
String
())
}
return
kube
.
New
(
nil
)
.
Create
(
"helm"
,
&
b
)
}
// InstallYAML is the installation YAML for DM.
const
InstallYAML
=
`
---
---
{{$namespace := default "helm" .Tiller.Namespace}}
apiVersion: v1
kind: Namespace
metadata:
labels:
app: helm
name: helm-namespace
name:
helm
name:
{{$namespace}}
---
apiVersion: v1
kind: ReplicationController
...
...
@@ -64,7 +69,7 @@ metadata:
app: helm
name: tiller
name: tiller-rc
namespace:
helm
namespace:
{{$namespace}}
spec:
replicas: 1
selector:
...
...
@@ -77,7 +82,11 @@ spec:
name: tiller
spec:
containers:
- env: []
- env:
- name: DEFAULT_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
image: {{default "gcr.io/kubernetes-helm/tiller:canary" .Tiller.Image}}
name: tiller
ports:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment