일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
- 리소스전체삭제
- Prometheus 서버 설정
- 포트 9255 설정
- minikube 설치 및 실행
- kubectl 설치
- compose.yml로 stackdriver-export 서비스 설정
- 스위치 4대 기능
- GCP 모니터링
- github
- github 사용법
- 정적 웹 사이트 호스팅
- 리소스삭제
- gke 클러스터 액세스 설정
- prometheus 서버 서비스등록
- stackdriver exporter
- prometheus dockerfile
- 서비스 계정 키 설정
- vs code로 ssh 접속
- dockerfile로 stackdriver-export이미지 생성
- 애플리케이션 기본 사용자 인증 정보
- GCP VM
- prometheus 연동
- prometheus.yml 파일 설정
- ADC 사용자 인증
- aws-nuke
- Prometheus 서버 설치
- permission denied 에러 발생
- git
- stackdriver exporter 설치
- 방화벽 오픈
- Today
- Total
My __ 노트
[ stackdriver-export ] 도커를 이용하여 컨테이너 빌드하기 본문
해당 글에서는 Dockerfile로 stackdriver-export 커스텀 도커이미지를 생성하고 compose.yml 파일에 컨테이너 서비스 설정을 기재하여 애플리케이션 배포를 실행해 보려고 합니다.
목차
▶ 전체적인 파일 구조
▶ 도커 이미지 파일 작성
▶ 도커 이미지 빌드 및 확인
▶ compose.yml 파일 작성
▶ 컨테이너 빌드 & 확인
전체적인 파일 구조
── mon
├── compose.yml
├── Dockerfile
└── keyfile
└── service_account.json
도커 이미지 파일 작성
먼저 mon 디렉터리를 생성 후 하위에 Dockerfile을 작성합니다.
FROM prometheuscommunity/stackdriver-exporter
USER nobody
EXPOSE 9255
ENTRYPOINT ["/bin/stackdriver_exporter"]
도커 이미지 빌드 및 확인
docker build . -t 도커이미지네임
docker images
예시 :
compose.yml 파일 작성
compose.yml 파일에 stackdriver-export 설치에 필요한 서비스 설정들을 기재합니다.
version: '3.8'
services:
stackdriver-export:
container_name: 생성할 컨테이너 네임
image: 사용할 도커이미지네임
restart: unless-stopped
####호스트 경로:컨테이너내부 경로 ####
volumes:
- ./keyfile:/keyfile:ro
environment:
GOOGLE_APPLICATION_CREDENTIALS: "/keyfile/service_account.json"
#####호스트 OS에서 공개할 포트:컨테이너내부 포트#####
ports:
- "9255:9255"
user: root
command:
"--google.project-id=프로젝트id
--monitoring.metrics-type-prefixes='compute.googleapis.com/instance/cpu/utilization,agent.googleapis.com/disk/percent_used,agent.googleapis.com/memory/percent_used'"
주의할 사항 :
- 생성할 컨테이너 네임은 구동 중인 컨테이너 네임과 일치하지 않아야 합니다.
- 사용할 도커 이미지 네임이 정확하여야 합니다.
- 호스트 볼륨을 사용할 경우 호스트 디렉터리 경로를 정확하게 기재하여야 합니다.
- 컨테이너 내부 포트는 동일해도 호스트 OS에서 사용할 포트는 동일하지 않아야 합니다.
- 프로젝트 id가 정확하여야 합니다.
- 수집할 GCP 모니터링 메트릭 타입 prefixes 가 정확하여야 합니다.
🔗더 자세한 내용은 해당 링크를 참고 : https://cloud.google.com/monitoring/api/metrics_opsagent#agent-cpu
Ops Agent metrics | Cloud Monitoring | Google Cloud
When you install the Ops Agent on your VM instances, the agent transmits data for the metric types listed on this page to Monitoring. For information about choosing the right agent, see Ops Agent overview. Important: You must install the Ops Agent to colle
cloud.google.com
컨테이너 빌드
docker compose up
🚨 에러 발생 : environment variable: open /keyfile/service_account.json: no such file or directory”
원인 : volumes 항목 작성 시 호스트 디렉터리 경로를 정확하게 입력하지 않아서 발생하는 이슈입니다.
🚨 에러 발생 : 'docker login': denied: requested access to the resource is denied
원인 : compose.yml 파일에 작성한 도커 이미지 네임이 현재 사용가능한 도커 이미지 네임과 일치하지 않아서 발생한 이슈입니다.
확인
curl http://localhost:9255/metrics
-------------------------------------------------------
stackdriver_monitoring_last_scrape_error{project_id="프로젝트id"} 0 => 수치가 "0"이면 정상 수집 되고 있습니다
'모니터링' 카테고리의 다른 글
[ Grafana ] 사용자 별 폴더 / 대시보드에 대한 접근 권한 설정 (1) | 2023.11.24 |
---|---|
[ prometheus 서버 ] 도커로 컨테이너 빌드하기 (0) | 2023.07.27 |
Stackdriver exporter 설치에 따른 방화벽 설정 (0) | 2023.07.25 |
[ prometheus 서버 ] GCE에 구축하는 방법 (0) | 2023.07.24 |
[ stackdriver_exporter ] Prometheus - GCP 모니터링 연동 (0) | 2023.07.13 |