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
f763c88f
Commit
f763c88f
authored
Jan 05, 2017
by
Adam Reese
Committed by
GitHub
Jan 05, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1786 from mortenlj/master
Add `--upgrade` option to `init`. Fixes #1782.
parents
6f023b32
eeaacc4a
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
3 deletions
+50
-3
init.go
cmd/helm/init.go
+11
-1
init_test.go
cmd/helm/init_test.go
+2
-1
install.go
cmd/helm/installer/install.go
+18
-1
install_test.go
cmd/helm/installer/install_test.go
+19
-0
No files found.
cmd/helm/init.go
View file @
f763c88f
...
...
@@ -65,6 +65,7 @@ type initCmd struct {
image
string
clientOnly
bool
canary
bool
upgrade
bool
namespace
string
dryRun
bool
out
io
.
Writer
...
...
@@ -94,6 +95,7 @@ func newInitCmd(out io.Writer) *cobra.Command {
f
:=
cmd
.
Flags
()
f
.
StringVarP
(
&
i
.
image
,
"tiller-image"
,
"i"
,
""
,
"override tiller image"
)
f
.
BoolVar
(
&
i
.
canary
,
"canary-image"
,
false
,
"use the canary tiller image"
)
f
.
BoolVar
(
&
i
.
upgrade
,
"upgrade"
,
false
,
"upgrade if tiller is already installed"
)
f
.
BoolVarP
(
&
i
.
clientOnly
,
"client-only"
,
"c"
,
false
,
"if set does not install tiller"
)
f
.
BoolVar
(
&
i
.
dryRun
,
"dry-run"
,
false
,
"do not install local or remote"
)
...
...
@@ -130,7 +132,15 @@ func (i *initCmd) run() error {
if
!
kerrors
.
IsAlreadyExists
(
err
)
{
return
fmt
.
Errorf
(
"error installing: %s"
,
err
)
}
fmt
.
Fprintln
(
i
.
out
,
"Warning: Tiller is already installed in the cluster. (Use --client-only to suppress this message.)"
)
if
i
.
upgrade
{
if
err
:=
installer
.
Upgrade
(
i
.
kubeClient
,
i
.
namespace
,
i
.
image
,
i
.
canary
);
err
!=
nil
{
return
fmt
.
Errorf
(
"error when upgrading: %s"
,
err
)
}
fmt
.
Fprintln
(
i
.
out
,
"
\n
Tiller (the helm server side component) has been upgraded to the current version."
)
}
else
{
fmt
.
Fprintln
(
i
.
out
,
"Warning: Tiller is already installed in the cluster.
\n
"
+
"(Use --client-only to suppress this message, or --upgrade to upgrade Tiller to the current version.)"
)
}
}
else
{
fmt
.
Fprintln
(
i
.
out
,
"
\n
Tiller (the helm server side component) has been installed into your Kubernetes Cluster."
)
}
...
...
cmd/helm/init_test.go
View file @
f763c88f
...
...
@@ -89,7 +89,8 @@ func TestInitCmd_exsits(t *testing.T) {
if
err
:=
cmd
.
run
();
err
!=
nil
{
t
.
Errorf
(
"expected error: %v"
,
err
)
}
expected
:=
"Warning: Tiller is already installed in the cluster. (Use --client-only to suppress this message.)"
expected
:=
"Warning: Tiller is already installed in the cluster.
\n
"
+
"(Use --client-only to suppress this message, or --upgrade to upgrade Tiller to the current version.)"
if
!
strings
.
Contains
(
buf
.
String
(),
expected
)
{
t
.
Errorf
(
"expected %q, got %q"
,
expected
,
buf
.
String
())
}
...
...
cmd/helm/installer/install.go
View file @
f763c88f
...
...
@@ -43,15 +43,32 @@ func Install(client extensionsclient.DeploymentsGetter, namespace, image string,
return
err
}
// Upgrade uses kubernetes client to upgrade tiller to current version
//
// Returns an error if the command failed.
func
Upgrade
(
client
extensionsclient
.
DeploymentsGetter
,
namespace
,
image
string
,
canary
bool
)
error
{
obj
,
err
:=
client
.
Deployments
(
namespace
)
.
Get
(
"tiller-deploy"
)
if
err
!=
nil
{
return
err
}
obj
.
Spec
.
Template
.
Spec
.
Containers
[
0
]
.
Image
=
selectImage
(
image
,
canary
)
_
,
err
=
client
.
Deployments
(
namespace
)
.
Update
(
obj
)
return
err
}
// deployment gets the deployment object that installs Tiller.
func
deployment
(
namespace
,
image
string
,
canary
bool
)
*
extensions
.
Deployment
{
return
generateDeployment
(
namespace
,
selectImage
(
image
,
canary
))
}
func
selectImage
(
image
string
,
canary
bool
)
string
{
switch
{
case
canary
:
image
=
defaultImage
+
":canary"
case
image
==
""
:
image
=
fmt
.
Sprintf
(
"%s:%s"
,
defaultImage
,
version
.
Version
)
}
return
generateDeployment
(
namespace
,
image
)
return
image
}
// DeploymentManifest gets the manifest (as a string) that describes the Tiller Deployment
...
...
cmd/helm/installer/install_test.go
View file @
f763c88f
...
...
@@ -103,3 +103,22 @@ func TestInstall_canary(t *testing.T) {
t
.
Errorf
(
"unexpected error: %#+v"
,
err
)
}
}
func
TestUpgrade
(
t
*
testing
.
T
)
{
image
:=
"gcr.io/kubernetes-helm/tiller:v2.0.0"
fc
:=
fake
.
NewSimpleClientset
(
deployment
(
api
.
NamespaceDefault
,
"imageToReplace"
,
false
))
fc
.
AddReactor
(
"update"
,
"deployments"
,
func
(
action
testcore
.
Action
)
(
bool
,
runtime
.
Object
,
error
)
{
obj
:=
action
.
(
testcore
.
CreateAction
)
.
GetObject
()
.
(
*
extensions
.
Deployment
)
i
:=
obj
.
Spec
.
Template
.
Spec
.
Containers
[
0
]
.
Image
if
i
!=
image
{
t
.
Errorf
(
"expected image = '%s', got '%s'"
,
image
,
i
)
}
return
true
,
obj
,
nil
})
err
:=
Upgrade
(
fc
.
Extensions
(),
api
.
NamespaceDefault
,
image
,
false
)
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %#+v"
,
err
)
}
}
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