반응형

log4j 취약점 사태에 따라서 프로젝트에 log4j 라이브러리를 변경해야 했다.

실제 프로젝트에서는 logback 을 사용중이었고 boot 버전은 2.2.4를 사용하고 있었고 spring-boot-starter-logging 을 사용중이었다.  이 라이브러리의 dependency 는 아래와 같다.

ch.qos.logback » logback-classic 1.2.3 
org.apache.logging.log4j » log4j-to-slf4j 2.12.1
org.slf4j » jul-to-slf4j 1.7.30
출처 : https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-logging/2.2.4.RELEASE

 

1. sping-boot-starter-logging 을 제외하고 log4j 라이브러리를 추가했다.

configurations {
    all {
        exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
    }
}

dependencies{
    compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.15.0'
    compile group: 'org.apache.logging.log4j', name: 'log4j-to-slf4j', version: '2.15.0'
    .....
}

그리고 나서 어플리케이션을 실행시켜보니 다음과 같은 로그가 남았다.

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.2.4.RELEASE)

SLF4J: Failed to load class "org.slf4j.impl.StaticMDCBinder".
SLF4J: Defaulting to no-operation MDCAdapter implementation.
SLF4J: See http://www.slf4j.org/codes.html#no_static_mdc_binder for further details.

처음에는 어플리케이션이 실행이 안된건줄 알았는데 알고보니 로그가 안올라간것이었다. 그럼 왜 로그가 안나오는것일까??

일단 정확하지는 않지만 확인해본 바로는 프로젝트에서는 logback 을 사용중이었는데 sping-boot-starter-logging 라이브러리를 제외하는 바람에 logback 관련 라이브러리가 dependency 에 추가지되 않아서라는 추측을 하게 되었다. 

2. 로그백 라이브러리 추가

dependencies{
	implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.7'
    implementation group: 'ch.qos.logback', name: 'logback-core', version: '1.2.7'
    ....
}

위와같이 로그백 라이브러리를 추가했다. 어플리케이션은 정상적으로 기동이 됐다. 그런데 다른 로컬 PC 에서 다시 SLF4J 관련 메세지가 나서 다시 수정을 했다.

3. sping-boot-starter-logging 제외 취소하고 log4j 만 추가.

configurations {
    all {
        exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
    }
}

1번에서 추가했던 위 부분을 삭제하고 2번에 추가했던 로그백 라이브러리도 삭제를 했다. 결과적으로는 log4j 라이브러리만 추가된 상황이다. 실제로 dependency를 확인해보면 다음과 같이 변경이 되어있다.

Gradle: org.apache.logging.log4j:log4j-api:2.15.0
Gradle: org.apache.logging.log4j:log4j-to-slf4j:2.15.0

어플리케이션도 정상적으로 잘 기동이 되었다.

이것때문에 구글에서 SLF4J 관련해서 계속 검색 하면서 삽질했는데 간단하게 해결이 됐다. ㅠㅠ 

 

728x90
반응형
반응형

https://openinfradays.kr/session/10

 

OpenInfra Community Days Korea 2021

손석호 Speaker's bio 한국전자통신연구원(ETRI)에서 클라우드 컴퓨팅을 연구하며, Kubernetes와 Cloud-Barista 등의 오픈소스에 기여하고 있습니다. [Kubernetes] - SIG-Docs Korean Localization Team Leader - Kubernetes/websi

openinfradays.kr

위 영상을 보면서 간략하게 메모한 내용입니다.
 
Github contribute Workflow

Upstream Repository -> Origin Repository -> Local Repository -> Working copy

1. Fork : Upstream Repository 에서 Fork 받으면  Origin Repository 로 이동
2. Clone : Origin Repository 에서 Local Repository 로 이동
3. git remote add upstream (upstream repository 를 알수 있도록 설정)
4. git fetch upstream
5. git checkout 현재_최신_브랜치
6. feature 브랜치 생성해서 작업 진행후 commit
8. git fetch upstream (내가 작업하는 도중에 변경되는것을 확인하기 위해)
9. git rebase upstream/현재_최신_브랜치
7. local -> origin 으로 push (본인 저장소)
8. Pull Request 생성

 

 

728x90
반응형

'Development > Git' 카테고리의 다른 글

git cherry pick  (0) 2024.01.05
다른 브랜치에서 pull 하면 어떻게 될까???  (0) 2020.12.07
github page 에 테마 설치  (0) 2020.10.20
github 에 page 만들기  (0) 2020.10.15
Git local, remote branch 삭제  (0) 2020.09.08
반응형

docker 실행시 컨테이너 내부에서 컨테이너 외부 파일을 연결할수 있는 방법이 있다.

docker run 실행시 -v [호스트경로]:[컨테이너경로] 를 추가해주면 호스트 경로와 컨테이너 경로가 연결되게 된다. 한가지 중요한 점은 호스트 경로의 상태가 컨테이너 경로에 덮어써진다는 것이다. 

➜  docker docker run --name nginx-mounts -d -p 8081:80 -v /Users/Workspaces/docker:/usr/share/nginx/html nginx
Unable to find image 'nginx:latest' locally
latest: Pulling from library/nginx
7d63c13d9b9b: Pull complete 
15641ef07d80: Pull complete 
392f7fc44052: Pull complete 
8765c7b04ad8: Pull complete 
8ddffa52b5c7: Pull complete 
353f1054328a: Pull complete 
Digest: sha256:dfef797ddddfc01645503cef9036369f03ae920cac82d344d58b637ee861fda1
Status: Downloaded newer image for nginx:latest
f1aa047705f563a0db1f76abbadddf74ea2fff7542e55601a84eccf43dc207b4
➜  docker curl localhost:8081                          
<html>
<head><title>403 Forbidden</title></head>
<body>
<center><h1>403 Forbidden</h1></center>
<hr><center>nginx/1.21.4</center>
</body>
</html>

위에서는 docker를 실행할 때 /Users/Workspaces/docker 경로를 컨테이너 안에 /usr/share/nginx/html 에 바인드 시켰다. 기본적으로 nginx의 /usr/share/nginx/html 경로에는 index.html 파일이 존재하지만 현재 호스트의 /Users/Workspaces/docker 경로에는 아무것도 없는 빈 디렉토리이기 때문에 403 이 나온다.

 

728x90
반응형
반응형

시스템의 mac 주소를 확인할때 사용한다. 

root@myserver-001:~# arp
Address                  HWtype  HWaddress           Flags Mask            Iface
10.32.0.2                ether   e2:be:6b:98:75:27   C                     weave
10.32.0.3                ether   c2:2b:4a:0f:0b:5b   C                     weave
10.36.0.1                ether   02:84:38:18:ac:31   C                     weave
10.36.0.2                ether   8e:21:c9:42:d3:da   C                     weave
10.36.0.3                ether   a2:7f:5e:83:5b:c4   C                     weave
10.44.0.4                ether   2a:54:11:6b:1f:fe   C                     weave
10.44.0.5                ether   b6:bb:2c:98:2b:7b   C                     weave
_gateway                 ether   02:50:56:56:44:52   C                     ens160
192.168.0.2                      (incomplete)                              ens160
myserver-002             ether   00:50:56:99:e5:ba   C                     ens160
10.44.0.1                ether   46:bf:dd:bc:51:8a   C                     weave
192.168.30.18                    (incomplete)                              docker0
10.44.0.2                ether   e6:4a:dc:2d:f4:e7   C                     weave
myserver-003             ether   00:50:56:99:1e:4d   C                     ens160
10.44.0.3                ether   96:38:40:ba:ac:a0   C                     weave

다음과 같이 뒤에 host 명을 붙여주면 해당 host 의 정보만 출력한다.

root@myserver-001:~# arp myserver-002
Address                  HWtype  HWaddress           Flags Mask            Iface
myserver-002             ether   00:50:56:99:e5:ba   C                     ens160

 

728x90
반응형

'Development > Linux' 카테고리의 다른 글

xargs 명령어  (0) 2024.01.17
[리눅스 명령어] nohup  (0) 2021.06.09
[리눅스 명령어] 디스크 관련 명령어  (0) 2021.06.04
파일 찾기, 파일 날짜별 삭제  (0) 2021.05.21
[리눅스 명령어] IP 관련 명령어  (0) 2021.03.08
반응형

1. docker inspect container_id
명령어를 치면 굉장히 많은 정보를 확인할 수 있다. 그래서 grep 으로 조회하면 좀 수월하다.
docker inspect container_id | grep IP

"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "192.168.0.1",
"IPPrefixLen": 16,
"IPv6Gateway": "",
        "IPAMConfig": null,
        "IPAddress": "192.168.0.1",
        "IPPrefixLen": 16,
        "IPv6Gateway": "",
        "GlobalIPv6Address": "",
        "GlobalIPv6PrefixLen": 0,

2. docker exec -it container_id /bin/bash
위 명령어를 사용하면 컨테이너 내부로 접속이 가능하다. 내부로 접속을 해서 ip addr 이나 ifconfig, hostname -I 등을 사용해서 확인 가능하다. 

3. docker exec container_id command
exec 만 사용을 하고 후에 명령어를 치면 컨테이너 내부에 명령어를 보내 실행이 가능하다. 

 

728x90
반응형
반응형

간단한(?) Ping 테스트.

- inventory 파일 정보
[workers]
worker1 ansible_host=192.168.0.12 ansible_user=root
worker2 ansible_host=192.168.0.14 ansible_user=root

- ping을 쏴보자. (-m 옵션은 module 이라는 의미)
ansible workers -m ping
당연히 될줄 알았으나 Error 발생

worker1 | FAILED! => {
    "msg": "to use the 'ssh' connection type with passwords, you must install the sshpass program"
}
worker2 | FAILED! => {
    "msg": "to use the 'ssh' connection type with passwords, you must install the sshpass program"
}

sshpass 프로그램이 없다고 하길래 sshpass 프로그램을 설치했다.
apt install sshpass.

그리고 다시 시도!. 그리고 다시 Error

worker1 | FAILED! => {
    "changed": false, 
    "module_stderr": "Shared connection to 192.168.0.12 closed.\r\n", 
    "module_stdout": "/bin/sh: 1: /usr/bin/python: not found\r\n", 
    "msg": "MODULE FAILURE", 
    "rc": 127
}

python 이 없다고 나옴. 생각해보니 master 에 ansible 만 설치했지 다른 노드에는 아무것도 안한 상태였다. 그래서 각각의 노드에 python 을 설치했다. (apt install python)

그리고 나서 다시 했더니 다음과 같은 Error 가 나온다.

worker1 | UNREACHABLE! => {
    "changed": false, 
    "msg": "Failed to connect to the host via ssh: root@192.168.0.12: Permission denied (publickey,password).\r\n", 
    "unreachable": true
}
worker2 | UNREACHABLE! => {
    "changed": false, 
    "msg": "Failed to connect to the host via ssh: root@192.168.0.14: Permission denied (publickey,password).\r\n", 
    "unreachable": true
}

흠... 패스워드 문제인것 같아서 옵션을 줘보고 실행을 해봤다.

ansible all -m ping -k

-k : 이 옵션은 실행시에 password 를 물어보도록 하는 옵션이다.
이렇게 실행을 했더니 정상적으로 실행이 되었다. 

root@myserver-001:~# ansible all -m ping -k
SSH password: 
worker1 | SUCCESS => {
    "changed": false, 
    "ping": "pong"
}
worker2 | SUCCESS => {
    "changed": false, 
    "ping": "pong"
}

 

728x90
반응형

'Development > Ansible' 카테고리의 다른 글

Ansible Inventory 파일  (0) 2021.11.12
반응형

호스트 파일에는 목적지 노드의 정보를 담고 있다. 

1. 파일 위치 : /etc/ansible/hosts (설치위치에 따라 달라질수는 있다.) 
실제로 ansible.cfg 파일을 보면 다음과 같이 default 로 정의되어있다.
# some basic default values...
#inventory      = /etc/ansible/hosts

2. 사용 방법

test test.com

[test]
test.com

[web]
web1.com
web2.com

[db]
db.com

[mail]
mail.com

[workers]
worker1 ansible_host=192.168.0.12 ansible_user=root 
worker2 ansible_host=192.168.0.14 ansible_user=root 

[all_servers:children]
test
web
db
mail

- test test.com : test 는 alias 이며 test.com 이 실제 접속 주소이다.
- [] : [] 으로 표현된 부분은 group 이름이다. 
- ansible_user : 각각의 노드에 user 가 다를 경우 ansible_user 로 정의 해준다.
- [그룹명:children] : 그룹들로 서로 묶을 수 있다.

 

728x90
반응형

'Development > Ansible' 카테고리의 다른 글

Ansible Ping 테스트 해보자.  (0) 2021.11.12
반응형

history 명령어를 통해서 이미지가 어떤 과정을 거쳐 생성되었는지 확인해볼수 있다.

아래와 같이 nginx 의 latest 이미지와 stable 이미지에 대한 내역을 비교해볼수 있다.

root@myserver-001:~# docker history nginx:stable
IMAGE          CREATED       CREATED BY                                      SIZE      COMMENT
c8d03f6b8b91   4 weeks ago   /bin/sh -c #(nop)  CMD ["nginx" "-g" "daemon…   0B        
<missing>      4 weeks ago   /bin/sh -c #(nop)  STOPSIGNAL SIGQUIT           0B        
<missing>      4 weeks ago   /bin/sh -c #(nop)  EXPOSE 80                    0B        
<missing>      4 weeks ago   /bin/sh -c #(nop)  ENTRYPOINT ["/docker-entr…   0B        
<missing>      4 weeks ago   /bin/sh -c #(nop) COPY file:09a214a3e07c919a…   4.61kB    
<missing>      4 weeks ago   /bin/sh -c #(nop) COPY file:0fd5fca330dcd6a7…   1.04kB    
<missing>      4 weeks ago   /bin/sh -c #(nop) COPY file:0b866ff3fc1ef5b0…   1.96kB    
<missing>      4 weeks ago   /bin/sh -c #(nop) COPY file:65504f71f5855ca0…   1.2kB     
<missing>      4 weeks ago   /bin/sh -c set -x     && addgroup --system -…   63.9MB    
<missing>      4 weeks ago   /bin/sh -c #(nop)  ENV PKG_RELEASE=1~buster     0B        
<missing>      4 weeks ago   /bin/sh -c #(nop)  ENV NJS_VERSION=0.5.3        0B        
<missing>      4 weeks ago   /bin/sh -c #(nop)  ENV NGINX_VERSION=1.20.1     0B        
<missing>      4 weeks ago   /bin/sh -c #(nop)  LABEL maintainer=NGINX Do…   0B        
<missing>      4 weeks ago   /bin/sh -c #(nop)  CMD ["bash"]                 0B        
<missing>      4 weeks ago   /bin/sh -c #(nop) ADD file:910392427fdf089bc…   69.3MB    

root@myserver-001:~# docker history nginx:latest
IMAGE          CREATED        CREATED BY                                      SIZE      COMMENT
04661cdce581   45 hours ago   /bin/sh -c #(nop)  CMD ["nginx" "-g" "daemon…   0B        
<missing>      45 hours ago   /bin/sh -c #(nop)  STOPSIGNAL SIGQUIT           0B        
<missing>      45 hours ago   /bin/sh -c #(nop)  EXPOSE 80                    0B        
<missing>      45 hours ago   /bin/sh -c #(nop)  ENTRYPOINT ["/docker-entr…   0B        
<missing>      45 hours ago   /bin/sh -c #(nop) COPY file:09a214a3e07c919a…   4.61kB    
<missing>      45 hours ago   /bin/sh -c #(nop) COPY file:0fd5fca330dcd6a7…   1.04kB    
<missing>      45 hours ago   /bin/sh -c #(nop) COPY file:0b866ff3fc1ef5b0…   1.96kB    
<missing>      45 hours ago   /bin/sh -c #(nop) COPY file:65504f71f5855ca0…   1.2kB     
<missing>      45 hours ago   /bin/sh -c set -x     && addgroup --system -…   61.1MB    
<missing>      45 hours ago   /bin/sh -c #(nop)  ENV PKG_RELEASE=1~bullseye   0B        
<missing>      45 hours ago   /bin/sh -c #(nop)  ENV NJS_VERSION=0.7.0        0B        
<missing>      45 hours ago   /bin/sh -c #(nop)  ENV NGINX_VERSION=1.21.4     0B        
<missing>      45 hours ago   /bin/sh -c #(nop)  LABEL maintainer=NGINX Do…   0B        
<missing>      4 weeks ago    /bin/sh -c #(nop)  CMD ["bash"]                 0B        
<missing>      4 weeks ago    /bin/sh -c #(nop) ADD file:16dc2c6d1932194ed…   80.4MB

 

728x90
반응형
반응형

kubectl drain 노드명

- drain 명령어를 사용하게 되면 해당 노드의 pod 를 다른 노드로 옮긴다.
- 실제로는 pod 를 옮기는게 아니라 다른 노드에 재 생성한다.
- 데몬셋을 무시하고 진행할 경우에는 --ignore-daemonsets 옵션을 사용한다.

아래와 같이 myserver-002와 myserver-003 에 pod 가 각각 deploy 되어있다.

root@myserver-001:~# kubectl get po -o wide
NAME                            READY   STATUS    RESTARTS   AGE     IP          NODE           NOMINATED NODE   READINESS GATES
rollout-nginx-74695fdcd-5trw5   1/1     Running   0          3m55s   10.32.0.2   myserver-002   <none>           <none>
rollout-nginx-74695fdcd-jkw2d   1/1     Running   0          3m55s   10.47.0.2   myserver-003   <none>           <none>
rollout-nginx-74695fdcd-tp75z   1/1     Running   0          3m55s   10.47.0.1   myserver-003   <none>           <none>

이 상황에서 myserver-003 을 drain 을 시켜보면 다음과 같이 변경된다.

root@myserver-001:~# kubectl get nodes
NAME           STATUS                     ROLES                  AGE     VERSION
myserver-001   Ready                      control-plane,master   2d8h    v1.22.3
myserver-002   Ready                      <none>                 2d8h    v1.22.3
myserver-003   Ready,SchedulingDisabled   <none>                 4h23m   v1.22.3

 

root@myserver-001:~# kubectl get po -o wide
NAME                            READY   STATUS    RESTARTS   AGE     IP          NODE           NOMINATED NODE   READINESS GATES
rollout-nginx-74695fdcd-5trw5   1/1     Running   0          4m45s   10.32.0.2   myserver-002   <none>           <none>
rollout-nginx-74695fdcd-8c55f   1/1     Running   0          11s     10.32.0.3   myserver-002   <none>           <none>
rollout-nginx-74695fdcd-h6txz   1/1     Running   0          11s     10.32.0.4   myserver-002   <none>           <none>

기존에 있던 rollout-nginx-74695fdcd-5trw5 파드를 제외하고 나머지 pod 는 이름을 보면 새로 만들어진것이다. Age 도 11s 로 나온다. 따라서 위에서 말한것처럼 drain 을 했을 경우 pod 를 옮기는게 아니라 삭제하고 새로 만들게 된다. 

 

728x90
반응형

+ Recent posts