A Beginners Guide to Helm - Deploy Apache/HTTPD Web Server using Helm

A Beginners Guide to Helm - Deploy Apache/HTTPD Web Server using Helm

There are several approaches to managing large-scale production services. Kubernetes is a popular choice for running containers in a production environment. When working directly with Kubernetes, there are some limitations.

Helm makes an effort to address these issues by providing useful features that increase productivity and reduce the need for maintenance on complex deployments.

The use of Helm simplifies the installation and management of Kubernetes applications. Consider it the Apt/Yum/Homebrew of Kubernetes. Helm uses charts as his packaging format. A chart is a collection of files that list various Kubernetes resources that are related to one another.

A complete web app stack, including HTTP servers, databases, caches, and other components, can be deployed using a single chart, which can be as simple as a memcached pod or as complex as a full stack.

A Helm Chart describes a set of Kubernetes resources through a collection of templates and settings. It can manage a single node definition all the way up to an extremely scalable multi-node cluster.

Even though managing applications on Kubernetes can be difficult, Helm is relatively simple to use. Here's an example of a deployment without Helm and how Helm simplifies it. We configure the workload using Kubernetes YAML files instead of Helm. These YAML files contain all of the information needed to deploy containers.

These YAML files must contain information on everything, including the configuration requirements for each Pod and how the Kubernetes cluster handles load balancing. As a result, in order to configure a new Kubernetes workload, you must create a YAML file specifically for that workload. To do it manually, you must create many YAML files, one for each workload you create.

Instead of manually generating separate YAML files for each application, we can simply create a Helm chart and let Helm deploy the application to the cluster on your behalf. Helm charts contain templates for various Kubernetes resources, which come together to form applications.

A Helm chart can be modified when it is installed on multiple Kubernetes clusters. Environment- or deployment-specific configurations can be extracted from a Helm chart and placed in a separate file to specify these values when the Helm chart is deployed. Deploying an application in development, staging, and production environments, for example, does not necessitate the use of separate charts.

In this article we will learn how to deploy httpd apache web server using helm.

Steps -

  1. Install Microk8s single node Kubernetes cluster.
  2. Install kubectl
  3. Install/Enable helm
  4. Deploy httpd apache server using helm

1.Microk8s installation on Ubuntu -

prayag@devops101:~$ sudo snap install microk8s --classic

prayag@devops101:~$ microk8s status

prayag@devops101:~$ sudo snap alias microk8s.kubectl kubectl

prayag@devops101:~$ echo "alias kubectl=microk8s.kubectl" >> .bashrc

prayag@devops101:~$ sudo usermod -a -G microk8s $USER

prayag@devops101:~$ sudo chown -f -R $USER ~/.kube

prayag@devops101:~$ newgrp microk8s

prayag@devops101:~$ sudo microk8s config > ~/.kube/config
        

2. Kubectl installation -


prayag@devops101:~$ curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"

prayag@devops101:~$ sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl

prayag@devops101:~$ which kubectl
        

Check nodes using kubectl


prayag@devops101:~$ kubectl get all

prayag@devops101:~$ kubectl get nodes

prayag@devops101:~$ kubectl get nodes -o wide
        

3.Enable helm in microk8s -


prayag@devops101:~$ microk8s enable helm dns storage/hostpath-storage
Infer repository core for addon helm
Enabling Helm
Fetching helm version v2.16.7.
?% Total??% Received % Xferd?Average Speed??Time??Time???Time?Current
?????????????????Dload?Upload??Total??Spent??Left?Speed
100 24.1M?100 24.1M??0???0?3846k???0?0:00:06?0:00:06 --:--:-- 4577k

Helm is enabled
        


prayag@devops101:~$ microk8s status

microk8s is running
high-availability: no
?datastore master nodes: 127.0.0.1:19001
?datastore standby nodes: none

addons:

?enabled:
??ha-cluster??????# (core) Configure high availability on the current node
??helm?????????# (core) Helm 2 - the package manager for Kubernetes        

Finding Charts with 'helm search'

Helm includes a strong search command. It can search two types of sources:

1. Helm search hub searches the Artifact Hub, which contains helm charts from dozens of different repositories.

2. Helm search repo - searches for repositories added to your local helm client (with helm repo add). This search utilises local data and does not necessitate the use of a public network connection.


prayag@devops101:~$ helm repo add bitnami https://charts.bitnami.com/bitnami
"bitnami" has been added to your repositories
prayag@devops101:~$

prayag@devops101:~$ helm repo list
NAME??URL
bitnami https://charts.bitnami.com/bitnami
prayag@devops101:~$

prayag@devops101:~$ helm list
NAME??NAMESPACE REVISION??UPDATED??STATUS??CHART??APP VERSION
prayag@devops101:~$
        

4. Deploy httpd apache server using helm


prayag@devops101:~$ helm install apache bitnami/apache --set service.type=NodePort

NAME: apache
LAST DEPLOYED: Fri Sep?9 15:44:53 2022
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
CHART NAME: apache
CHART VERSION: 9.2.3
APP VERSION: 2.4.54

** Please be patient while the chart is being deployed **

1. Get the Apache URL by running:

?export NODE_PORT=$(kubectl get --namespace default -o jsonpath="{.spec.ports[0].nodePort}" services apache)

?export NODE_IP=$(kubectl get nodes --namespace default -o jsonpath="{.items[0].status.addresses[0].address}")

?echo https://$NODE_IP:$NODE_PORT/

WARNING: You did not provide a custom web application. Apache will be deployed with a default page. Check the README section "Deploying your custom web application" in https://github.com/bitnami/charts/blob/master/bitnami/apache/README.md#deploying-a-custom-web-application.

prayag@devops101:~$??export NODE_PORT=$(kubectl get --namespace default -o jsonpath="{.spec.ports[0].nodePort}" services apache)

prayag@devops101:~$??export NODE_IP=$(kubectl get nodes --namespace default -o jsonpath="{.items[0].status.addresses[0].address}")

prayag@devops101:~$??echo https://$NODE_IP:$NODE_PORT/

https://192.168.0.151:31583/
        

Check helm deployment


prayag@devops101:~$ helm list
NAME??NAMESPACE REVISION??UPDATED??????STATUS?????CHART??????APP VERSION

apache default??1?????2022-09-09 15:44:53.482193694 +0000 TC???deployed????apache-9.2.3??2.4.54

prayag@devops101:~$ kubectl get all
NAME?????????????READY??STATUS??RESTARTS??AGE
pod/apache-65c86759df-9mwvk??1/1???Running??0?????89s
NAME?????????TYPE????CLUSTER-IP????EXTERNAL-IP??PORT(S)???????????AGE
service/kubernetes??ClusterIP??10.152.183.1???<none>????443/TCP???????????52m
service/apache????NodePort??10.152.183.193??<none>????80:31583/TCP,443:32014/TCP??92s
NAME???????????READY??UP-TO-DATE??AVAILABLE??AGE

deployment.apps/apache??1/1???1??????1??????91s

NAME????????????????DESIRED??CURRENT??READY??AGE
replicaset.apps/apache-65c86759df??1?????1?????1????91s
        

Check if apache web page is loaded -


prayag@devops101:~$ curl https://192.168.0.151:31583/

<html><body><h1>It works!</h1></body></html>

prayag@devops101:~$
        

We can see that we have successfully deployed apache httpd web server and we are able to load the default html page.

I hope you found this to be useful in some way. I’ll be back with some more interesting new Kubernetes, Cloud and Devops articles soon.

要查看或添加评论,请登录

Prayag Sangode的更多文章

社区洞察

其他会员也浏览了