Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add undeploy #25

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker/WasmEdge/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ FROM ubuntu:18.04 as wasm_serverless
LABEL maintainers="ActivePeter"
LABEL description="Wasm serverless platform"

RUN apt-get update && apt-get install -y python3 python3-pip git && mkdir -p /tmp/install
RUN apt-get update && apt-get install -y python3 python3-pip git iproute2 iputils-ping && mkdir -p /tmp/install
# COPY --from=builder /root/.wasmedge /root/.wasmedge
COPY wasm_edge.py /tmp/install/wasm_edge.py
COPY WasmEdge-0.13.3-manylinux2014_x86_64.tar.gz /tmp/install/WasmEdge-0.13.3-manylinux2014_x86_64.tar.gz
Expand Down
6 changes: 6 additions & 0 deletions docker/WasmServerless/wasm_serverless_entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
echo "Node id: ${WASM_SERVERLESS_NODEID}"
echo "Who am i: $(whoami)"

# tc qdisc add dev eth0 root netem delay 100ms

# tc qdisc add dev eth0 root tbf rate 1mbit burst 10kb latency 70ms

timeout 10 ping baidu.com

cd /usr/local/bin/
ls /etc/wasm_serverless/

Expand Down
1 change: 1 addition & 0 deletions scripts/deploy_cluster/3.undeploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ansible-playbook -vv scripts/deploy_cluster/ans_undeploy_cluster.yml -i scripts/deploy_cluster/gen_ansible.ini
4 changes: 3 additions & 1 deletion scripts/deploy_cluster/_gen_each_node_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def read_yaml(file_path):

def generate_docker_compose(ip, nodes):
services = {}

for key, node in nodes.items():
service_name = f"node{key}"

Expand All @@ -35,7 +36,8 @@ def generate_docker_compose(ip, nodes):
'volumes': ['/root/wasm_serverless_deploy:/etc/wasm_serverless/config'],
'environment': {
'WASM_SERVERLESS_NODEID': key
}
},
'privileged': True # for tc control
}

compose_data = {'version': '3', 'services': services}
Expand Down
25 changes: 25 additions & 0 deletions scripts/deploy_cluster/ans_undeploy_cluster.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
- hosts: web
vars:
container_whitelist:
- "portainer"

tasks:
- name: 获取所有运行中的容器
command: docker ps -q
register: running_containers
ignore_errors: true

- name: 关闭非白名单中的容器
docker_container:
name: "{{ item }}"
state: stopped
with_items: "{{ running_containers.stdout_lines }}"
when: item not in container_whitelist and running_containers.stdout_lines|length > 0

- name: 删除非白名单中的容器
docker_container:
name: "{{ item }}"
state: absent
with_items: "{{ running_containers.stdout_lines }}"
when: item not in container_whitelist and running_containers.stdout_lines|length > 0
Loading