쿠버네티스 아파치(Apache) Helm 배포 및 볼륨 마운트

💡 핵심 요약 (Executive Summary)

본 가이드는 쿠버네티스 Helm 패키지 매니저 apache 핵심 가이드 및 실전 아키텍처의 핵심 개념, 실전 구성 명령어 및 아키텍처 베스트 프랙티스를 다룹니다. 클라우드 네이티브 및 인프라 엔지니어링 실무에 즉시 활용 가능하도록 체계적으로 정리했습니다.

📑 Table of Contents
Informations
Using Chart Information
Exec
Create Yaml
yaml
apiVersion: v1
kind: PersistentVolume
metadata:
  name: apache-htdocs
spec:
  storageClassName: local-path
  capacity:
    storage: 8Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: /home/apache/html
  volumeMode: Filesystem
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: apache-htdocs-pvc
  namespace: apache
spec:
  storageClassName: local-path # Empty string must be explicitly set otherwise default StorageClass will be set
  volumeName: apache-htdocs
  accessModes:
    - ReadWriteOnce
  volumeMode: Filesystem
  resources:
    requests:
      storage: 8Gi
Helm values.yaml Overwrited
bash
repo=bitnami
sdiff -s <(helm show values ${repo}/$(cat Chart.yaml | yq '.name') | yq -oprops) <(cat ./values.yaml | yq -oprops)
global.defaultStorageClass =                                  | global.defaultStorageClass = local-path
htdocsPVC =                                                   | htdocsPVC = apache-htdocs-pvc
resourcesPreset = nano                                        | resourcesPreset = none
service.type = LoadBalancer                                   | service.type = NodePort
service.nodePorts.http =                                      | service.nodePorts.http = 30980
service.nodePorts.https =                                     | service.nodePorts.https = 30943
service.externalTrafficPolicy = Cluster                       | service.externalTrafficPolicy = Local

Apache httpd.conf Overwrited — ingress에서 처리함
xml
sdiff -s httpd.origin.conf httpd.conf
...
DocumentRoot "/opt/bitnami/apache/htdocs"                       DocumentRoot "/opt/bitnami/apache/htdocs"
<Directory "/opt/bitnami/apache/htdocs">                        <Directory "/opt/bitnami/apache/htdocs">
...
    Require all granted                                       |     #Require all granted
                                                              >     Require ip 1.2.3.4 #허용할 IP
</Directory>                                                    </Directory>
old
xml
sdiff -s httpd.origin.conf httpd.conf
...
#LoadModule remoteip_module modules/mod_remoteip.so           | LoadModule remoteip_module modules/mod_remoteip.so
                                                              > # 신뢰할 프록시 IP (예: ingress 컨트롤러 IP, 클러스터 게이트
                                                              > RemoteIPHeader X-Forwarded-For
                                                              > RemoteIPInternalProxy 10.42.0.0/16
...
DocumentRoot "/opt/bitnami/apache/htdocs"                       DocumentRoot "/opt/bitnami/apache/htdocs"
<Directory "/opt/bitnami/apache/htdocs">                        <Directory "/opt/bitnami/apache/htdocs">
...
    Require all granted                                       |     #Require all granted
                                                              >     Require ip 1.2.3.4 #허용할 IP
</Directory>                                                    </Directory>
...
<IfModule log_config_module>                                    <IfModule log_config_module>
    #                                                               #
    # The following directives define some format nicknames f       # The following directives define some format nicknames f
    # a CustomLog directive (see below).                            # a CustomLog directive (see below).
    #                                                               #
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{       LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{
    LogFormat "%h %l %u %t \"%r\" %>s %b" common                    LogFormat "%h %l %u %t \"%r\" %>s %b" common
                                                              >
                                                              >     <IfModule remoteip_module>
                                                              >       LogFormat "%a %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"
                                                              >       LogFormat "%a %l %u %t \"%r\" %>s %b" common
                                                              >     </IfModule>
...
</IfModule>                                                     </IfModule>
Ingress

Troubleshoot
Custom httpd.conf 정의시 오류발생할 경우…
  • 전제조건
  • 차트 내에 files directory가 있으며, 여기에 httpd.conf 를 custom해 놓으면 configmap 제작하여 사용 가능
    • 그런데 custom할 Sample이 존재하지 않음..
  • 파일을 넣지 않으면 컨테이너 내에 default값 httpd.conf 를 생성함
  • Idea: default httpd.conf를 생성 후 container 밖으로 가져오기
  • files directory가 빈 상태에서 설치
bash
helm install -n apache apache --create-namespace .
  • default httpd.conf 차트에 저장
bash
k exec -it -n apache deployments/apache -- cat /opt/bitnami/apache/conf/httpd.conf > ./files/httpd.conf
  • custom 후 재설치
bash
helm upgrade -n apache apache --create-namespace .
Features
특정 디렉토리내 모든 파일에 다운로드 권한 주기
bash
cd /mnt/apache/html
chmod +r -R $mydir

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *