ksingh3 / MediaWiki

This repo containerize mediawiki application along with mariadb and apache. Helm charts setup here installs the application and database and also help in rolling out updates.
0 stars 0 forks source link
docker helm helm-charts kubernetes

MediaWiki

This project containerizes the Media Wiki application along with Mariadb under Centos 7.

Install

Following are the prerequisite before going forward:

Docs

Docker image:

You can use my docker hub images, else you can create you own image beofre create run docker login.

Use my docker images

$ docker pull ksingh3/mediawiki:deploy
$ docker pull ksingh3/mediawiki:db

Docker login

If you want to create you own image login to docker hub before proceeding and complete the authentication

$ docker login

Clone this repo

$ git clone https://github.com/ksingh3/MediaWiki.git

Build application image

$ cd MediaWiki/Docker/Application
$ docker build -t ksingh3/mediawiki:deploy .

Build database image

$ cd /MediaWiki/Docker/Database
$ docker build -t ksingh3/mediawiki:db .

Create a namespace

$ kubectl create ns wm

Install Maridb chart

$ cd MediaWiki/Charts/mywiki-db
$ helm upgrade --install mywiki-db -f values.yaml . -n wm

Configure Mariadb one time

Login to Database pod

$ export POD_NAME=$(kubectl get pods --namespace wm -l "app.kubernetes.io/name=mywiki-db,app.kubernetes.io/instance=mywiki-db" -o jsonpath="{.items[0].metadata.name}")
$ kubectl exec -it $POD_NAME -n wm bash

Open mysql terminal

$ mysql

Run to give perms to root user

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'; FLUSH PRIVILEGES;

Exit from the pod.

Mariadb hostname

mywiki-db.wm.svc.cluster.local

Install the application

$ cd MediaWiki/Charts/mywiki
$ helm upgrade --install mywiki -f values.yaml . -n wm

Port forward to access from local

 $ export POD_NAME=$(kubectl get pods --namespace wm -l "app.kubernetes.io/name=mywiki,app.kubernetes.io/instance=mywiki" -o jsonpath="{.items[0].metadata.name}")
 $ kubectl --namespace wm port-forward $POD_NAME 8080:80

Setup the Application

Open the application on http://localhost:8080

Database hostname

update the hostname to mywiki-db.wm.svc.cluster.local

Update Application helm chart.

Download LocalSettings.php

Update Values.yaml

Update config property in File: Values.yaml using the downloaded LocalSettings.php.

Re-run the helm upgrade with upgrade=Yes

helm upgrade --install mywiki -f values.yaml . -n wm --set upgrade=Yes

This time it will mount LocalSettings.php file under /var/www/html/ using config map.

Rolling updates Automation

To automate rolling update, we can make use of secrets under Settings and making use of following Action: https://github.com/marketplace/actions/helm-3

name: Deploy
on:
  release:
    types: [created]
jobs:
  deployment:
    runs-on: 'ubuntu-latest'
    steps:
      - uses: actions/checkout@v1
      - name: Deploy
        uses: WyriHaximus/github-action-helm3@v2
        with:
          exec: helm upgrade --install mywiki -f values.yaml . -n wm --set upgrade=Yes
          kubeconfig: '${{ secrets.KUBECONFIG }}'

secrets.KUBECONFIG is kubeconfig saved inside github secrets.