sts 의 상태를 확인하자. 이미 mariadb가 설치되어 있으므로 확인한다.

root@ip-172-31-4-27:~/resource# kubectl get po
NAME                             READY   STATUS    RESTARTS   AGE
idolized-mule-mariadb-master-0   1/1     Running   0          81m
idolized-mule-mariadb-slave-0    1/1     Running   0          81m.

root@ip-172-31-4-27:~/resource# kubectl get sts
NAME                           READY   AGE
idolized-mule-mariadb-master   1/1     81m
idolized-mule-mariadb-slave    1/1     81m

root@ip-172-31-4-27:~/resource# kubectl get sts idolized-mule-mariadb-master -o yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
  creationTimestamp: "2020-12-04T03:12:33Z"
  generation: 1
  labels:
    app: mariadb
    chart: mariadb-7.3.14
    component: master
    heritage: Tiller
    release: idolized-mule
	생략
	spec:
	  podManagementPolicy: OrderedReady #@ 병렬로 수정가능
	  replicas: 1 #@ RS 지원
	  revisionHistoryLimit: 10
	생략
	spec:
      affinity:
        podAntiAffinity: #@ anti를 통해 master와 worker가 서로 다른 노드에 설치되도록 설정
          preferredDuringSchedulingIgnoredDuringExecution:
          - podAffinityTerm:
              labelSelector:
                matchLabels:
                  app: mariadb
                  release: idolized-mule
              topologyKey: kubernetes.io/hostname
            weight: 1
	containers:
      - env: #@ 환경변수 확인
        - name: MARIADB_ROOT_PASSWORD
          valueFrom:
            secretKeyRef:
              key: mariadb-root-password
              name: idolized-mule-mariadb
        - name: MARIADB_DATABASE
          value: my_database
        - name: MARIADB_REPLICATION_MODE
          value: master
        - name: MARIADB_REPLICATION_USER
          value: replicator
        - name: MARIADB_REPLICATION_PASSWORD
          valueFrom:
            secretKeyRef:
              key: mariadb-replication-password
              name: idolized-mule-mariadb
        image: docker.io/bitnami/mariadb:10.3.22-debian-10-r27
        imagePullPolicy: IfNotPresent
		
	livenessProbe: #@ 현재 동작하는지 상태 판단 후 결과를 전달한다.
          exec:
            command:
            - sh
            - -c
            - |
              password_aux="${MARIADB_ROOT_PASSWORD:-}"
              if [ -f "${MARIADB_ROOT_PASSWORD_FILE:-}" ]; then
                  password_aux=$(cat $MARIADB_ROOT_PASSWORD_FILE)
              fi
              mysqladmin status -uroot -p$password_aux
          failureThreshold: 3
          initialDelaySeconds: 120
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 1
		  
	readinessProbe:	#@ 아래 조건이 맞아야 ep를 생성하겠다.
          exec:
            command:
            - sh
            - -c
            - |
              password_aux="${MARIADB_ROOT_PASSWORD:-}"
              if [ -f "${MARIADB_ROOT_PASSWORD_FILE:-}" ]; then
                  password_aux=$(cat $MARIADB_ROOT_PASSWORD_FILE)
              fi
              mysqladmin status -uroot -p$password_aux
          failureThreshold: 3
          initialDelaySeconds: 30
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 1

	volumes: #@ 볼륨을 두개 정의하여 사용하고 있다.
      - configMap:
          defaultMode: 420
          name: idolized-mule-mariadb-master
        name: config
      - emptyDir: {} #@ emptyDir를 백앤솔루션으로 사용. 임시저장소로 DB를 저장한다. POD가 삭제되면 저장소가 함께 삭제될 것이다.
        name: data
		
	root@ip-172-31-4-27:~/resource# kubectl get cm
	NAME                           DATA   AGE
	idolized-mule-mariadb-master   1      88m
	idolized-mule-mariadb-slave    1      88m
	idolized-mule-mariadb-tests    1      88m
	
	root@ip-172-31-4-27:~/resource# kubectl get cm idolized-mule-mariadb-master -o yaml
	apiVersion: v1
	data:
	  my.cnf: |-
		[mysqld]
		skip-name-resolve
		explicit_defaults_for_timestamp
		basedir=/opt/bitnami/mariadb
		plugin_dir=/opt/bitnami/mariadb/plugin
		port=3306
		socket=/opt/bitnami/mariadb/tmp/mysql.sock
		tmpdir=/opt/bitnami/mariadb/tmp
		max_allowed_packet=16M
		bind-address=0.0.0.0
		pid-file=/opt/bitnami/mariadb/tmp/mysqld.pid
		log-error=/opt/bitnami/mariadb/logs/mysqld.log
		character-set-server=UTF8
		collation-server=utf8_general_ci
        
#@ 디커플링 메소드로 edit를 제공한다.
root@ip-172-31-4-27:~/resource# kubectl edit cm idolized-mule-mariadb-master -o yaml
Edit cancelled, no changes made.

'클라우드 컴퓨팅 & NoSQL > k8s' 카테고리의 다른 글

monitoring 구축  (0) 2020.12.06
Monitoring  (0) 2020.12.06
statefulset  (0) 2020.12.06
Helm 설치/Helm을 이용한 mysql 설치  (0) 2020.12.06
Helm  (0) 2020.12.06

+ Recent posts