container-agent 업데이트

This commit is contained in:
ByeonJungHun
2024-04-17 13:43:48 +09:00
parent aa5d5f6ad0
commit 0a12083230
13 changed files with 101 additions and 7 deletions

View File

@@ -11,4 +11,4 @@
#RECEIVER_CONTAINER_PORT: 9009
# port 설정이 필요할 경우 위 주석을 해제하고 설정
# RECEIVER_PORT 와 RECEIVER_CONTAINER_PORT 같은 경우 변수를 설정하지 않을 경우 default 값으로 각각 9010 , 9009 으로 설정 됨
agent_list: ['host-agent']
agent_list: ['container-agent']

View File

@@ -3,10 +3,9 @@ host_agent
container_agent
[host_agent]
10.10.54.151
10.10.54.152
10.10.54.153
[container_agent]
10.10.54.105
10.10.54.150
[ndm_agent]

View File

@@ -0,0 +1,7 @@
#!/bin/sh
PRODUCT_NAME=exemONE
MODULE_NAME=exem-container-agent
VERSION=1.1.2
echo ${PRODUCT_NAME} ${MODULE_NAME} ver ${VERSION}

View File

@@ -0,0 +1,16 @@
#!/bin/sh
docker load -i __INST__EXEM_HOME__/container/image/exem-container-agent_image_1.1.2.tar
docker run -d \
--cap-add SYS_PTRACE \
--restart=always \
-v /:/host:ro \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
-v /run/containerd/containerd.sock:/run/containerd/containerd.sock:ro \
--env EXEM_HOME="__INST__EXEM_HOME__" \
--env EXEM_CONTAINER_HOME="__INST__EXEM_HOME__/container" \
--env COMMON_RECEIVER_IP="__INST__RECEIVER_IP__" \
--env COMMON_RECEIVER_PORT="__INST__RECEIVER_PORT__" \
--env CONTAINER_LOG_LEVEL="info" \
--name exem-container-agent exem-container-agent:1.1.2

View File

@@ -0,0 +1,4 @@
#!/bin/sh
docker stop exem-container-agent
docker rm exem-container-agent

View File

@@ -0,0 +1,25 @@
#!/bin/sh
SYSTEMCTL=$(which systemctl 2> /dev/null)
SERVICE=$(which service 2> /dev/null)
CHKCONFIG=$(which chkconfig 2> /dev/null)
if [ -n "${SYSTEMCTL}" ]; then
systemctl stop exem-container-agent
systemctl disable exem-container-agent
systemctl daemon-reload
if [ -e "/etc/systemd/system/exem-container-agent.service" ]; then
rm -f /etc/systemd/system/exem-container-agent.service
systemctl daemon-reload
fi
if [ -e "/etc/systemd/system/default.target.wants/exem-container-agent.service" ]; then
rm -f /etc/systemd/system/default.target.wants/exem-container-agent.service
systemctl daemon-reload
fi
echo "exem-container-agent is disabled"
fi

View File

@@ -0,0 +1,35 @@
#!/bin/sh
SYSTEMCTL=$(which systemctl 2> /dev/null)
SERVICE=$(which service 2> /dev/null)
CHKCONFIG=$(which chkconfig 2> /dev/null)
# root 권한 없는 경우 불가능
if [ "$(id -u)" -ne 0 ]; then
echo "Not a root user. Not support service registration"
echo "Use binary mode or image mode"
exit 1
fi
if [ -n "${SYSTEMCTL}" ]; then
# SELinux setting
SELINUX_OPTION=$(awk -F= '/^SELINUX=/{print $2}' /etc/selinux/config)
if [ ${SELINUX_OPTION} != "disabled" ]; then
chcon -t bin_t __INST__EXEM_HOME__/container/script/binary_mode/start.sh
chcon -R -t var_run_t __INST__EXEM_HOME__/container/data
fi
if [ ! -e "/etc/systemd/system/exem-container-agent.service" ]; then
systemctl enable __INST__EXEM_HOME__/container/data/service/exem-container-agent.service
fi
systemctl daemon-reload
echo "exem-container-agent is enabled"
else
echo "this OS version that does not support service registration"
echo "Use binary mode or image mode"
exit 1
fi

View File

@@ -0,0 +1,3 @@
#!/bin/sh
sudo systemctl start exem-container-agent

View File

@@ -0,0 +1,5 @@
#!/bin/sh
sudo __INST__EXEM_HOME__/container/script/binary_mode/stop.sh
sudo systemctl stop exem-container-agent

View File

@@ -14,11 +14,11 @@
- name: Create Agent Script
ansible.builtin.template:
src: "{{ item }}.j2"
dest: "{{ EXEM_HOME }}/container/{{ item }}"
dest: "{{ EXEM_HOME }}/container/script/binary_mode/{{ item }}"
mode: '0755'
with_items:
- start.sh
- stop.sh
- name: exem-container-agent start
ansible.builtin.shell: "nohup {{ EXEM_HOME }}/container/start.sh"
ansible.builtin.shell: "nohup {{ EXEM_HOME }}/container/script/binary_mode/start.sh"

View File

@@ -34,7 +34,7 @@
ansible.builtin.copy:
src: "{{ EXEM_HOME }}/host/os_binary/exem-host-agent_linux-2.6-x86_64-64"
dest: "{{ EXEM_HOME }}/host/bin/exem-host-agent"
# remote_src: yes
remote_src: yes
mode: '0755'
- name: Setting SELinux