diff --git a/tools/merak-aca-container/Dockerfile b/tools/merak-aca-container/Dockerfile new file mode 100644 index 0000000..6f111d5 --- /dev/null +++ b/tools/merak-aca-container/Dockerfile @@ -0,0 +1,14 @@ +FROM ubuntu:18.04 +RUN apt update +RUN apt upgrade -y +RUN apt install -y git +RUN apt install -y wget +RUN apt install -y uuid +RUN apt-get install -y uuid-dev +RUN apt install -y openvswitch-switch=2.9.8-0ubuntu0.18.04.2 + +RUN git clone --recurse-submodules https://github.com/futurewei-cloud/alcor-control-agent.git /root/alcor-control-agent + +ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/ +RUN /root/alcor-control-agent/build/aca-machine-init.sh +CMD sh /root/alcor-control-agent/build/aca_container/aca_run.sh diff --git a/tools/merak-aca-container/README.md b/tools/merak-aca-container/README.md new file mode 100644 index 0000000..6482526 --- /dev/null +++ b/tools/merak-aca-container/README.md @@ -0,0 +1,48 @@ +# How to build ACA image and run it in docker/k8s + +Use the bellow command to build image +``` +docker build --no-cache -f Dockerfile -t aca_build . +``` + +After Build we can rename(tag) it, no need to do, unless upload to dockerhub: +``` +docker tag / +``` +To upload image to Dockerhub: +``` +docker push / +``` + +To download image to physical machines: +``` +docker pull / +``` + +To run the docer image in container: +``` +docker container run -d -it --cap-add=NET_ADMIN --cap-add=SYS_PTRACE --privileged --security-opt seccomp=unconfined --name / /bin/bash +``` + +To Login to the Docker container: +``` +docker exec -u 0 -it /bin/bash +``` + +___ + +## For k8s +To run the above aca image in K8s, we need to run the folling command on all k8s nodes. +``` +docker pull / +``` + +Then we can use the bellow yaml file to create ACA pods in k8s: +``` +Kubectl create -f aca_k8s.yaml +``` + +To get into ACA pod: +``` +kubectl exec --stdin --tty -- /bin/bash +``` diff --git a/tools/merak-aca-container/aca_k8s.yaml b/tools/merak-aca-container/aca_k8s.yaml new file mode 100644 index 0000000..f2d424b --- /dev/null +++ b/tools/merak-aca-container/aca_k8s.yaml @@ -0,0 +1,24 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: aca-deployment +spec: + selector: + matchLabels: + app: aca + replicas: 1 # tells deployment to run 2 pods matching the template + template: + metadata: + labels: + app: aca + spec: + # hostPID: true + containers: + - name: aca + image: aca_image + command: ["/bin/sh","-c"] + args: ["service rsyslog restart && /etc/init.d/openvswitch-switch restart && /root/alcor-control-agent/build/bin/AlcorControlAgent -d -a 10.213.43.251 -p 30014"] + securityContext: + privileged: true + ports: + - containerPort: 50001 \ No newline at end of file