samanbayaka 0.0.16 → 0.0.17
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.
- package/README.md +2 -1
- package/commit-hash.mjs +1 -1
- package/docs/dockers/etcd.md +126 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -438,7 +438,8 @@ node demo.mjs
|
|
|
438
438
|
|
|
439
439
|
## Documentation
|
|
440
440
|
|
|
441
|
-
|
|
441
|
+
* [Dockers]
|
|
442
|
+
* [etcd](docs/dockers/etcd.md)
|
|
442
443
|
|
|
443
444
|
<p align="center" style="margin-top: 100px;">
|
|
444
445
|
<img src="https://moleculer.services/images/banner.png" alt="Moleculer Logo" width="600">
|
package/commit-hash.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const COMMIT_HASH = '
|
|
1
|
+
export const COMMIT_HASH = '7052c65';
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# Dockers
|
|
2
|
+
## Etcd
|
|
3
|
+
To manage configurations centrally, use the docker-compose.yml file to run Etcd.
|
|
4
|
+
```bash
|
|
5
|
+
mkdir -p etcd
|
|
6
|
+
cd etcd
|
|
7
|
+
touch docker-compose.yml
|
|
8
|
+
export ETCD_ROOT_PW=<your_root_pass>
|
|
9
|
+
export ETCD_CONFIG_ADMIN_PW=<your_config_admin_pass>
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Open `docker-compose.yml` and paste the following:
|
|
13
|
+
```yml
|
|
14
|
+
services:
|
|
15
|
+
etcd:
|
|
16
|
+
image: quay.io/coreos/etcd:v3.5.5
|
|
17
|
+
container_name: sbk-etcd
|
|
18
|
+
|
|
19
|
+
ports:
|
|
20
|
+
- "<your_api_port>:2379"
|
|
21
|
+
- "<your_cluster_port>:2380"
|
|
22
|
+
|
|
23
|
+
volumes:
|
|
24
|
+
- /usr/local/etc/samanbayaka:/etcd-data
|
|
25
|
+
|
|
26
|
+
command:
|
|
27
|
+
- /usr/local/bin/etcd
|
|
28
|
+
- --name=etcd
|
|
29
|
+
- --data-dir=/etcd-data
|
|
30
|
+
- --listen-client-urls=http://0.0.0.0:2379
|
|
31
|
+
- --advertise-client-urls=http://etcd:2379
|
|
32
|
+
- --listen-peer-urls=http://0.0.0.0:2380
|
|
33
|
+
- --initial-advertise-peer-urls=http://etcd:2380
|
|
34
|
+
- --initial-cluster=etcd=http://etcd:2380
|
|
35
|
+
- --initial-cluster-state=new
|
|
36
|
+
|
|
37
|
+
restart: unless-stopped
|
|
38
|
+
|
|
39
|
+
etcd-init:
|
|
40
|
+
image: quay.io/coreos/etcd:v3.5.5
|
|
41
|
+
depends_on:
|
|
42
|
+
- etcd
|
|
43
|
+
|
|
44
|
+
volumes:
|
|
45
|
+
- /usr/local/etc/samanbayaka:/etcd-data
|
|
46
|
+
|
|
47
|
+
environment:
|
|
48
|
+
- ETCDCTL_API=3
|
|
49
|
+
|
|
50
|
+
entrypoint:
|
|
51
|
+
- /bin/sh
|
|
52
|
+
- -c
|
|
53
|
+
|
|
54
|
+
command:
|
|
55
|
+
- |
|
|
56
|
+
set -e
|
|
57
|
+
|
|
58
|
+
echo "waiting for etcd..."
|
|
59
|
+
|
|
60
|
+
for i in $(seq 1 30); do
|
|
61
|
+
etcdctl --endpoints=http://etcd:2379 endpoint health && break
|
|
62
|
+
echo "retry $$i..."
|
|
63
|
+
sleep 2
|
|
64
|
+
done
|
|
65
|
+
|
|
66
|
+
echo "etcd initialized"
|
|
67
|
+
|
|
68
|
+
echo "Creating the root role"
|
|
69
|
+
etcdctl --endpoints=http://etcd:2379 role add root || true
|
|
70
|
+
|
|
71
|
+
echo "Creating the root user"
|
|
72
|
+
etcdctl --endpoints=http://etcd:2379 user add root:${ETCD_ROOT_PW} || true
|
|
73
|
+
|
|
74
|
+
echo "Granting the root role to the root user"
|
|
75
|
+
etcdctl --endpoints=http://etcd:2379 user grant-role root root
|
|
76
|
+
|
|
77
|
+
echo "Enable authentication"
|
|
78
|
+
etcdctl --endpoints=http://etcd:2379 auth enable || true
|
|
79
|
+
|
|
80
|
+
# -------------------------------------------------------
|
|
81
|
+
|
|
82
|
+
echo "Creating admin role"
|
|
83
|
+
etcdctl --endpoints=http://etcd:2379 --user=root:${ETCD_ROOT_PW} role add admin
|
|
84
|
+
|
|
85
|
+
echo "Granting broad permissions"
|
|
86
|
+
etcdctl --endpoints=http://etcd:2379 --user=root:${ETCD_ROOT_PW} role grant-permission --prefix=true admin readwrite /
|
|
87
|
+
|
|
88
|
+
echo "Creating configadmin user"
|
|
89
|
+
etcdctl --endpoints=http://etcd:2379 --user=root:${ETCD_ROOT_PW} user add configadmin:${ETCD_CONFIG_ADMIN_PW}
|
|
90
|
+
|
|
91
|
+
echo "Assign role"
|
|
92
|
+
etcdctl --endpoints=http://etcd:2379 --user=root:${ETCD_ROOT_PW} user grant-role configadmin admin
|
|
93
|
+
|
|
94
|
+
# ---------------------------------------------------------
|
|
95
|
+
|
|
96
|
+
echo "Creating Roles and Granting"
|
|
97
|
+
etcdctl --endpoints=http://etcd:2379 --user=root:${ETCD_ROOT_PW} role add gateway
|
|
98
|
+
etcdctl --endpoints=http://etcd:2379 --user=root:${ETCD_ROOT_PW} role grant-permission --prefix=true gateway read /config/yaml/nats
|
|
99
|
+
etcdctl --endpoints=http://etcd:2379 --user=root:${ETCD_ROOT_PW} role grant-permission --prefix=true gateway read /config/yaml/auth
|
|
100
|
+
etcdctl --endpoints=http://etcd:2379 --user=root:${ETCD_ROOT_PW} role grant-permission --prefix=true gateway read /config/yaml/catch
|
|
101
|
+
etcdctl --endpoints=http://etcd:2379 --user=root:${ETCD_ROOT_PW} role grant-permission --prefix=true gateway read /config/yaml/telemetry
|
|
102
|
+
|
|
103
|
+
# ---------------------------------------------------------
|
|
104
|
+
|
|
105
|
+
echo "Creating User and Assign Role"
|
|
106
|
+
etcdctl --endpoints=http://etcd:2379 --user=root:${ETCD_ROOT_PW} user add <your_user>:<your_pass>
|
|
107
|
+
etcdctl --endpoints=http://etcd:2379 --user=root:${ETCD_ROOT_PW} user grant-role apigtwy gateway
|
|
108
|
+
|
|
109
|
+
# ---------------------------------------------------------
|
|
110
|
+
|
|
111
|
+
etcdctl --endpoints=http://etcd:2379 --user=configadmin:${ETCD_CONFIG_ADMIN_PW} put /config/yaml/nats "$(cat /etcd-data/nats.yml)" || true
|
|
112
|
+
|
|
113
|
+
#etcdctl --endpoints=http://etcd:2379 --user=<your_user>:<your_pass> get /config/yaml/nats
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
echo "etcd initialization completed"
|
|
117
|
+
```
|
|
118
|
+
Optionally verify:
|
|
119
|
+
```bash
|
|
120
|
+
docker ps | grep 'sbk-etcd'
|
|
121
|
+
```
|
|
122
|
+
Optionally check health:
|
|
123
|
+
```bash
|
|
124
|
+
docker exec sbk-etcd etcdctl --endpoints=http://etcd:2379 endpoint health
|
|
125
|
+
```
|
|
126
|
+
---
|