Blog Details

image

29 Jan 2024

09

35

Introduction

This documentation shows you how you can configure a Minikube Container as kubernetes cluster to deploy 5 replicas of mariadb.

Steps:

Start Ubuntu or any Linux

Install Minikube

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube

Start Docker with following command

 sudo systemctl start docker
 or
 sudo service docker start

startwsl

Verify docker status

systemctl status docker

startdocker

Create file called "mariadb.yaml". Enter following

apiVersion: apps/v1
kind: Deployment 
metadata:
  name: mariadb-deployment
spec: 
  replicas: 5 
  selector:
    matchLabels:
      app: mariadb
  template: 
    metadata:
      labels:
        app: mariadb 
    spec:
      containers: 
      - name: mariadb
        image: mariadb
        resources:
          limits:
            memory: 512Mi
            cpu: "1"
          requests:
            memory: 256Mi
            cpu: "0.2"
        ports:
        - containerPort: 3306 
        env:        
        - name: MARIADB_ALLOW_EMPTY_ROOT_PASSWORD
          value: "0" # if it is 1 and root_password is set, root_password takes precedance
        - name: MARIADB_ROOT_PASSWORD
          value: secret

Run the following command to start Minikube cluster:

minikube start
kubectl cluster-info
kubectl apply -f mariadb.yaml

dockerrun

After this you can write various commands for detail info

kubectl get deployments
kubectl get pods -o wide | grep minikube
kubectl get pods

dockerps dockerps

You can start Minikube Dashboard by entering following command:

minikube dashboard

dockerps dockerps

To connect to mariadb enter this command:

you need to forward the port 3306 before that

 kubectl port-forward mariadb-deployment-695d57dc6d-blnns 3306:3306 #(mariadb-deployment-695d57dc6d-blnns is one of the 5 pod)
 kubectl exec -it mariadb-deployment-695d57dc6d-blnns -- mariadb -u root -psecret 

dockerps

Connect from MySql Workbench

start workbench and click on new connection 
use host as 127.0.0.1 and port as forwarded port in this case 3306 enter password and done.

connected

Join our newsletter!

Enter your email to receive our latest newsletter.

Don't worry, we don't spam

image

Related Articles

image
05 Feb 2024

Embed Youtube video in mdx file.

How to Embed Youtube video in mdx file -by Evan Dangol

image
05 Feb 2024

Get Free Linux Virtual Machine Forever in Cloud.

Comparasion of free tier AWS, Azure and Google cloud virtual machines -by Evan Dangol

image
05 Feb 2024

.Net MAUI, Local Web Api Access From Mobile Phones During Development

How to Access local web api from mobile device -by Evan Dangol