cloud-sh 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b779b9ffb09de3a990d1f15dcadfb8dbd18c958c86836866b0ff417a20759907
4
- data.tar.gz: ad1200c5af739ed5d7a0e0b21a010f5f6309b528e4e0c46a9519d12b547dda07
3
+ metadata.gz: 7d542846c4ade970de1b85af0ea33def7b5c4d373c82e70b33e961f3cfbb6c51
4
+ data.tar.gz: cb699d91552a1174d7e424d20e5be9767b575be019bb62bc25293fdad3c91414
5
5
  SHA512:
6
- metadata.gz: 8923664d58e8f4ac6794b9a2195f33d37d1ce191d1b8aa66f3791edbeff4a45e625ff8f5fa11063326322ef5ece9f5e509b091d5fb7cd767a35a646ae422cef4
7
- data.tar.gz: ac512fa615a6ace8b00f8f50aabeed62a6bdf2c6af29d0e95cabcd92e9b35f1372b7bd0381edd7fdfa0722cb852d80a5226a2845ba59ded1897a6accc23661be
6
+ metadata.gz: 30425d3f24bfb1481adf1ea89dc120e4e1f19ebea5b1b635ecbb03769831f29f738f572b94995e6459c68d7493076b5cfe4e53ce012eb5c83f8771a7de35fe8a
7
+ data.tar.gz: a71f8117f7909c240eea82d4f4aafb458aebca95a6b41852d0c18b4138c747e5023a4d6ea6098a4c5f371553699dd511a1ae367ace37dda894064608362f0830
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Cloud shell helpers
2
2
 
3
- Wrapper around `doctl`, `kubectl` to build aliases for easier access to cloud server, services. Special mention to [kubetail](https://github.com/johanhaleby/kubetail) which does the multiple kubernetes containers tailing.
3
+ Wrapper around `doctl`, `kubectl` to build aliases for easier access to cloud server and services.
4
+ Special mention to [kubetail](https://github.com/johanhaleby/kubetail) which does the multiple kubernetes containers tailing.
4
5
 
5
6
  ## Features
6
7
 
@@ -14,11 +15,13 @@ Wrapper around `doctl`, `kubectl` to build aliases for easier access to cloud se
14
15
  ### Requirements
15
16
 
16
17
  - recent version of ruby (2.6+)
17
- - kubectl
18
- - doctl
19
- - A MySQL client (mysql - version 8 needed for TLS, mycli)
20
- - A Postgres client (psql, pgcli)
21
- - Redis client (you'll need redli as it needs TLS support)
18
+ - [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/)
19
+ - [doctl](https://github.com/digitalocean/doctl)
20
+
21
+ If you're using DigitalOcean's Databases you'll need some clients for the aliases to work.
22
+ - A MySQL client ([mysql](https://dev.mysql.com/downloads/) - version 8 needed for TLS, [mycli](https://www.mycli.net))
23
+ - A Postgres client ([psql](https://www.postgresql.org/download/), [pgcli](https://www.pgcli.com))
24
+ - Redis client (you'll need [redli](https://github.com/IBM-Cloud/redli) as it needs TLS support)
22
25
 
23
26
  ### Install
24
27
 
@@ -36,18 +39,18 @@ Write a YAML file to `~/.config/cloud-sh.yml`
36
39
 
37
40
  ```
38
41
  - name: personal # name of the account; will be used to prefix aliases
39
- kind: do # cloud kind (do - digitalocean support for now)
40
- default: true # if true don't use the name for aliases (default: false)
42
+ kind: do # cloud kind (do - digitalocean only support for now)
43
+ default: true # if true don't use the name to prefix aliases (default: false)
41
44
  context: default # doctl context
42
45
  clusters: # customize K8S clusters aliases
43
46
  - name: k8s-01 # name as it is at DigitalOcean
44
47
  alias: staging # alias name to be used in aliases (defaults to name)
45
- default: true # if true don't use the name / alias (default: false)
48
+ default: true # if true don't use the name / alias as prefix (default: false)
46
49
  ignore: true # don't create aliases for this (default: false)
47
50
  databases: # customize databases aliases
48
51
  - name: pg-01 # name as it is at DigitalOcean
49
52
  alias: staging # alias name to be used in aliases (defaults to name)
50
- default: true # if true don't use the name / alias (default: false)
53
+ default: true # if true don't use the name / alias as prfix (default: false)
51
54
  ignore: true # don't create aliases for this (default: false)
52
55
  ```
53
56
 
@@ -57,14 +60,14 @@ After that you can run `cloud-sh refresh` you'll get the aliases written to `~/.
57
60
 
58
61
  1. Manual Integration
59
62
 
60
- Run `cloud-sh refresh` to generate the aliases in `~/cloud_sh_aliases` and load the aliases. Or run `cloud-sh help` to see the available options.
61
-
63
+ Run `cloud-sh refresh` to generate the aliases in `~/cloud_sh_aliases` and load the aliases with `source ~/cloud_sh_aliase`.
62
64
 
63
65
  2. Automatic Integration
64
- Setup a cron job for it:
66
+
67
+ Setup a cron job to generate aliases:
65
68
 
66
69
  ```
67
- * * * * * ~/.cloud-sh/bin/cloud-sh refresh 2>&1 | logger -t cloud-sh
70
+ */5 * * * * . $HOME/.profile; cloud-sh refresh 2>&1 | logger -t cloud-sh
68
71
  ```
69
72
 
70
73
  And load the aliases using for shell. For `zsh` I'm adding to `.zshrc`:
@@ -78,12 +81,17 @@ add-zsh-hook precmd reload_cloud_sh
78
81
 
79
82
  ### Digital Ocean aliases
80
83
  ```
81
- do-ssh-[account-name]-[dashed-droplet-name]
82
- do-psql-[account-name]-[db-cluster-name]-[db-name]
83
- do-pgcli-[account-name]-[db-cluster-name]-[db-name]
84
- do-mysql-[account-name]-[db-cluster-name]-[db-name]
85
- do-mycli-[account-name]-[db-cluster-name]-[db-name]
86
- do-redis-[account-name]-[db-cluster-name]-[db-name]
84
+ do-[account-name]-ssh-[dashed-droplet-name]
85
+
86
+ do-[account-name]-psql-[db-cluster-name]-[db-name]
87
+ do-[account-name]-pgcli-[db-cluster-name]-[db-name]
88
+ do-[account-name]-pgdump-[db-cluster-name]-[db-name]
89
+
90
+ do-[account-name]-mysql-[db-cluster-name]-[db-name]
91
+ do-[account-name]-mycli-[db-cluster-name]-[db-name]
92
+ do-[account-name]-mysqldump-[db-cluster-name]-[db-name]
93
+
94
+ do-[account-name]-redis-[db-cluster-name]
87
95
  ```
88
96
 
89
97
  ### K8S aliases
@@ -94,26 +102,26 @@ Note: For K8S it will try to guess a pod name by removing the groups or random g
94
102
 
95
103
  ```
96
104
  # Switch current kubectl context
97
- k8s-switch-to-[account-name]-[cluster-name]
98
- k8s-switch-to-personal-k8s-01 # switch to cluster k8s-01 of the account
105
+ k8s-[account-name]-switch-to-[cluster-name]
106
+ k8s-personal-switch-to-k8s-01 # switch to cluster k8s-01 of the personal account
99
107
  k8s-switch-to-k8s-01 # switch to cluster k8s-01 of the default account
100
108
 
109
+ # Execute kubectl in a given cluster
110
+ k8s-[account-name]-ctl-[cluster-name]
111
+ k8s-personal-ctl-k8s-01 get pod --all-namespaces
112
+
101
113
  # Tail all pods in a namespace
102
114
  k8s-[account-name]-[cluster-name]-[namespace]-tail-all
103
115
 
104
116
  # Tail by pod name (prefix). Supported arguments:
105
- # -p - pod index (default: 1)
106
- # -c - container name (default: first found)
107
- # -n - number of initial lines (default: 10)
117
+ # --tail - number of initial lines (default: 10)
108
118
  k8s-[account-name]-[cluster-name]-[namespace]-tail-[pod-name]
109
119
 
110
120
  # Exec a shell in a specific pod. Supported arguments:
111
- # -p - pod index (default: 1)
112
- # -c - container name (default: first found)
113
- # -x - command to be executed (default: bash)
121
+ # --cmd - command to be executed (default: bash)
114
122
  k8s-[account-name]-[cluster-name]-[namespace]-exec-[-pod-name]
115
123
 
116
- # if there's a pod named console then it will run bundle exec rails console in that pod
124
+ # if there's a pod named console then it will run bundle exec rails console in that pod
117
125
  k8s-[account-name]-[cluster-name]-[namespace]-rails-console
118
126
  ```
119
127
 
@@ -72,11 +72,11 @@ module Cloud
72
72
  add_alias(:k8s, account, :switch, :to, cluster, kubectl("config use-context", cluster.context))
73
73
  add_alias(:k8s, account, :ctl, cluster, kubectl("--context #{cluster.context}"))
74
74
  cluster.pods.each do |namespace, pods|
75
- add_alias(:k8s, account, :tail, namespace, :all, "cloud-sh k8s tail --context #{cluster.context} --namespace #{namespace}")
75
+ add_alias(:k8s, account, :tail, cluster, namespace, :all, "cloud-sh k8s tail --context #{cluster.context} --namespace #{namespace}")
76
76
  pods.each do |pod|
77
- add_alias(:k8s, account, :tail, namespace, pod.name, "cloud-sh k8s tail --context #{cluster.context} --namespace #{namespace} --pod #{pod.name}") unless pod.name == "console"
78
- add_alias(:k8s, account, :exec, namespace, pod.name, "cloud-sh k8s exec --context #{cluster.context} --namespace #{namespace} --pod #{pod.name}")
79
- add_alias(:k8s, account, namespace, :rails, :console, "cloud-sh k8s exec --context #{cluster.context} --namespace #{namespace} --pod #{pod.name} --cmd 'bundle exec rails console'") if pod.name == "console"
77
+ add_alias(:k8s, account, :tail, cluster, namespace, pod.name, "cloud-sh k8s tail --context #{cluster.context} --namespace #{namespace} --pod #{pod.name}") unless pod.name == "console"
78
+ add_alias(:k8s, account, :exec, cluster, namespace, pod.name, "cloud-sh k8s exec --context #{cluster.context} --namespace #{namespace} --pod #{pod.name}")
79
+ add_alias(:k8s, account, cluster, namespace, :rails, :console, "cloud-sh k8s exec --context #{cluster.context} --namespace #{namespace} --pod #{pod.name} --cmd 'bundle exec rails console'") if pod.name == "console"
80
80
  end
81
81
  end
82
82
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Cloud
4
4
  module Sh
5
- VERSION = "1.0.0"
5
+ VERSION = "1.0.1"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloud-sh
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cristian Bica
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-08-30 00:00:00.000000000 Z
11
+ date: 2019-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gli