civo_cli 0.4.5 → 0.4.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ccd3f61d8a3693962d4dd59039aa43c5138745c63be90a6138c07903cc0f50a
4
- data.tar.gz: 5408ab15762175cb0720a9ac746d049e23e6f03da589ef5c54c70def21a7ed2e
3
+ metadata.gz: f677f74099b68315c824843def3112cc20190588066d6efe027abae1f02dd3fb
4
+ data.tar.gz: fcd21eee2af1e684d2f1f427d8db66d354a2dac7e929baa8686d6e18e09324c1
5
5
  SHA512:
6
- metadata.gz: bccfa3c0f62c7d404fe883548716dfd36fb012965bd8006c83bff1624ee4fa0229a562d34aaaac343f03cd58b465e77f1dc531028b7ff1c5cb30f1869c2d6b7a
7
- data.tar.gz: da98e39e9e6f48176d7212bd3faa8850d9a07092133abbad7416f21876db7358237ee28cc1ab4c3176960e3cca21722e7eeb9269460a3aa72bfd8242a3a52113
6
+ metadata.gz: 98559a1e50cf114746c8707a61277836e78187bbafa4c319ff1de329d621a663a153fcaf7ef93f4864cb0b3018976d07309dbbe69a75f7bef80ea945bc6a0b94
7
+ data.tar.gz: f51e7291b27b3a520210fe80ecab4c073e77476408f1b2517a1262a58a01941722a172d112e0f1bfa34df0f559714ae15f5ad848ec5c66023dd24cf53766fe93
@@ -3,6 +3,16 @@ All notable changes to the Civo CLI will be documented in this file.
3
3
 
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
5
5
 
6
+ ## [0.4.7] - 2019-10-17
7
+ ### Added
8
+ - Ability to upgrade an existing k3s cluster `civo k3s upgrade`.
9
+
10
+ ## [0.4.6] - 2019-10-08
11
+ ### Fixed
12
+ - Behaviour of Kubernetes cluster configuration saving in Windows
13
+ ### Added
14
+ - Help text for some common aliases when running `civo help`.
15
+
6
16
  ## [0.4.5] - 2019-09-30
7
17
  ### Changed
8
18
  - Set default for reboot to be a soft reboot, and made hard-reboot an optional extra command
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- civo_cli (0.4.5)
4
+ civo_cli (0.4.7)
5
5
  bundler (~> 1.17)
6
- civo (>= 1.2.8)
6
+ civo (>= 1.2.9)
7
7
  colorize
8
8
  json
9
9
  terminal-table
@@ -20,7 +20,7 @@ GEM
20
20
  zeitwerk (~> 2.1, >= 2.1.8)
21
21
  addressable (2.6.0)
22
22
  public_suffix (>= 2.0.2, < 4.0)
23
- civo (1.2.8)
23
+ civo (1.2.9)
24
24
  commander
25
25
  flexirest (>= 1.4.6)
26
26
  toml
@@ -32,7 +32,7 @@ GEM
32
32
  crack (0.4.3)
33
33
  safe_yaml (~> 1.0.0)
34
34
  diff-lcs (1.3)
35
- faraday (0.16.2)
35
+ faraday (0.17.0)
36
36
  multipart-post (>= 1.2, < 3)
37
37
  ffi (1.11.1)
38
38
  flexirest (1.8.6)
@@ -57,8 +57,8 @@ GEM
57
57
  guard-compat (~> 1.1)
58
58
  rspec (>= 2.99.0, < 4.0)
59
59
  hashdiff (1.0.0)
60
- highline (2.0.2)
61
- i18n (1.6.0)
60
+ highline (2.0.3)
61
+ i18n (1.7.0)
62
62
  concurrent-ruby (~> 1.0)
63
63
  json (2.2.0)
64
64
  listen (3.1.5)
@@ -69,9 +69,9 @@ GEM
69
69
  method_source (0.9.2)
70
70
  mime-types (3.3)
71
71
  mime-types-data (~> 3.2015)
72
- mime-types-data (3.2019.0904)
72
+ mime-types-data (3.2019.1009)
73
73
  minitest (5.12.2)
74
- multi_json (1.13.1)
74
+ multi_json (1.14.1)
75
75
  multipart-post (2.1.1)
76
76
  nenv (0.3.0)
77
77
  notiffany (0.1.3)
@@ -116,7 +116,7 @@ GEM
116
116
  addressable (>= 2.3.6)
117
117
  crack (>= 0.3.2)
118
118
  hashdiff (>= 0.4.0, < 2.0.0)
119
- zeitwerk (2.1.10)
119
+ zeitwerk (2.2.0)
120
120
 
121
121
  PLATFORMS
122
122
  ruby
data/README.md CHANGED
@@ -11,6 +11,7 @@ Civo CLI is a tool to manage your [Civo.com](https://www.civo.com) account from
11
11
  - [API Keys](#api-keys)
12
12
  - [Instances](#instances)
13
13
  - [Kubernetes clusters](#kubernetes-clusters)
14
+ - [Kubernetes applications](#kubernetes-applications)
14
15
  - [Domains and Domain Records](#domains-and-domain-records)
15
16
  - [Firewalls](#firewalls)
16
17
  - [Networks](#networks)
@@ -273,7 +274,7 @@ $ civo kubernetes list
273
274
  +--------------------------------------+------+---------+-----------+--------+
274
275
  ```
275
276
 
276
- #### Create a cluster
277
+ #### Create a cluster
277
278
  You can create an instance by running `civo kubernetes create` with a cluster name parameter, as well as any options you provide:
278
279
 
279
280
  * `size` - The size of nodes to create, from the current list of sizes available at [`civo sizes`](#sizes). Defaults to `g2.medium`.
@@ -299,10 +300,12 @@ To output a cluster's configuration information, you can invoke `civo kubernetes
299
300
 
300
301
  You can save a cluster's configuration to your local `~/.kube/config` file. This requires `kubectl` to be installed. Usage:
301
302
  ```
302
- civo kubernetes save my-first-cluster
303
+ civo kubernetes config -s my-first-cluster
303
304
  Saved config to ~/.kube/config
304
305
  ```
305
306
 
307
+ If you already have a `~/.kube/config` file, any cluster configuration that is saved will be merged to the file, allowing you to switch contexts at will.
308
+
306
309
  #### Renaming the cluster
307
310
  Although the name isn't used anywhere except for in the list of clusters (e.g. it's not in any way written in to the cluster), if you wish to rename a cluster you can do so with:
308
311
 
@@ -319,6 +322,85 @@ civo kubernetes remove my-first-cluster
319
322
  Removing Kubernetes cluster my-first-cluster
320
323
  ```
321
324
 
325
+ ## Kubernetes Applications
326
+ #### Introduction
327
+ You can install applications from the [Applications Marketplace](https://github.com/civo/kubernetes-marketplace/) through the command-line interface. The installation depends on if you are creating a new cluster or adding applications to an existing cluster.
328
+
329
+ #### Listing Available Applications
330
+ To get an up-to-date list of available applications on the Marketplace, run `civo apps list`. At the time of writing, the list looked like this:
331
+ ```
332
+ +---------------------+------------+--------------+-----------------+--------------+
333
+ | Name | Version | Category | Plans | Dependencies |
334
+ +---------------------+------------+--------------+-----------------+--------------+
335
+ | cert-manager | v0.10.0 | architecture | Not applicable | Helm |
336
+ | Helm | 2.14.3 | management | Not applicable | |
337
+ | Linkerd | 2.5.0 | architecture | Not applicable | |
338
+ | Longhorn | 0.5.0 | storage | Not applicable | |
339
+ | Maesh | Latest | architecture | Not applicable | Helm |
340
+ | MariaDB | 10.4.7 | database | 5GB, 10GB, 20GB | Longhorn |
341
+ | metrics-server | Latest | architecture | Not applicable | Helm |
342
+ | MinIO | 2019-08-29 | storage | 5GB, 10GB, 20GB | Longhorn |
343
+ | MongoDB | 4.2.0 | database | 5GB, 10GB, 20GB | Longhorn |
344
+ | OpenFaaS | 0.18.0 | architecture | Not applicable | Helm |
345
+ | PostgreSQL | 11.5 | database | 5GB, 10GB, 20GB | Longhorn |
346
+ | prometheus-operator | 0.32.0 | monitoring | Not applicable | Helm |
347
+ | Redis | 3.2 | database | Not applicable | |
348
+ | Traefik | (default) | architecture | Not applicable | |
349
+ +---------------------+------------+--------------+-----------------+--------------+
350
+ ```
351
+
352
+
353
+ #### Installing Applications Onto a New Cluster
354
+ To specify applications to install onto a new cluster, list them at cluster creation by specifying their `name` from the list above:
355
+ ```
356
+ $ civo kubernetes create apps-demo-cluster --nodes=2 --applications=Redis,Linkerd
357
+ Created Kubernetes cluster apps-demo-cluster.
358
+ ```
359
+ Now, if you take a look at the cluster's details, you will see the newly-installed applications listed:
360
+ ```
361
+ $ civo kubernetes show apps-demo
362
+ ID : 1199efbe-e2a5-4d25-a32f-0b7aa50082b2
363
+ Name : apps-demo-cluster
364
+ # Nodes : 2
365
+ Size : g2.medium
366
+ Status : ACTIVE
367
+ Version : 0.8.1
368
+ API Endpoint : https://[Cluster-IP]:6443
369
+ DNS A record : 1199efbe-e2a5-4d25-a32f-0b7aa50082b2.k8s.civo.com
370
+
371
+ Nodes:
372
+ +------------------+----------------+--------+
373
+ | Name | IP | Status |
374
+ +------------------+----------------+--------+
375
+ | kube-master-1e91 | (IP) | ACTIVE |
376
+ | kube-node-e678 | (IP) | ACTIVE |
377
+ +------------------+----------------+--------+
378
+
379
+ Installed marketplace applications:
380
+ +---------+-----------+-----------+--------------+
381
+ | Name | Version | Installed | Category |
382
+ +---------+-----------+-----------+--------------+
383
+ | Traefik | (default) | Yes | architecture |
384
+ | Linkerd | 2.5.0 | Yes | architecture |
385
+ | Redis | 3.2 | Yes | database |
386
+ +---------+-----------+-----------+--------------+
387
+ ```
388
+
389
+ #### Installing Applications to an Existing Cluster
390
+ If you want to add a new application to an existing cluster, you can do so by running the `civo applications` command specifying the cluster and the app(s) you wish to add:
391
+ ```
392
+ $ civo applications add Longhorn --cluster=apps-demo
393
+ Added Longhorn 0.5.0 to Kubernetes cluster apps-demo-cluster
394
+ ```
395
+
396
+ #### Installing Applications That Require Plans
397
+ Some applications, specifically database apps, require a storage plan that you can specify at installation time from the list of plan options. If you do not provide a plan for an application that requires one, the CLI will notify you and suggest a default size:
398
+ ```
399
+ $ civo applications add mariadb --cluster=apps-demo
400
+ You requested to add MariaDB but didn't select a plan. Please choose one... (5GB, 10GB, 20GB) [5GB]: 10GB
401
+ Thank you, next time you could use "MariaDB:10GB" to choose automatically
402
+ Added MariaDB 10.4.7 to Kubernetes cluster apps-demo-cluster
403
+ ```
322
404
 
323
405
  ## Domains and Domain Records
324
406
  #### Introduction
@@ -49,6 +49,6 @@ Gem::Specification.new do |spec|
49
49
  spec.add_runtime_dependency 'thor'
50
50
  spec.add_runtime_dependency 'colorize'
51
51
  spec.add_runtime_dependency "bundler", "~> 1.17"
52
- spec.add_runtime_dependency 'civo', ">= 1.2.8"
52
+ spec.add_runtime_dependency 'civo', ">= 1.2.9"
53
53
  spec.add_runtime_dependency 'json'
54
54
  end
@@ -38,11 +38,11 @@ module CivoCLI
38
38
  subcommand "instance", CivoCLI::Instance
39
39
  map "instances" => "instance"
40
40
 
41
- desc "kubernetes", "manage Kubernetes"
41
+ desc "kubernetes", "manage Kubernetes. Aliases: k8s, k3s"
42
42
  subcommand "kubernetes", CivoCLI::Kubernetes
43
43
  map "k8s" => "kubernetes", "k3s" => "kubernetes"
44
44
 
45
- desc "applications", "list and add marketplace applications to Kubernetes clusters"
45
+ desc "applications", "list and add marketplace applications to Kubernetes clusters. Alias: apps, addons, marketplace, k8s-apps, k3s-apps"
46
46
  subcommand "applications", CivoCLI::KubernetesApplications
47
47
  map "apps" => "applications", "app" => "applications", "application" => "applications",
48
48
  "addon" => "applications", "addons" => "applications", "marketplace" => "applications",
@@ -1,3 +1,3 @@
1
1
  module CivoCLI
2
- VERSION = "0.4.5"
2
+ VERSION = "0.4.7"
3
3
  end
@@ -5,16 +5,27 @@ module CivoCLI
5
5
  option :quiet, type: :boolean, aliases: '-q'
6
6
  def list
7
7
  CivoCLI::Config.set_api_auth
8
+ latest_version = get_latest_k3s_version
9
+ upgrade_available = false
10
+
8
11
  if options[:quiet]
9
12
  Civo::Kubernetes.all.items.each do |cluster|
10
13
  puts cluster.id
11
14
  end
12
15
  else
16
+ upgrade_available = true
13
17
  rows = []
14
18
  Civo::Kubernetes.all.items.each do |cluster|
15
- rows << [cluster.id, cluster.name, cluster.num_target_nodes, cluster.target_nodes_size, cluster.status]
19
+ version = cluster.kubernetes_version
20
+ if Gem::Version.new(latest_version) > Gem::Version.new(version)
21
+ version = "#{version} *".colorize(:red)
22
+ end
23
+ rows << [cluster.id, cluster.name, cluster.num_target_nodes, cluster.target_nodes_size, version, cluster.status]
24
+ end
25
+ puts Terminal::Table.new headings: ['ID', 'Name', '# Nodes', 'Size', 'Version', 'Status'], rows: rows
26
+ if upgrade_available
27
+ puts "\n* An upgrade to v#{latest_version} is available, use - civo k3s upgrade ID - to upgrade it".colorize(:red)
16
28
  end
17
- puts Terminal::Table.new headings: ['ID', 'Name', '# Nodes', 'Size', 'Status'], rows: rows
18
29
  end
19
30
  rescue Flexirest::HTTPForbiddenClientException
20
31
  reject_user_access
@@ -26,6 +37,7 @@ module CivoCLI
26
37
  CivoCLI::Config.set_api_auth
27
38
  rows = []
28
39
  cluster = Finder.detect_cluster(id)
40
+ upgrade_available = false
29
41
 
30
42
  puts " ID : #{cluster.id}"
31
43
  puts " Name : #{cluster.name}"
@@ -39,9 +51,22 @@ module CivoCLI
39
51
  else
40
52
  puts " Status : #{cluster.status.colorize(:red)}"
41
53
  end
42
- puts " Version : #{cluster.kubernetes_version}"
54
+
55
+ latest_version = get_latest_k3s_version
56
+ if Gem::Version.new(latest_version) > Gem::Version.new(cluster.kubernetes_version)
57
+ puts " Version : " + "#{cluster.kubernetes_version} *".colorize(:red)
58
+ upgrade_available = true
59
+ else
60
+ puts " Version : #{cluster.kubernetes_version}"
61
+ end
62
+
43
63
  puts " API Endpoint : #{cluster.api_endpoint}"
44
64
  puts " DNS A record : #{cluster.id}.k8s.civo.com"
65
+ puts " *.#{cluster.id}.k8s.civo.com"
66
+
67
+ if upgrade_available
68
+ puts "\n* An upgrade to v#{latest_version} is available, use - civo k3s upgrade ID - to upgrade it".colorize(:red)
69
+ end
45
70
 
46
71
  puts ""
47
72
  puts "Nodes:"
@@ -204,6 +229,23 @@ module CivoCLI
204
229
  exit 1
205
230
  end
206
231
 
232
+ desc "upgrade ID/NAME [--version]", "upgrade Kubernetes cluster's k3s version"
233
+ option :version
234
+ long_desc <<-LONGDESC
235
+ Use --name=version to specify the new version (or leave blank to automatically use latest)
236
+ LONGDESC
237
+ def upgrade(id)
238
+ CivoCLI::Config.set_api_auth
239
+ cluster = Finder.detect_cluster(id)
240
+
241
+ version = get_latest_k3s_version(options[:version])
242
+ Civo::Kubernetes.update(id: cluster.id, version: version)
243
+ puts "Kubernetes cluster #{cluster.name.colorize(:green)} is upgrading to #{version.colorize(:green)}"
244
+ rescue Flexirest::HTTPException => e
245
+ puts e.result.reason.colorize(:red)
246
+ exit 1
247
+ end
248
+
207
249
  desc "scale ID/NAME [--nodes]", "rescale the Kubernetes cluster to a new node count"
208
250
  option :nodes
209
251
  long_desc <<-LONGDESC
@@ -240,19 +282,32 @@ module CivoCLI
240
282
 
241
283
  private
242
284
 
285
+ def windows?
286
+ RUBY_PLATFORM =~ /win32/ || RUBY_PLATFORM =~ /mingw/
287
+ end
288
+
243
289
  def save_config(cluster)
244
290
  config_file_exists = File.exist?("#{ENV["HOME"]}/.kube/config")
245
291
  tempfile = Tempfile.new('import_kubeconfig')
246
292
  begin
247
293
  tempfile.write(cluster.kubeconfig)
248
294
  tempfile.size
249
- if options[:switch]
250
- result = `KUBECONFIG=#{tempfile.path}:~/.kube/config kubectl config view --flatten`
295
+ if windows?
296
+ home = `echo %HOMEPATH%`.chomp
297
+ if options[:switch]
298
+ ENV['KUBECONFIG'] = "#{tempfile.path};#{home}\\.kube\\config"
299
+ else
300
+ ENV['KUBECONFIG'] = "#{home}\\.kube\\config;#{tempfile.path}"
301
+ end
302
+ result = `kubectl config view --flatten`
251
303
  else
252
- result = `KUBECONFIG=~/.kube/config:#{tempfile.path} kubectl config view --flatten`
304
+ if options[:switch]
305
+ result = `KUBECONFIG=#{tempfile.path}:~/.kube/config kubectl config view --flatten`
306
+ else
307
+ result = `KUBECONFIG=~/.kube/config:#{tempfile.path} kubectl config view --flatten`
308
+ end
253
309
  end
254
- Dir.mkdir("#{ENV['HOME']}/.kube/") unless Dir.exist?("#{ENV["HOME"]}/.kube/")
255
- File.write("#{ENV['HOME']}/.kube/config", result)
310
+ write_file(result)
256
311
  if config_file_exists && options[:switch]
257
312
  puts "Merged".colorize(:green) + " config into ~/.kube/config and switched context to #{cluster.name}"
258
313
  elsif config_file_exists && !options[:switch]
@@ -266,9 +321,28 @@ module CivoCLI
266
321
  end
267
322
  end
268
323
 
324
+ def write_file(result)
325
+ Dir.mkdir("#{ENV['HOME']}/.kube/") unless Dir.exist?("#{ENV["HOME"]}/.kube/")
326
+ File.write("#{ENV['HOME']}/.kube/config", result)
327
+ end
328
+
269
329
  def reject_user_access
270
330
  puts "Sorry, this functionality is currently in closed beta and not available to the public yet"
271
331
  exit(1)
272
332
  end
333
+
334
+ def get_latest_k3s_version(version = nil)
335
+ available_versions = Civo::Kubernetes.versions
336
+ if version
337
+ if available_versions.detect {|v| v.version == version}
338
+ version
339
+ else
340
+ puts "Version #{version.colorize(:red)} is not available for upgrading"
341
+ exit(1)
342
+ end
343
+ else
344
+ available_versions.first.version
345
+ end
346
+ end
273
347
  end
274
348
  end
@@ -57,7 +57,7 @@ module CivoCLI
57
57
 
58
58
 
59
59
  desc "add NAME --cluster=...", "add the marketplace application to a Kubernetes cluster by ID or name"
60
- option :cluster, required: true
60
+ option :cluster
61
61
  long_desc <<-LONGDESC
62
62
  Use --cluster=name to specify part of the ID or name of the cluster to add the application to
63
63
  LONGDESC
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: civo_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Jeffries
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2019-10-03 00:00:00.000000000 Z
13
+ date: 2019-10-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
@@ -158,14 +158,14 @@ dependencies:
158
158
  requirements:
159
159
  - - ">="
160
160
  - !ruby/object:Gem::Version
161
- version: 1.2.8
161
+ version: 1.2.9
162
162
  type: :runtime
163
163
  prerelease: false
164
164
  version_requirements: !ruby/object:Gem::Requirement
165
165
  requirements:
166
166
  - - ">="
167
167
  - !ruby/object:Gem::Version
168
- version: 1.2.8
168
+ version: 1.2.9
169
169
  - !ruby/object:Gem::Dependency
170
170
  name: json
171
171
  requirement: !ruby/object:Gem::Requirement