카카오클라우드스쿨 Week14

황동근·2022년 9월 13일
0

카카오클라우드스쿨

목록 보기
14/21

09/12

추석


09/13

Docker

Jupyter notebook

Node

MongoDB

Image

  • layer의 집합
  • merge
  • 불변
  • Dockerfile로 image build
    • build 과정
      • image > container > image > container ...
  • container의 infra 제공
    • cgroup
    • OS

Container

  • image의 snapshot
    • /var/lib/docker
  • process
  • 변경 가능

Command

  • pull
  • image
    • history
      • --no-trunc
      • notepad++
    • search
    • rmi
      • image rm
      • 참조 중인 container가 없어야 함
    • push
      • login
        • base64
      • tag
      • 계정자ID/저장소:태그
  • inspect
    • json-file
    • image
      • 정적 image
      • build에서 마지막 container
      • lowerDir, UpperDir, MergedDir
      • --format
    • container
      • namespace
        • IP, MAC address 할당
  • ps
    • -a
    • -q
      • Only display container IDs
    • --filter
    • docker rm $(docker ps -a -q --filter 'status=exited')
  • container
    • run
      • image가 local에 없으면 pull
      • create + start + [command]
      • -i
        • interactive
      • -t
        • tty
        • 단말
      • -d
        • detach
        • 백그라운드 실행
      • -p host_port:container_port
        • publish list
        • 포트 연결
      • -e list
        • 환경변수
        • -e ... -e ...
        • -env-file env_list
      • --restart
        • default : no
        • always
          • 사용자 stop이 아닌 예기치 않은 컨테이너 종료 시 자동 재시작
        • kubernates default : always
          • aout-healing
      • --name
      • --rm
        • container stop과 동시에 자동 rm 수행
      • -u
        • 특정 계정에서 application 수행
      • -w
        • workdir
        • container 접속 시 연결되는 경로
      • -v
        • volume 지정
    • logs
      • container id or name
      • kubectl logs pod_name
      • -f
        • follow
        • 지속적 확인
    • port
    • top
    • pause
      • unpause
    • rename
    • attach
      • 조회할 때 사용
    • cp
      • container에서 vi 사용하지 않음
      • container file을 host로 복사
      • host file을 container로 복사
    • diff
      • 변경 사항 체크
    • commit
      • container 내부 변경된 것을 새로운 image에 저장
  • system
    • events

09/14

Docker

Linux

  • kill
    • session kill

Command

  • backup
    • tar
      • 계층 구조
      • 묶어서 관리
    • image
      • save
        • gzip
          • tar.gz
        • bzip2
          • tar.bz2
      • load
        • redirection
    • container
      • 동적이기 때문에 추천하지 않음
      • export
      • import
        • 직접 run 할 수 없음

Network

  • 구성
    • host NIC
    • bridge
    • docker0
      • veth와 연결
    • End Point
      • Network Name Space
      • eth0
      • MAC
      • IP
      • Routing Table
      • veth와 연결
        • 1:1 pair
        • full duplex link
  • custom
    • 자동
      • 172.18.0.1/16
      • network create
    • 수동
      • CIDR
  • container 통신
    • API 통신
  • nginx
    • conf
      • web 대신 proxy로 설정
  • CNM
    • Container Network Model
  • Command
    • run
      • --add-host
      • --dns
      • --expose
      • --net
        • host
          • container의 ip는 없음
    • network create
      • -d
        • driver
      • 자동
        • docker network create -d bridge web-net
      • 수동
        • docker network create --driver bridge --subnet 172.30.1.0/24 --ip-range 172.30.1.0/24 --gateway 172.30.1.1 vswitch-net
  • CIDR
    • Classless Inter-Domain Routing
    • IP 대역 지정
    • private Network 지향
    • RFC 1918
      • 10.0.0.0/8 : 10.0.0.0 ~ 10.255.255.255
      • 172.16.0.0/12 : 172.16.0.0 ~ 172.31.0.0
      • 192.168.0.0/16 : 192.168.0.0 ~ 192.168.255.255
  • DNS
    • service discovery

Container load balancer

  • Proxy
    • HAProxy
    • Nginx
    • Apache
  • Round Robin
  • docker self load balancer
    • 내장된 DNS 서버로 구현
      • 127.0.0.11
      • docker DNS
      • service discovery
    • 사용자 정의 Bridge Network 생성
    • --net-alias
      • target group
      • workload(traffic)을 받을 server(container)의 그룹
  • nginx load balancer
    • nginx.conf

09/15

Docker

Network

  • 기본 네트워크 구성
    • bridge
    • 소프트웨어적으로 구현된 스위치와 같다
  • overlay network
  • swarm
    • orchestration
    • network cluster

자원 소비 제어

  • cgroup
    • 컨테이너에 자원 할당
    • defalut : unlimit
  • cpu
    • 종류
      • count
      • rate
    • cpu register 작업 등록
    • time schedule
      • Round Robin
    • --cpu-shares
      • 시간
    • --cpuset-cpus
      • 개수
    • update
      • --cpus
        • 비율
  • memory
    • 종류
      • physical
      • swap
    • 4MB부터 할당 가능
      • page
        • 4KB
    • --memory
    • --memory-swap
  • disk
    • 성능지표
      • IOPS
      • MBPS
      • iostat
        • kB_read/s, kB_wrtn/s, kB_read, kB_wrtn
    • --device-read/write-bps
    • --device-read/write-iops
  • volume
    • 데이터 이전을 위한 공유 설정
    • 데이터 영속성(지속성) 유지를 위한 volume 구성
    • volume은 해당 container의 주요 소스, 구성 경로에 배치
    • host to container
    • container to container
    • bind mount
      • filesystem
      • 디렉토리에 연결
        • 파일과 연결 가능
      • 사용자 관리
      • -v(--volume) host_path:container_path
      • 없으면 자동 생성
      • 마운트된 모든 디스크를 사용 가능
        • 용량 모두 사용
      • docker 용량 제한
        • pquota
        • --storage-opt
    • volume
      • docker area
      • docker가 경로 관리
      • volume create volume_name
      • /var/lib/docker/volumes에 volume_name 생성
      • -v volume_name:contaier_path
    • tmpfs mount
      • memory

Multi Container

  • --link 옵션 또는 docker network를 통해 container 연결
  • one container one application
  • 3-Tier container MAS
    • Frontend
    • Application
    • Database

09/16

Docker

DockerFile

  • Building Docker Image
  • IaC
    • Infrastructure as Code
    • 코드형 인프라
  • Docker image 생성 순서
    • 개발팀 요청 > 분석 > 작업 계획서
    • docker file 작성 > build
    • docker run > test
    • 공유
      • resistry
        • public / private
      • source
        • github
    • 개발팀 활용 > test
      • update 요청
  • 명령어
    • FROM
      • 베이스 image 지정
    • MAINTAINER
      • dockerfile 작성자
    • LABEL
      • 라벨 설정
      • 설명
      • key-value 구조
    • RUN
      • linux 명령어 실행
      • image build 시 동작
    • CMD
      • 데몬 실행
      • container 실행 시 동작
    • ENTRYPOINT
      • 데몬 실행, 변수 실행, arg 실행
      • container 실행 시 동작할 변수
    • EXPOSE
      • 노출될 포트
    • ENV
      • 내부 환경변수 설정
    • ADD
      • 파일 및 디렉토리 추가(복사)
      • 압축 자동 해제 기능
    • COPY
      • 파일 복사
      • host to image
    • VOLUME
      • 볼륨 마운트
      • host와 공유할 디렉토리
    • USER
      • 사용자 설정
    • WORKDIR
      • 작업 디렉토리 지정
    • ONBUILD
      • build 완료 후 실행할 명령어
  • Container Layer
  • Multi-stage build

Image 공유

  • Private registry
  • Nexus
profile
안녕하세요~

0개의 댓글