본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

예제 MySQL 구성

원문 보기 위키 갱신

예제 MySQL 구성 (Kubernetes) (Example MySQL Configuration)

MySQL에 의존하는 프로젝트를 위한 지속적 통합(CI) 파이프라인 구성 방법을 안내합니다. Drone이 처음이라면 먼저 튜토리얼과 빌드 구성 가이드를 읽어 보세요.

출처: Drone CI Docs

본문

기본 예제 (Basic Example)

아래 예제는 MySQL 서비스 컨테이너를 실행하는 파이프라인을 보여줍니다. 데이터베이스 서버는 localhost:3306에서 사용할 수 있습니다.

kind: pipeline
type: kubernetes
name: default

steps:
- name: test
  image: mysql
  commands:
  - sleep 15
  - mysql -u root --execute="SELECT VERSION();"

services:
- name: database
  image: mysql
  environment:
    MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
    MYSQL_DATABASE: test

데이터베이스 옵션 (Database Options)

mysql 컨테이너에 추가 런타임 옵션을 주고 시작해야 한다면 entrypoint와 command 인자를 재정의할 수 있습니다.

services:
- name: database
  image: mysql
  entrypoint: [ "mysqld" ]
  command: [ "--character-set-server=utf8mb4" ]

데이터베이스 설정 (Database Settings)

공식 MySQL 이미지는 시작 시점에 기본 사용자명, 비밀번호, 데이터베이스 등을 생성하는 데 사용되는 환경 변수를 제공합니다. 자세한 내용은 공식 이미지 문서를 참고하세요.

services:
- name: database
  image: mysql
  environment:
    MYSQL_DATABASE: test
    MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'

자주 겪는 문제 (Common Problems)

MySQL 컨테이너에 연결할 수 없다면 MySQL이 초기화를 마치고 연결을 받기 시작할 충분한 시간을 확보했는지 확인하세요.

kind: pipeline
type: kubernetes
name: default

steps:
- name: test
  image: mysql
  commands:
  - sleep 15
  - mysql -u root -h database

더 알아보기 (Learn more)