2023-09-04-TIL

Today I Learned

MD5 Hashing in Java

  • https://www.baeldung.com/java-md5
  • https://www.javatpoint.com/java-md5-hashing-example
  • https://stackoverflow.com/questions/415953/how-can-i-generate-an-md5-hash-in-java
  • https://www.geeksforgeeks.org/md5-hash-in-java/
  • https://veneas.tistory.com/entry/JAVA-%EC%9E%90%EB%B0%94-MD5-%EC%95%94%ED%98%B8%ED%99%94-%EB%8B%A8%EB%B0%A9%ED%96%A5-%EC%95%94%ED%98%B8%ED%99%94
  • https://www.quickprogrammingtips.com/java/how-to-generate-md5-hash-in-java.html
  • https://www.javainterviewpoint.com/java-md5-hashing-example/#google_vignette
  • https://docs.spring.io/spring-framework/docs/3.0.0.M3/javadoc-api/org/springframework/util/Md5HashUtils.html
  • https://www.baeldung.com/java-md5-checksum-file
  • https://mvnrepository.com/artifact/commons-codec/commons-codec/1.16.0
  • https://mkyong.com/java/java-md5-hashing-example/

printStackTrace() vs log.error("error", e)

  • https://www.tutorialspoint.com/what-are-the-differences-between-printstacktrace-method-and-getmessage-method-in-java
  • https://lnsideout.tistory.com/entry/JAVA-etoString-egetMessage-eprintStackTrace-%EC%98%88%EC%99%B8%EC%B2%98%EB%A6%AC
  • https://stackoverflow.com/questions/32840399/printing-exception-vs-exception-getmessage

Today I Studied

Kubernetes

  • https://www.leafcats.com/305
  • https://easyitwanner.tistory.com/171
  • https://smoh.tistory.com/348
  • https://www.datanet.co.kr/news/articleView.html?idxno=174833
  • https://kubernetes.io/ko/docs/concepts/overview/
  • https://www.whatap.io/ko/blog/142/
  • https://soobindeveloper8.tistory.com/829
  • https://www.codestates.com/blog/content/%EC%BF%A0%EB%B2%84%EB%84%A4%ED%8B%B0%EC%8A%A4

Kubernetes vs AWS Auto-Scaling

  • https://www.cloudthat.com/resources/blog/kubernetes-vs-autoscaling-which-is-better-for-your-cloud-environment#:~:text=Auto%20Scaling%20Groups%20do%20not,requests%20for%20individual%20containers%20easily.
  • https://www.reddit.com/r/devops/comments/vlahs6/autoscaling_vs_kubernetes/
  • https://applatix.com/top-5-reasons-kubernetes-aws-autoscaling-groups-awesome-together/
  • https://www.quora.com/What-is-the-difference-between-Kubernetes-and-EC2-Auto-scaling-group-running-behind-ELB-since-they-are-both-using-virtual-machines

Split-Brain

  • https://leehi0110.tistory.com/11

ETCD

etcd consensus algorithm high availability

  • https://stackoverflow.com/questions/70345068/how-is-etcd-a-highly-available-system-even-though-it-uses-raft-which-is-a-cp-al
  • https://the-report.cloud/etcd-in-kubernetes/
  • https://medium.com/@extio/deep-dive-into-etcd-a-distributed-key-value-store-a6a7699d3abc
  • https://stackoverflow.com/questions/24708325/eli5-how-etcd-really-works-and-what-is-consensus-algorithm
  • https://medium.com/@pixelpig/talk-about-etcd-part2-the-raft-consistency-protocol-5a029ef53593
  • https://etcd.io/docs/v3.2/faq/
  • https://www.linkedin.com/pulse/etcd-kubernetes-distributed-configuration-management-aditya-joshi/

ETCD and Kubernetes

  • https://etcd.io/docs/v3.3/learning/why/
  • https://www.digihunch.com/2022/06/etcd-the-key-value-store-for-kubernetes/
  • https://dev.to/adipolak/what-is-etcd-kubernetes-bitesize-3k79
  • https://www.youtube.com/watch?v=CuWSY_fwV6M
  • https://dev.to/giladmaayan/what-is-etcd-and-how-is-it-used-in-kubernetes-47bg
  • https://medium.com/@extio/deep-dive-into-etcd-a-distributed-key-value-store-a6a7699d3abc

EKS vs Kubernetes

  • https://www.techtarget.com/searchaws/tip/2-options-to-deploy-Kubernetes-on-AWS-EKS-vs-self-managed
  • https://dinarys.com/blog/kubernetes-vs-aws-eks

AWS ECS vs Kubernetes

  • https://bluexp.netapp.com/blog/aws-ecs-vs-kubernetes-an-unfair-comparison

Imperative vs Declarative

  • https://code-lab1.tistory.com/244#:~:text=%EB%AA%85%EB%A0%B9%ED%98%95%20vs%20%EC%84%A0%EC%96%B8%ED%98%95%20%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%B0%8D&text=%EB%AA%85%EB%A0%B9%ED%98%95%20%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%B0%8D%EC%9D%80%20%EB%AC%B4%EC%97%87%EC%9D%84,%EC%9D%84%20%EC%98%88%EB%A1%9C%20%EB%93%A4%EC%96%B4%20%EC%84%A4%EB%AA%85%ED%95%B4%EB%B3%B4%EC%9E%90.&text=%EB%8B%B9%EC%8B%A0%EC%9D%80%20%EC%95%A0%EC%9D%B8%EA%B3%BC%20%ED%95%A8%EA%BB%98,%EB%A5%BC%20%ED%95%98%EA%B8%B0%EB%A1%9C%20%EA%B2%B0%EC%A0%95%ED%96%88%EB%8B%A4.

Kubernetes Scheduler

  • https://devocean.sk.com/blog/techBoardDetail.do?ID=163909
  • https://kubernetes.io/docs/concepts/scheduling-eviction/kube-scheduler/

Kubelet

  • https://kubernetes.io/docs/reference/command-line-tools-reference/kubelet/

Rolling Update

  • https://kubernetes.io/ko/docs/tutorials/kubernetes-basics/update/update-intro/
  • https://ooeunz.tistory.com/124
  • https://velog.io/@zero/%EC%BF%A0%EB%B2%84%EB%84%A4%ED%8B%B0%EC%8A%A4-%EB%B0%B0%ED%8F%AC-%EC%A0%84%EB%9E%B5RollingUpdate-BlueGreen-Canary-%EB%B0%8F-%EB%A1%A4%EB%B0%B1Rollback-%EA%B0%9C%EB%85%90%EA%B3%BC-%EC%84%A4%EC%A0%95

nGrinder

  • https://naver.github.io/ngrinder/

Event Bubbling

  • https://velog.io/@tlatjdgh3778/%EC%9D%B4%EB%B2%A4%ED%8A%B8-%EB%B2%84%EB%B8%94%EB%A7%81%EA%B3%BC-%EC%BA%A1%EC%B2%98%EB%A7%81%EC%97%90-%EB%8C%80%ED%95%9C-%EC%A0%95%EB%A6%AC

Image Optimization

  • https://tecoble.techcourse.co.kr/post/2023-05-02-image-size-optimization/

Today I Studied

마스터 노드를 3개 띄우는데, 일일이 적어주는 이유는? master1도 ETCD 1,2,3를 다 알아야하고 master2도 ETCD 1,2,3를 다 알아야하는 이유?

master가 두 개 이상이 되어야하는 이유? -> HA 구성

ETCD is a distributed key-value store that is used to store the cluster state of Kubernetes. The cluster state includes information such as the names and IP addresses of the master nodes, the pods that are running in the cluster, and the services that are available in the cluster.

In order to maintain a consistent view of the cluster state, all of the ETCD nodes in the cluster need to be aware of each other. This is because ETCD uses a consensus algorithm to ensure that all of the nodes have the same data. If one node does not know about the other nodes, it will not be able to participate in the consensus algorithm and the cluster state will become inconsistent.

In a Kubernetes cluster, the ETCD nodes are typically co-located on the master nodes. However, it is also possible to have the ETCD nodes on separate machines. In this case, the ETCD nodes need to be configured with the IP addresses of each other so that they can communicate and maintain a consistent view of the cluster state.

To answer your question more specifically, ETCD needs to know the other ETCD in other master nodes in order to:

Maintain a consistent view of the cluster state.
Detect and resolve conflicts in the cluster state.
Recover from failures in the cluster.
Without this knowledge, ETCD would not be able to function properly and the Kubernetes cluster would not be able to operate.

I hope this answers your question. Let me know if you have any other questions.

K8s 목적?

auto-scale vs k8s?

  • dong: 리소스를 추상화해서 노드로 관리하여 pod를 활성화하는게 목적

  • pyro: ami로 이미지로 만들어서 띄워서 컨테이너화 시키면 aws에서 auto-scale이 훨씬 용이

  • Woody: pod가 auto-scaling이 되어야하는데 node, pods가 모두 auto-scaling이 되어야하는데, 시점을 파악하기가 어려움. k8s의 공식적인 툴은 없고 핸들링해야하는 부분이 많다. Pod, node 모두 보고 auto-scaling을 해야해서 side-effect를 우려해서 안씀

  • 저도 궁금했는데, AWS 에 auto-scale 기능이 제공되는데 k8s 를 직접 사용해서 느껴지는 장점이 있나요? ami 로 이미지로 만들어서 띄울수도 있고, 컨테이너화 시켜서 scale-out 할 수도 있습니다.

  • 오히려 큰 규모의 서비스는 파이로 말대로 하면 될 것 같아요

    저희는 참고로 제약사항이 좀 있어서 오토스케일 기능을 거의 안사용합니다

  • Roach: aws 가져다 쓰는것보다는 ..

  • dong: backend app 여러개인 msa구조일때, 모듈이 많아질때 k8s가 필요해진다.

  • woody: 또 k8s 장점이 self-healing이 가능 probe가 죽으면 다시 destroy하고 다시 살리는게 부드러워서 도움이 많이 된다.

  • Jane: application의 단위?

  • Woody: pods가 많다보니 관리하기가 힘들어서 k8s가 좋다. 하나의 .. 안에 여러개의 pods가 뜨니깐 관리가 용이하다

  • dong: pod하나 띄우는게 프로세스 하나 띄우는것

  • Jane: k8s안에 물리장비가 뜨는 경우도 많은데, 한 번에 배포할 수 있도록 해놔서 k8s관리군이랑 물리군이랑 차이를 모르고 쓰고있었다. 물리장비(pm) 관리는 low-level의 인프라 모니터링 말고는 직접 다루고있다.

  • woody: 모니터링은 lense 사용중

  • dong: 물리적인 스펙과 상관없이 추상화되어서 띄우는게 장점

  • woody: memory peak?
  • jane: 5% ~ 15%? k8s 가상장비는 80%, 알림오면 임계치 조정하기
  • dong:
  • roachL저희도 보통 하드한거 하는 인스턴스 아니면 보통 10% 이하에요 CPU 메모리는 보통 60% 로 두는거같아요 근데 어차피 VM 옵션으로 다 제약걸어두니
  • dong: 근데 쿠버네티스가 메모리 80%점유중이면 가끔 메모리 부족해서 배포 실패나고 그러지 않나요 우디?
  • woody: request, node는 크로스체크해야함. request를 말하는건지 실제 사용량을 말하는건지 모르겠음
  • roach: 근데 성능테스트 안하면 알수없지 않아요? 애초에 메모리 얼마나 둘지?
  • woody: 처음에는 충분히 크게 잡아놓고, 점차 줄여나가는 방식으로 구성

  • 성능테스트 도구는? ngrinder, k6
  • 성능테스트는 항상 하는가?
  • 사용자층이 운영자가 아니라 public인 경우에는 꼼꼼히 하는편
  • WebClient vs Feign -> Feign을 여전히 많이 사용
  • koroutine으로 비동기로 wrapper layer를 하나두어서 사용

  • GraalVM 사용? 부팅 시간을 줄이는 이유?
  • 부팅 시 드는 부하를 줄인다.
  • roach: lazy loading
  • roach: redis나 kafka는 lazy loading 하기도 함. but 비추
  • woody: 메모리까지 계속 잡아먹다가 restart되는 현상이 있는데, 원인이 너무 다양할 수 있어서 정확히는 모르지만 최초 pod가 뜰때의 부하인것은 확실한데 어떻게 개선할 수 있을지 고민. tps가 많지는 않은데…
  • Roach: 그래도 스프링 때문에 그 정도의 부하가 있다면 이상한듯? runtime과 동일해야 정상인데
  • woody: 처음 트래픽을 받을때에도 동
  • 롤링 업데이트
  • woody: OOM이 발생하면서 재시작되기도하고, 그냥 재시작되기도 함. probe http requests + 일반 requests -> 대기큐에 너무 쌓여서 probe가 안되어서
  • dong: periodSeconds?
  • woody: 그 설정은 되어있는데… 로그를 못 봐서 좀 어려울듯
  • roach: 보통 배치서버에 graal을 사용하지 api 서버에서는 graal을 잘 사용하지 않는것 같다?

  • jane: wait를 수동으로 부하를 이동시키고있는데, rolling update가 이를 해소할 수 있는 기술인가?
  • woody: 기존 pod 2대가 죽고 새 pod 2대가 살아도 90분이라고 하면 그동안 기다렸다가 해야하는 문제가 있다. 그냥 수동으로 해도 나쁘지 않을듯?

  • kyu: 로그 관련해서 애플리케이션 로그를 확인할 때 k8s로 띄우면 어디에 있는 로그인지 확인을 어떻게 하나? 직접 접속해서 하는가?
  • woody: app 로그를 보고 에러가 난것같다고 하면 pod이름이 찍혀있는데, pod 이름이 로그에 찍혀있기 때문에 pod이름을 보고 shell을 확인하기도 하고..
  • Kyu: 예를 들여, 로그인 에러가 발생하면 account error 같은 내용이 하나의 컨테이너에서 찍혔을텐데

  • memory: 60%정도 주고