23. Apache Helm Chart: Simplified Deployment of Apache HTTP Server

23. Apache Helm Chart: Simplified Deployment of Apache HTTP Server

This Helm chart simplifies the deployment of an Apache HTTP Server on Kubernetes, ensuring scalability and ease of configuration.


Prerequisites

Before deploying the Apache Helm chart, ensure you have:

  1. A running Kubernetes cluster (local, cloud, or KIND).

  2. kubectl installed and configured.

  3. Helm 3 installed. To install Helm, run:

     curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
     chmod 700 get_helm.sh
     ./get_helm.sh
    


Create Chart

The Helm chart is organized as follows:

helm create apache-helm

Chart Structure

The Helm chart is organized as follows:

apache-helm/
├── Chart.yaml         # Metadata about the chart
├── values.yaml        # Default values for the deployment
└── templates/         # Kubernetes manifests
    ├── deployment.yaml
    └── service.yaml


Installation Steps

1. Clone the Helm Chart

Navigate to the directory containing the Helm chart.


You can override these values by:

  • Editing values.yaml.

  • Using the --set flag during installation.

Default Configuration

The deployment uses the default values from values.yaml:


image:
  repository: httpd
  tag: 2.4

service:
  port: 80
  targetPort: 80

2.Package the Chart

Run the following command to package the chart:

helm package apache-helm

3. Install the Helm Chart

Deploy the Apache server with: (for dev and prod environment)

helm install dev-apache apache-helm -n apache-namespace --create-namespace

Similarly Deploy for prod environment :
change Values.yml file

helm install prod-apache apache-helm -n prod-apache --create-namespace

Change Chart.yml file version 1.16.1 for production:

Change values.yml file for replica count 2 for production:

Run the following command to upgrade apache-helm chart:

helm upgrade prod-apache ./apache-helm -n prod-apache

we can see pod replicas running as 2

Roll back :

helm rollback prod-apache 1 -n prod-apache


Accessing the Deployment

  1. Check the Status

     kubectl get pods -n dev-apache
     kubectl get svc -n dev-apache
     kubectl get pods -n prod-apache
     kubectl get svc -n prod-apache
    
  1. Forward the Service Port Forward the Apache service to a local port for access:

     sudo -E kubectl port-forward service/dev-apache-apache-helm -n dev-apache 80:80 --address=0.0.0.0
    

  2. Access Locally Open your browser and visit:

     http://ec2-public-ip:80
    


Uninstallation

To remove the deployment and its resources:

helm uninstall dev-apache -n dev-apache
helm uninstall prod-apache -n prod-apache
kubectl delete namespace dev-apache
kubectl delete namespace prod-apache


Customizing the Chart

You can customize the deployment in two ways:

1. Override Values Using the --set Flag

helm install apache ./apache \
  --namespace apache-namespace \
  --set replicaCount=3 \
  --set image.tag=2.4.53 \
  --set service.type=LoadBalancer

2. Modify the values.yaml File

Edit the values.yaml file directly to adjust configurations.


Features

  • Scalable: Adjust replicaCount to scale pods.

  • Configurable Resources: Define CPU/memory requests and limits.

  • Flexible Service Types: Supports ClusterIP, NodePort, and LoadBalancer.


Troubleshooting

  1. Verify Versions

     helm version
     kubectl version
    
  2. Check Helm Release Status

     helm status apache -n dev-apache
    
  3. Inspect Pod Logs

     kubectl logs <apache-pod-name> -n apache-namespace
    

Would you like to dive deeper into Helm charts or expand this guide further?