Apache HTTP Server on Kubernetes: Helm

๐Ÿ’ก Apache HTTP Server on Kubernetes: Helm โ€” Executive Summary

Technical architectural analysis, practical configuration manifests, and deployment instructions for Apache HTTP Server on Kubernetes: Helm.

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 Overwritten
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 Overwritten โ€” Handled by 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
If an error occurs when defining
Custom httpd.confโ€ฆ
  • Prerequisites
  • There is a files directory in the chart, and if you customize httpd.conf here, you can create and use a configmap.
    • But there is no sample to customize..
  • If the file is not included, a default value httpd.conf is created within the container
  • Idea: Create default httpd.conf and import it outside the container
  • Install with an empty files directory
bash
helm install -n apache apache --create-namespace .
  • default httpd.conf Save to chart
bash
k exec -it -n apache deployments/apache -- cat /opt/bitnami/apache/conf/httpd.conf > ./files/httpd.conf
  • Reinstall after custom
bash
helm upgrade -n apache apache --create-namespace .
Features
Give download permission to all files in a specific directory
bash
cd /mnt/apache/html
chmod +r -R $mydir

Comments

Leave a Reply

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