Deployment of WordPress and MYSQL  Using HELM

Deployment of WordPress and MYSQL Using HELM

In this article, we are going to discuss the Kubernetes package manager helm and how to create a helm chart for setup the Jenkins.

We have divided the process into three steps as follows:

1.   Installing helm

2.   Create helm chart for WordPress and MySQL

3.   Publish a site/blog in WordPress

Introduction

Helm helps you manage Kubernetes applications — Helm Charts help you define, install, and upgrade even the most complex Kubernetes application.

Charts are easy to create, version, share, and publish — so start using Helm and stop the copy-and-paste.

Helm helps in three keyways:

  • Improves productivity
  • Reduces the complexity of deployments of microservices
  • Enables the adaptation of cloud-native applications

Why use Helm?

Writing and maintaining Kubernetes YAML manifests for all the required Kubernetes objects can be a time consuming and tedious task. For the simplest of deployments, you would need at least 3 YAML manifests with duplicated and hardcoded values. Helm simplifies this process and creates a single package that can be advertised to your cluster.

Helm is a client/server application and, until recently, has relied on Tiller (the helm server) to be deployed in your cluster. This gets installed when installing/initializing helm on your client machine. Tiller simply receives requests from the client and installs the package into your cluster. Helm can be easily compared to RPM of DEB packages in Linux, providing a convenient way for developers to package and ship an application to their end users to install.

 

Describing Helm

Helm has two parts to it:

·   The client (CLI), which lives on your local workstation.

·   The server (Tiller), which lives on the Kubernetes cluster to execute what’s needed.

The idea is that you use the CLI to push the resources you need and tiller will make sure that state is in fact the case by creating/updating/deleting resources from the chart. To fully grasp helm, there are 3 concepts we need to get familiar with:

·   Chart: A package of pre-configured Kubernetes resources.

·   Release: A specific instance of a chart which has been deployed to the cluster using Helm.

·   Repository: A group of published charts which can be made available to others.

Benefits of Helm

Developers like Helm charts for many reasons:

Boost’s productivity

Software engineers are good at writing software, and their time is best spent doing just that. Using Helm allows software to deploy their test environments at the click of a button.

An example of this might be that, in order to test a new feature, an engineer needs a SQL database. Instead of going through the process of installing the software locally, creating the databases and tables required, the engineer can simply run a single Helm Install command to create and prepare the database ready for testing.


Reduces duplication & complexity

Once the chart is built once, it can be used over and over again and by anyone. The fact that you can use the same chart for any environment reduces complexity of creating something for dev, test and prod. You can simply tune you chart and make sure it is ready to apply to any environment. And you get the benefit of using a production ready chart in dev.

Describing a Helm chart

Helm has a certain structure when you create a new chart. To create, run “helm create YOUR-CHART-NAME".

Once this is created, the directory structure should look like:

YOUR-CHART-NAME/

 |

 |- .helmignore

 |

 |- Chart.yaml

 |

 |- values.yaml

 |

 |- charts/

 |

 |- templates/

·   .helmignore: This holds all the files to ignore when packaging the chart. Similar to .gitignore, if you are familiar with git.

·   Chart.yaml: This is where you put all the information about the chart you are packaging. So, for example, your version number, etc. This is where you will put all those details.

·   Values.yaml: This is where you define all the values you want to inject into your templates. If you are familiar with terraform, think of this as helms variable.tf file.

·   Charts: This is where you store other charts that your chart depends on. You might be calling another chart that your chart need to function properly.

·   Templates: This folder is where you put the actual manifest you are deploying with the chart. For example you might be deploying an nginx deployment that needs a service, configmap and secrets. You will have your deployment.yaml, service.yaml, config.yaml and secrets.yaml all in the template dir. They will all get their values from values.yaml from above.

Installing Helm

Helm had the client-server architecture till version 2, We must need to install a server-side program Tiller in the Kubernetes Master cluster.

In version 3 helm provides more facilities i.e., install helm on the client-side only. We can install helm in Mac, Windows, and Linux.

The URL where you can download helm according to your operating system. link

Installation

No alt text provided for this image
No alt text provided for this image

To check the helm version

helm version
No alt text provided for this image

Create Chart for Jenkins

1.   Create a workspace (HelmWS)

mkdir HelmWS


cd HelmWS

2.   Create a new directory for wordpress (wpws)

mkdir wpws


cd wpws
No alt text provided for this image

3.   Now create Chart.yaml inside the workspace "wpws". This file consists of the metadata about the chart. i.e., The name of the chart, Version, and app version, etc.

·       Chart,yaml

apiVersion: v1

name: wpws

version: 0.1

appVersion: 0.1

description: Chart for setup of wordpress

No alt text provided for this image

5.   Now create one more folder inside the workspace "wpws" directory name will "templates" it contained all the YML manifest that launch our resources. Like: Deployment, service. 

mkdir  templates

Deployment file of WordPress:

apiVersion: apps/v1

kind: Deployment

metadata:

  creationTimestamp: null

  labels:

    app: wordpress

  name: wordpress

spec:

  replicas: 1

  selector:

    matchLabels:

      app: wordpress

  strategy: {}

  template:

    metadata:

      creationTimestamp: null

      labels:

        app: wordpress

    spec:

      containers:

      - image: wordpress:5.1.1-php7.3-apache

        name: wordpress

        resources: {}

      dnsPolicy: ClusterFirst

      restartPolicy: Always

status: {}

 
No alt text provided for this image

Service file of WordPress:

apiVersion: v1

kind: Service

metadata:

  creationTimestamp: null

  labels:

    app: wordpress

  name: wordpress

spec:

  ports:

  - port: 80

    protocol: TCP

    targetPort: 80

    nodePort: 32323

  selector:

    app: wordpress

  type: NodePort

status:


  loadBalancer: {}
No alt text provided for this image

5. Now we will install the chart as we create earlier using helm.

helm install <name> /folder
No alt text provided for this image

6.   Check the helm is successful or not.

helm list
No alt text provided for this image

7.   Connect to WordPress i.e., ip:32323

No alt text provided for this image
No alt text provided for this image

8.   Launch one more helm chart for data base

·       Create a new directory for MYSQL (dbws)

mkdir dbws


cd dbws

9.   Now create Chart.yaml inside the workspace "dbws". This file consists of the metadata about the chart. i.e., The name of the chart, Version, and app version, etc.

·       Chart,yaml

name: dbws

version: 0.1

appVersion: 0.1


description: Chart for setup of MYSQL DataBase
No alt text provided for this image

10.   Now create one more folder inside the workspace "wpws" directory name will "templates" it contained all the YML manifest that launch our resources. Like: Deployment, service. 

mkdir templates

No alt text provided for this image

Deployment of Mysql:

apiVersion: apps/v1

kind: Deployment

metadata:

  creationTimestamp: null

  labels:

    app: mysql

  name: mysql

spec:

  replicas: 1

  selector:

    matchLabels:

      app: mysql

  strategy: {}

  template:

    metadata:

      creationTimestamp: null

      labels:

        app: mysql

    spec:

      containers:

      - env:

        - name: MYSQL_ROOT_PASSWORD

          value: redhat

        - name: MYSQL_DATABASE

          value: wpdb

        - name: MYSQL_USER

          value: anuddeeph

        - name: MYSQL_PASSWORD

          value: redhat

        image: mysql:5.7

        name: mysql

        resources: {}

      dnsPolicy: ClusterFirst

      restartPolicy: Always

status: {}

 
No alt text provided for this image

1.   Now we will install the chart as we create earlier using helm.

helm install <name> /folder
No alt text provided for this image
No alt text provided for this image

·       Check the ip of database pod

No alt text provided for this image

·       Connect the Database with WordPress

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image

Thank you

 GitHub: https://github.com/Anuddeeph/Helm_Chart_for_Wordpress.git


Vaibhav Singh

" Associate DevOps_Engineer " || DevOps || AWS || AZURE || Digital Ocean || DevSecOps || Git || GitHub || Jenkins || CI/CD || Docker || Kubernetes || ECS || EKS || Terraform || Ansible ||WP_Engine ||

2 å¹´

deployment and pods not create

赞
回复
Aniket Khadye

Site Reliability Engineer at Crest data systems

4 å¹´

Great work

赞
回复

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

Anudeep Nalla的更多文章

  • How to Read RAM Data?

    How to Read RAM Data?

    What is RAM and What data it contains? Random-access memory (RAM) is a computer’s short-term memory. None of your…

    2 条评论
  • Zenity: Red Hat Enterprise Linux 8.4

    Zenity: Red Hat Enterprise Linux 8.4

    What is Zenity? Zenity is an open source and a cross-platform application which displays GTK+ Dialog Boxes in…

    6 条评论
  • OSPF (Open Short Path First) Routing Protocol implemented using Dijkstra Algorithm

    OSPF (Open Short Path First) Routing Protocol implemented using Dijkstra Algorithm

    Routing Information Protocol (RIP) RIP stands for Routing Information Protocol. RIP is an intra-domain routing protocol…

  • K-means Clustering and its use case in the Security Domain

    K-means Clustering and its use case in the Security Domain

    Introduction K-Means Clustering is an Unsupervised Learning algorithm, which groups the unlabeled dataset into…

  • JavaScript Use cases

    JavaScript Use cases

    What is JavaScript? JavaScript is a light-weight object-oriented programming language that is used by several websites…

  • Case Study on How Industries are using MongoDB.

    Case Study on How Industries are using MongoDB.

    What is MongoDB? MongoDB is one of the most popular open-source NoSQL database written in C++. As of February 2015…

  • Confusion Matrix role in Cyber Security

    Confusion Matrix role in Cyber Security

    What is a Confusion Matrix? A Confusion matrix is the comparison summary of the predicted results and the actual…

    1 条评论
  • GUI container on the Docker

    GUI container on the Docker

    Task 2 Task Description a) GUI container on the Docker b) Launch a container on docker in GUI mode c) Run any GUI…

    3 条评论
  • Deployment of Machine Learning Model Inside Docker Container

    Deployment of Machine Learning Model Inside Docker Container

    What is Docker? A Docker container is an open-source software development platform. Its main benefit is to package…

  • Create a Menu Using Python integrating with Ansible, Docker, AWS, Ansible

    Create a Menu Using Python integrating with Ansible, Docker, AWS, Ansible

    A) Output for Local Machine B) Output for Remote Machine Code is in GitHub:

社区洞察

其他会员也浏览了