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
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
8 deletions
+48
-8
helm.go
cmd/helm/helm.go
+4
-0
init.go
cmd/helm/init.go
+4
-1
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 (
...
@@ -11,6 +11,9 @@ import (
var
stdout
=
os
.
Stdout
var
stdout
=
os
.
Stdout
var
helmHome
string
var
helmHome
string
// flagVerbose is a signal that the user wants additional output.
var
flagVerbose
bool
var
globalUsage
=
`The Kubernetes package manager
var
globalUsage
=
`The Kubernetes package manager
To begin working with Helm, run the 'helm init' command:
To begin working with Helm, run the 'helm init' command:
...
@@ -41,6 +44,7 @@ var RootCommand = &cobra.Command{
...
@@ -41,6 +44,7 @@ var RootCommand = &cobra.Command{
func
init
()
{
func
init
()
{
RootCommand
.
PersistentFlags
()
.
StringVar
(
&
helmHome
,
"home"
,
"$HOME/.helm"
,
"location of you Helm files [$HELM_HOME]"
)
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
()
{
func
main
()
{
...
...
cmd/helm/init.go
View file @
6869258c
...
@@ -17,11 +17,13 @@ Kubernetes Cluster and sets up local configuration in $HELM_HOME (default: ~/.he
...
@@ -17,11 +17,13 @@ Kubernetes Cluster and sets up local configuration in $HELM_HOME (default: ~/.he
var
(
var
(
tillerImg
string
tillerImg
string
clientOnly
bool
clientOnly
bool
tillerNamespace
string
)
)
func
init
()
{
func
init
()
{
initCmd
.
Flags
()
.
StringVarP
(
&
tillerImg
,
"tiller-image"
,
"i"
,
""
,
"override tiller image"
)
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
()
.
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
)
RootCommand
.
AddCommand
(
initCmd
)
}
}
...
@@ -57,7 +59,8 @@ func runInit(cmd *cobra.Command, args []string) error {
...
@@ -57,7 +59,8 @@ func runInit(cmd *cobra.Command, args []string) error {
func
installTiller
()
error
{
func
installTiller
()
error
{
i
:=
client
.
NewInstaller
()
i
:=
client
.
NewInstaller
()
i
.
Tiller
[
"Image"
]
=
tillerImg
i
.
Tiller
[
"Image"
]
=
tillerImg
err
:=
i
.
Install
()
i
.
Tiller
[
"Namespace"
]
=
tillerNamespace
err
:=
i
.
Install
(
flagVerbose
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"error installing: %s"
,
err
)
return
fmt
.
Errorf
(
"error installing: %s"
,
err
)
...
...
cmd/tiller/release_server.go
View file @
6869258c
...
@@ -15,10 +15,13 @@ import (
...
@@ -15,10 +15,13 @@ import (
ctx
"golang.org/x/net/context"
ctx
"golang.org/x/net/context"
)
)
var
srv
*
releaseServer
func
init
()
{
func
init
()
{
srv
:
=
&
releaseServer
{
srv
=
&
releaseServer
{
env
:
env
,
env
:
env
,
}
}
srv
.
env
.
Namespace
=
namespace
services
.
RegisterReleaseServiceServer
(
rootServer
,
srv
)
services
.
RegisterReleaseServiceServer
(
rootServer
,
srv
)
}
}
...
...
cmd/tiller/tiller.go
View file @
6869258c
...
@@ -21,6 +21,7 @@ var rootServer = grpc.NewServer()
...
@@ -21,6 +21,7 @@ var rootServer = grpc.NewServer()
var
env
=
environment
.
New
()
var
env
=
environment
.
New
()
var
addr
=
":44134"
var
addr
=
":44134"
var
namespace
=
""
const
globalUsage
=
`The Kubernetes Helm server.
const
globalUsage
=
`The Kubernetes Helm server.
...
@@ -37,11 +38,14 @@ var rootCommand = &cobra.Command{
...
@@ -37,11 +38,14 @@ var rootCommand = &cobra.Command{
}
}
func
main
()
{
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
()
rootCommand
.
Execute
()
}
}
func
start
(
c
*
cobra
.
Command
,
args
[]
string
)
{
func
start
(
c
*
cobra
.
Command
,
args
[]
string
)
{
setNamespace
()
lstn
,
err
:=
net
.
Listen
(
"tcp"
,
addr
)
lstn
,
err
:=
net
.
Listen
(
"tcp"
,
addr
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"Server died: %s
\n
"
,
err
)
fmt
.
Fprintf
(
os
.
Stderr
,
"Server died: %s
\n
"
,
err
)
...
@@ -55,3 +59,20 @@ func start(c *cobra.Command, args []string) {
...
@@ -55,3 +59,20 @@ func start(c *cobra.Command, args []string) {
os
.
Exit
(
1
)
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
...
@@ -2,6 +2,7 @@ package client
import
(
import
(
"bytes"
"bytes"
"fmt"
"text/template"
"text/template"
"github.com/Masterminds/sprig"
"github.com/Masterminds/sprig"
...
@@ -32,7 +33,7 @@ func NewInstaller() *Installer {
...
@@ -32,7 +33,7 @@ func NewInstaller() *Installer {
//
//
// Returns the string output received from the operation, and an error if the
// Returns the string output received from the operation, and an error if the
// command failed.
// command failed.
func
(
i
*
Installer
)
Install
()
error
{
func
(
i
*
Installer
)
Install
(
verbose
bool
)
error
{
var
b
bytes
.
Buffer
var
b
bytes
.
Buffer
err
:=
template
.
Must
(
template
.
New
(
"manifest"
)
.
Funcs
(
sprig
.
TxtFuncMap
())
.
err
:=
template
.
Must
(
template
.
New
(
"manifest"
)
.
Funcs
(
sprig
.
TxtFuncMap
())
.
...
@@ -43,19 +44,23 @@ func (i *Installer) Install() error {
...
@@ -43,19 +44,23 @@ func (i *Installer) Install() error {
return
err
return
err
}
}
if
verbose
{
fmt
.
Println
(
b
.
String
())
}
return
kube
.
New
(
nil
)
.
Create
(
"helm"
,
&
b
)
return
kube
.
New
(
nil
)
.
Create
(
"helm"
,
&
b
)
}
}
// InstallYAML is the installation YAML for DM.
// InstallYAML is the installation YAML for DM.
const
InstallYAML
=
`
const
InstallYAML
=
`
---
---
{{$namespace := default "helm" .Tiller.Namespace}}
apiVersion: v1
apiVersion: v1
kind: Namespace
kind: Namespace
metadata:
metadata:
labels:
labels:
app: helm
app: helm
name: helm-namespace
name: helm-namespace
name:
helm
name:
{{$namespace}}
---
---
apiVersion: v1
apiVersion: v1
kind: ReplicationController
kind: ReplicationController
...
@@ -64,7 +69,7 @@ metadata:
...
@@ -64,7 +69,7 @@ metadata:
app: helm
app: helm
name: tiller
name: tiller
name: tiller-rc
name: tiller-rc
namespace:
helm
namespace:
{{$namespace}}
spec:
spec:
replicas: 1
replicas: 1
selector:
selector:
...
@@ -77,7 +82,11 @@ spec:
...
@@ -77,7 +82,11 @@ spec:
name: tiller
name: tiller
spec:
spec:
containers:
containers:
- env: []
- env:
- name: DEFAULT_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
image: {{default "gcr.io/kubernetes-helm/tiller:canary" .Tiller.Image}}
image: {{default "gcr.io/kubernetes-helm/tiller:canary" .Tiller.Image}}
name: tiller
name: tiller
ports:
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