Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy stack by default on install/upgrade #1737

Merged
merged 3 commits into from Feb 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/lib/kontena/cli/stacks/install_command.rb
Expand Up @@ -11,7 +11,7 @@ class InstallCommand < Kontena::Command
include Common::StackFileOrNameParam

include Common::StackNameOption
option '--deploy', :flag, 'Deploy after installation'
option '--[no-]deploy', :flag, 'Trigger deploy after installation', default: true

include Common::StackValuesFromOption

Expand Down
4 changes: 2 additions & 2 deletions cli/lib/kontena/cli/stacks/upgrade_command.rb
Expand Up @@ -13,7 +13,7 @@ class UpgradeCommand < Kontena::Command
include Common::StackFileOrNameParam
include Common::StackValuesFromOption

option '--deploy', :flag, 'Deploy after upgrade'
option '--[no-]deploy', :flag, 'Trigger deploy after upgrade', default: true

requires_current_master
requires_current_master_token
Expand All @@ -29,7 +29,7 @@ def execute
update_stack(stack) || spin.fail!
end

Kontena.run("stack deploy #{name}") if deploy?
Kontena.run(['stack', 'deploy', name]) if deploy?
end

def update_stack(stack)
Expand Down
45 changes: 21 additions & 24 deletions cli/spec/kontena/cli/stacks/upgrade_command_spec.rb
Expand Up @@ -71,30 +71,27 @@
subject.run(['stack-b', './path/to/kontena.yml'])
end

context '--deploy option' do
context 'when given' do
it 'triggers deploy' do
expect(client).to receive(:get).with('stacks/test-grid/stack-a').and_return(stack_response)
allow(subject).to receive(:require_config_file).with('./path/to/kontena.yml').and_return(true)
allow(subject).to receive(:stack_from_yaml).with('./path/to/kontena.yml', name: 'stack-a', values: nil, from_registry: false, defaults: defaults).and_return(stack)
allow(client).to receive(:put).with(
'stacks/test-grid/stack-a', anything
).and_return({})
expect(Kontena).to receive(:run).with("stack deploy stack-a").once
subject.run(['--deploy', 'stack-a', './path/to/kontena.yml'])
end
end
context 'when not given' do
it 'does not trigger deploy' do
expect(client).to receive(:get).with('stacks/test-grid/stack-a').and_return(stack_response)
allow(subject).to receive(:require_config_file).with('./path/to/kontena.yml').and_return(true)
allow(subject).to receive(:stack_from_yaml).with('./path/to/kontena.yml', name: 'stack-a', values: nil, from_registry: false, defaults: defaults).and_return(stack)
allow(client).to receive(:put).with(
'stacks/test-grid/stack-a', anything
).and_return({})
expect(Kontena).not_to receive(:run).with("stack deploy stack-a")
subject.run(['stack-a', './path/to/kontena.yml'])
end
it 'triggers deploy by default' do
expect(client).to receive(:get).with('stacks/test-grid/stack-a').and_return(stack_response)
allow(subject).to receive(:require_config_file).with('./path/to/kontena.yml').and_return(true)
allow(subject).to receive(:stack_from_yaml).with('./path/to/kontena.yml', name: 'stack-a', values: nil, from_registry: false, defaults: defaults).and_return(stack)
allow(client).to receive(:put).with(
'stacks/test-grid/stack-a', anything
).and_return({})
expect(Kontena).to receive(:run).with(['stack', 'deploy', 'stack-a']).once
subject.run(['stack-a', './path/to/kontena.yml'])
end

context '--no-deploy option' do
it 'does not trigger deploy' do
expect(client).to receive(:get).with('stacks/test-grid/stack-a').and_return(stack_response)
allow(subject).to receive(:require_config_file).with('./path/to/kontena.yml').and_return(true)
allow(subject).to receive(:stack_from_yaml).with('./path/to/kontena.yml', name: 'stack-a', values: nil, from_registry: false, defaults: defaults).and_return(stack)
allow(client).to receive(:put).with(
'stacks/test-grid/stack-a', anything
).and_return({})
expect(Kontena).not_to receive(:run).with(['stack', 'deploy', 'stack-a'])
subject.run(['--no-deploy', 'stack-a', './path/to/kontena.yml'])
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started/quick-start.md
Expand Up @@ -135,7 +135,7 @@ services:
You can then install and deploy the `wordpress` stack:

```
$ kontena stack install --deploy kontena.yml
$ kontena stack install kontena.yml
[done] Creating stack wordpress
[done] Deploying stack wordpress
```
Expand Down
11 changes: 5 additions & 6 deletions docs/using-kontena/stacks.md
Expand Up @@ -134,30 +134,29 @@ The following Kontena CLI commands are used to install local stack files to the
* `kontena stack deploy` - Deploy a stack to the Grid
* `kontena stack remove` - Remove a deployed stack

#### `kontena stack install --name wordpress-red --deploy wordpress/kontena.yml`
#### `kontena stack install --name wordpress-red wordpress/kontena.yml`

Install the stack from the YAML file to the master, creating a new named stack with associated services.
Use the `--deploy` flag to simultaneously deploy the stack services to the grid, spinning up the Docker containers.

```
[done] Creating stack wordpress-red
[done] Deploying stack wordpress-red
```

The stack services will now be visible in `kontena service ls`, and the service containers will be running on the grid's host nodes.
If you omit the `kontena stack install --deploy` flag, then you must run `kontena stack deploy wordpress-red` separately.
If you add the `kontena stack install --no-deploy` flag, then you must run `kontena stack deploy wordpress-red` separately.

Assuming the new `wordpress-red/wordpress` container is running on the host node at `192.168.66.102`, you can use `http://192.168.66.102:80/` to access the installed wordpress service.

#### `kontena stack install --name wordpress-green --deploy terom/wordpress`
#### `kontena stack install --name wordpress-green terom/wordpress`

Install and deploy the stack using the latest YAML file from the stack registry.

#### `kontena stack install --name wordpress-green --deploy terom/wordpress:4.6.1+mariadb5.`
#### `kontena stack install --name wordpress-green terom/wordpress:4.6.1+mariadb5.`

Install and deploy the stack using the versioned YAML file from the stack registry.

#### `kontena stack install --name wordpress-green --deploy --values-from production.yml terom/wordpress:4.6.1+mariadb5.`
#### `kontena stack install --name wordpress-green --values-from production.yml terom/wordpress:4.6.1+mariadb5.`

Install and deploy the stack using the versioned YAML file from the stack registry, read variable values from 'production.yml'.

Expand Down