Skip to content

Commit 9ae0608

Browse files
authored
Merge pull request #8 from cdsl-research/future/v2
Apply patches to v2
2 parents 04aa6b3 + bb74a24 commit 9ae0608

File tree

9 files changed

+176
-55
lines changed

9 files changed

+176
-55
lines changed

.github/workflows/image-build.yml

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
name: Image Build
2+
13
on:
24
push:
35
branches:

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Environment Variables:
4545

4646
| Name | Default Value | Type | Description | Component |
4747
| --- | --- | --- | --- | --- |
48+
| HOSTS_PATH | `$PROJECT_ROOT/hosts.yml` | String | | crawler, dashboard, executor |
4849
| MONGO_USERNAME | | String | If this value is empty, ECoMan connects to MongoDB without authentication. | crawler, dashboard |
4950
| MONGO_PASSWORD | | String | | crawler, dashboard |
5051
| MONGO_DBNAME | ecoman | String | | crawler, dashboard |
@@ -64,4 +65,4 @@ ECoMan has following system archtiecture.
6465
- `dashboard` provides Web UI to Administrators. When Administrator accesses `dashboard`, it fetches VMs info from MongoDB and returns to Administrator.
6566
- `executor` receives actions, "Create VM" or "Update VM's power", from `dashboard` and does the actions via SSH.
6667

67-
<img src="assets/architecture.png">
68+
<img src="assets/architecture.png">

docs/install_kubernetes.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ kubectl config set-context --current --namespace=ecoman
1414
Create a secret
1515

1616
```
17-
kubectl create secret generic ecoman-ssh-keyfile --from-file=ssh/id_rsa
17+
kubectl create secret generic priv-key --from-file=ssh/id_rsa
1818
```
1919

2020
(3) Create a ConfigMap for hosts.yml
2121

2222
```
23-
kubectl create configmap ecoman-hosts-yml --from-file=hosts.yml
23+
kubectl create configmap hosts-config --from-file=hosts.example.yml
2424
```
2525

2626
(4) Apply manifests

kubernetes/crawler.yml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: crawler
5+
spec:
6+
replicas: 1
7+
selector:
8+
matchLabels:
9+
ecoman: crawler
10+
template:
11+
metadata:
12+
labels:
13+
ecoman: crawler
14+
spec:
15+
containers:
16+
- name: crawler-container
17+
image: cdsl-research/ecoman/crawler:v2.0.0
18+
volumeMounts:
19+
- name: privkey-volume
20+
mountPath: /keys
21+
readOnly: true
22+
- name: hosts-config-volume
23+
mountPath: /config
24+
readOnly: true
25+
env:
26+
- name: MONGO_USER
27+
value: mongo
28+
- name: MONGO_PASSWORD
29+
value: password
30+
- name: MONGO_HOST
31+
value: mongo-service
32+
- name: HOSTS_PATH
33+
value: /config/hosts.example.yaml
34+
volumes:
35+
- name: priv-key-volume
36+
secret:
37+
secretName: priv-key
38+
items:
39+
- key: id_rsa
40+
path: id_rsa
41+
mode: 0400
42+
- name: hosts-config-volume
43+
configMap:
44+
name: hosts-config

kubernetes/dashboard.yml

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: dashboard
5+
spec:
6+
replicas: 1
7+
selector:
8+
matchLabels:
9+
ecoman: dashboard
10+
template:
11+
metadata:
12+
labels:
13+
ecoman: dashboard
14+
spec:
15+
containers:
16+
- name: dashboard-container
17+
image: cdsl-research/ecoman/dashboard:v2.0.0
18+
volumeMounts:
19+
- name: hosts-config-volume
20+
mountPath: /config
21+
readOnly: true
22+
ports:
23+
- containerPort: 8000
24+
env:
25+
- name: MONGO_USER
26+
value: mongo
27+
- name: MONGO_PASSWORD
28+
value: password
29+
- name: MONGO_HOST
30+
value: mongo-service
31+
- name: EXECUTOR_ADDRESS
32+
value: executor-service
33+
- name: HOSTS_PATH
34+
value: /config/hosts.example.yaml
35+
volumes:
36+
- name: hosts-config-volume
37+
configMap:
38+
name: hosts-config
39+
---
40+
apiVersion: v1
41+
kind: Service
42+
metadata:
43+
name: dashboard-svc
44+
spec:
45+
type: NodePort
46+
ports:
47+
- name: "http-port"
48+
protocol: "TCP"
49+
port: 8000
50+
targetPort: 8000
51+
selector:
52+
ecoman: dashboard

kubernetes/ecoman.yaml

-52
This file was deleted.

kubernetes/executor.yml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: executor
5+
spec:
6+
replicas: 1
7+
selector:
8+
matchLabels:
9+
ecoman: executor
10+
template:
11+
metadata:
12+
labels:
13+
ecoman: executor
14+
spec:
15+
containers:
16+
- name: executor-container
17+
image: cdsl-research/ecoman/executor:v2.0.0
18+
volumeMounts:
19+
- name: privkey-volume
20+
mountPath: /keys
21+
readOnly: true
22+
- name: hosts-config-volume
23+
mountPath: /config
24+
readOnly: true
25+
ports:
26+
- containerPort: 8000
27+
env:
28+
- name: MONGO_USER
29+
value: mongo
30+
- name: MONGO_PASSWORD
31+
value: password
32+
- name: MONGO_HOST
33+
value: mongo-service
34+
- name: EXECUTOR_ADDRESS
35+
value: executor-service
36+
- name: HOSTS_PATH
37+
value: /config/hosts.example.yaml
38+
volumes:
39+
- name: priv-key-volume
40+
secret:
41+
secretName: priv-key
42+
items:
43+
- key: id_rsa
44+
path: id_rsa
45+
mode: 0400
46+
- name: hosts-config-volume
47+
configMap:
48+
name: hosts-config
49+
---
50+
apiVersion: v1
51+
kind: Service
52+
metadata:
53+
name: executor-svc
54+
spec:
55+
type: NodePort
56+
ports:
57+
- name: "http-port"
58+
protocol: "TCP"
59+
port: 8000
60+
targetPort: 8000
61+
selector:
62+
ecoman: executor

kubernetes/hosts.example.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
hoge:
2+
addr: "hoge.a910.tak-cslab.org"
3+
username: "root"
4+
identity_file_path: "/keys/id_rsa"
5+
datastore_path: "/vmfs/volumes/datastore1/"
6+
installer_iso_path: "/vmfs/volumes/datastore1/os-images/ubuntu2004.iso"
7+
network_port_group: "Management Network"

library/src/load_config.py

+5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def get_esxi_nodes() -> dict[str, HostsConfig]:
2424

2525
if os.environ.get("HOSTS_PATH"):
2626
HOSTS_PATH = str(os.environ.get("HOSTS_PATH"))
27+
parent_dir = os.path.dirname(HOSTS_PATH)
2728
else:
2829
dir_this_file = os.path.dirname(__file__)
2930
parent_dir = os.path.join(dir_this_file, "..")
@@ -37,6 +38,10 @@ def get_esxi_nodes() -> dict[str, HostsConfig]:
3738
for esxi_nodename, conf in hosts_config.items():
3839
print("Validating:", esxi_nodename)
3940
try:
41+
_path = conf["datastore_path"].endswith("/")
42+
if _path:
43+
conf["datastore_path"] = conf["datastore_path"][:-2]
44+
4045
hosts_conf = HostsConfig(**conf)
4146
hosts_conf.identity_file_path = os.path.join(
4247
parent_dir, hosts_conf.identity_file_path

0 commit comments

Comments
 (0)