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 +4 -4
- data/README.md +37 -29
- data/lib/cloud/sh/commands/refresh.rb +4 -4
- data/lib/cloud/sh/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d542846c4ade970de1b85af0ea33def7b5c4d373c82e70b33e961f3cfbb6c51
|
4
|
+
data.tar.gz: cb699d91552a1174d7e424d20e5be9767b575be019bb62bc25293fdad3c91414
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
-
|
20
|
-
|
21
|
-
-
|
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
|
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
|
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
|
-
|
66
|
+
|
67
|
+
Setup a cron job to generate aliases:
|
65
68
|
|
66
69
|
```
|
67
|
-
|
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-
|
82
|
-
|
83
|
-
do-
|
84
|
-
do-
|
85
|
-
do-
|
86
|
-
|
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-
|
98
|
-
k8s-switch-to-
|
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
|
-
#
|
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
|
-
#
|
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
|
-
|
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
|
data/lib/cloud/sh/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2019-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gli
|