Simple Ingress Controller for Kubernetes (NGINX-based)
🌐 Simple Ingress Controller for Kubernetes (NGINX-based)
This guide provides a simple setup for deploying NGINX Ingress Controller on a Kubernetes cluster, suitable for bare-metal or lab environments using NodePort service type.
📦 Step 1: Create Namespace
kubectl create namespace ingress-nginx
🚀 Step 2: Deploy Ingress Controller
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.10.1/deploy/static/provider/baremetal/deploy.yaml
Wait a few seconds for the pods to be created in the ingress-nginx namespace.
🌍 Step 3: Expose Ingress via NodePort (Optional)
Edit the service to use NodePort instead of LoadBalancer:
kubectl edit svc ingress-nginx-controller -n ingress-nginx
Change this:
spec:
type: LoadBalancer
To:
spec:
type: NodePort
Then check the assigned ports:
kubectl get svc -n ingress-nginx
You’ll see output like:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
ingress-nginx-controller NodePort 10.96.221.42 <none> 80:31234/TCP,443:31235/TCP 2m
🧪 Step 4: Test with a Sample Ingress
Create a test Ingress resource:
# hello-ingress.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: hello-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
ingressClassName: nginx
rules:
- host: local.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: hello-service
port:
number: 80
Don’t forget to create the backend service (hello-service) and add local.example.com to your /etc/hosts file pointing to your Node IP.
📄 Reference
- Official repo: https://github.com/kubernetes/ingress-nginx
Prometheus on Kubernetes with NFS
📈 Prometheus on Kubernetes with NFS
This guide provides Kubernetes manifests to deploy Prometheus on a cluster using:
NFS server for persistent storage (192.168.88.61:/nfs/prometheus)
📌 Requirements
- Kubernetes cluster (v1.24+)
- NFS path
/nfs/prometheusexists and is writable
🗂 Files Included
📄 prometheus-configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: prometheus-config
data:
prometheus.yml: |
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
📄 prometheus-pv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: prometheus-pv
spec:
capacity:
storage: 5Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
nfs:
server: 192.168.88.61
path: /nfs/prometheus
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: prometheus-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
📄 prometheus-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: prometheus
spec:
replicas: 1
selector:
matchLabels:
app: prometheus
template:
metadata:
labels:
app: prometheus
spec:
containers:
- name: prometheus
image: prom/prometheus:v2.52.0
args:
- "--config.file=/etc/prometheus/prometheus.yml"
- "--storage.tsdb.path=/prometheus"
ports:
- containerPort: 9090
volumeMounts:
- name: config-volume
mountPath: /etc/prometheus
- name: data-volume
mountPath: /prometheus
volumes:
- name: config-volume
configMap:
name: prometheus-config
- name: data-volume
persistentVolumeClaim:
claimName: prometheus-pvc
📄 prometheus-service.yaml
apiVersion: v1
kind: Service
metadata:
name: prometheus
spec:
type: NodePort
selector:
app: prometheus
ports:
- port: 80
targetPort: 9090
nodePort: 30084
🚀 Deployment Steps
kubectl apply -f prometheus-configmap.yaml
kubectl apply -f prometheus-pv.yaml
kubectl apply -f prometheus-deployment.yaml
kubectl apply -f prometheus-service.yaml
🌐 Access Prometheus
Visit in browser:
http://<NodeIP>:30084
⚠️ Notes
- Ensure
/nfs/prometheusexists on the NFS server:
mkdir -p /nfs/prometheus
chmod -R 777 /nfs/prometheus
- For shared access or HA setup, consider
ReadWriteManyif supported by your CSI.
📄 License
MIT
Grafana on Kubernetes with NFS
📊 Grafana on Kubernetes with NFS
This guide provides Kubernetes manifests to deploy Grafana on a cluster using:
- NFS server for persistent storage (
192.168.88.61:/nfs/grafana)
📌 Requirements
- Kubernetes cluster (v1.24+)
- NFS path
/nfs/grafanaexists and is writable
🗂 Files Included
📄 grafana-pv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: grafana-pv
spec:
capacity:
storage: 2Gi
accessModes:
- ReadWriteOnce
nfs:
server: 192.168.88.61
path: /nfs/grafana
persistentVolumeReclaimPolicy: Retain
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: grafana-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2Gi
📄 grafana-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: grafana
spec:
replicas: 1
selector:
matchLabels:
app: grafana
template:
metadata:
labels:
app: grafana
spec:
containers:
- name: grafana
image: grafana/grafana:10.4.1
ports:
- containerPort: 3000
volumeMounts:
- name: grafana-storage
mountPath: /var/lib/grafana
volumes:
- name: grafana-storage
persistentVolumeClaim:
claimName: grafana-pvc
📄 grafana-service.yaml
apiVersion: v1
kind: Service
metadata:
name: grafana
spec:
type: NodePort
selector:
app: grafana
ports:
- port: 80
targetPort: 3000
nodePort: 30083
🚀 Deployment Steps
kubectl apply -f grafana-pv.yaml
kubectl apply -f grafana-deployment.yaml
kubectl apply -f grafana-service.yaml
🌐 Access Grafana
Visit in browser:
http://<NodeIP>:30083
Default credentials:
- Username:
admin - Password:
admin(you’ll be prompted to change on first login)
⚠️ Notes
- Make sure
/nfs/grafanaexists on the NFS server:mkdir -p /nfs/grafana chmod -R 777 /nfs/grafana - For shared access or HA setup, consider
ReadWriteManyif supported by your CSI.
📄 License
MIT
Moodle on Kubernetes with NFS and External MariaDB/MySQL
📦 Moodle on Kubernetes with NFS and External MariaDB/MySQL
This repository provides Kubernetes manifests to deploy Moodle using:
- 📁 NFS persistent volume (
192.168.88.61:/nfs/moodle) - 🛢️ External MariaDB or MySQL as database (must be pre-deployed)
📌 Requirements
- Kubernetes v1.24+
- NFS path
/nfs/moodle(with write permissions) - Existing database service:
mariadbormysql - Moodle image:
bitnami/moodle:5.0.1(latest stable)
📂 Files and Usage
1. moodle-pv.yaml – PersistentVolume & PersistentVolumeClaim
# moodle-pv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: moodle-pv
spec:
capacity:
storage: 10Gi
accessModes:
- ReadWriteMany
nfs:
server: 192.168.88.61
path: /nfs/moodle
persistentVolumeReclaimPolicy: Retain
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: moodledata-pv
spec:
capacity:
storage: 5Gi
accessModes:
- ReadWriteMany
nfs:
server: 192.168.88.61
path: /nfs/moodledata
persistentVolumeReclaimPolicy: Retain
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: moodle-pvc
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 10Gi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: moodledata-pvc
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 5Gi
2. moodle-deployment.yaml – Moodle Deployment
# moodle-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: moodle
spec:
replicas: 1
selector:
matchLabels:
app: moodle
template:
metadata:
labels:
app: moodle
spec:
containers:
- name: moodle
image: bitnami/moodle:5.0.1
env:
- name: MOODLE_DATABASE_HOST
value: "mariadb"
- name: MOODLE_DATABASE_USER
value: "root"
- name: MOODLE_DATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: mariadb-secret
key: root-password
- name: MOODLE_DATABASE_NAME
value: "moodle"
ports:
- containerPort: 8080
volumeMounts:
- name: moodle-data
mountPath: /bitnami/moodle
- name: moodledata
mountPath: /bitnami/moodledata
volumes:
- name: moodle-data
persistentVolumeClaim:
claimName: moodle-pvc
- name: moodledata
persistentVolumeClaim:
claimName: moodledata-pvc
3. moodle-service.yaml – Moodle Service (NodePort)
# moodle-service.yaml
apiVersion: v1
kind: Service
metadata:
name: moodle
spec:
type: NodePort
selector:
app: moodle
ports:
- port: 80
targetPort: 8080
nodePort: 30082
🚀 Deployment Steps
kubectl apply -f moodle-pv.yaml
kubectl apply -f moodle-deployment.yaml
kubectl apply -f moodle-service.yaml
🌐 Access Moodle
Visit in browser:
http://<NodeIP>:30082
📁 NFS Server Setup
sudo mkdir -p /nfs/moodle
sudo chmod -R 777 /nfs/moodle
⚠️ Notes
- Database service name must match
MOODLE_DATABASE_HOST - Make sure MariaDB has:
root@%user- database
moodle - password matching
mariadb-secret
- NFS path must be RW by pod
- NodePort can be changed as needed
📄 License
MIT
WordPress on Kubernetes with NFS and External MariaDB/MySQL
📦 WordPress on Kubernetes with NFS and External MariaDB/MySQL
This repository contains Kubernetes manifests to deploy WordPress using:
- NFS for persistent storage (
192.168.88.61:/nfs/wordpress) - External MySQL or MariaDB database running in the same Kubernetes cluster
📌 Requirements
- Kubernetes cluster (v1.24+)
- Existing NFS path:
/nfs/wordpress - Running external DB (
mariadbormysqlservice) - Port
30081open on Node for external access (NodePort)
📁 NFS Server Setup
sudo mkdir -p /nfs/wordpress
sudo chmod -R 777 /nfs/wordpress
🗂 Deployment Files
1. PersistentVolume and PersistentVolumeClaim
# wordpress-pv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: wordpress-pv
spec:
capacity:
storage: 5Gi
accessModes:
- ReadWriteMany
nfs:
server: 192.168.88.61
path: /nfs/wordpress
persistentVolumeReclaimPolicy: Retain
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: wordpress-pvc
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 5Gi
2. WordPress Secret
# wordpress-secret.yaml
apiVersion: v1
kind: Secret
metadata:
name: wordpress-secret
type: Opaque
data:
db-password: bXktc2VjcmV0LXB3
📌 The value db-password is the base64 encoding of my-secret-pw.
You can generate your own with:
echo -n 'your-password' | base64
3. WordPress Deployment
# wordpress-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: wordpress
spec:
replicas: 1
selector:
matchLabels:
app: wordpress
template:
metadata:
labels:
app: wordpress
spec:
containers:
- name: wordpress
image: wordpress:6.8-php8.3-apache
env:
- name: WORDPRESS_DB_HOST
value: "mariadb"
- name: WORDPRESS_DB_USER
value: "root"
- name: WORDPRESS_DB_PASSWORD
valueFrom:
secretKeyRef:
name: wordpress-secret
key: db-password
- name: WORDPRESS_DB_NAME
value: "wordpress"
ports:
- containerPort: 80
volumeMounts:
- name: wordpress-data
mountPath: /var/www/html
volumes:
- name: wordpress-data
persistentVolumeClaim:
claimName: wordpress-pvc
4. WordPress Service
# wordpress-service.yaml
apiVersion: v1
kind: Service
metadata:
name: wordpress
spec:
type: NodePort
selector:
app: wordpress
ports:
- port: 80
targetPort: 80
nodePort: 30081
🚀 Deploy WordPress
Apply all manifests in order:
kubectl apply -f wordpress-pv.yaml
kubectl apply -f wordpress-secret.yaml
kubectl apply -f wordpress-deployment.yaml
kubectl apply -f wordpress-service.yaml
🌐 Access WordPress
Visit:
http://<NodeIP>:30081
⚠️ Notes
- Ensure that your database service (
mariadbormysql) is running and accessible. - The
WORDPRESS_DB_NAMEmust match a database created in your MySQL/MariaDB beforehand (e.g.,CREATE DATABASE wordpress;) - Make sure the secret name and key match exactly.
- You can adjust the NodePort or switch to Ingress as needed.
📄 License
MIT
phpMyAdmin on Kubernetes
📦 phpMyAdmin on Kubernetes
This repository provides the necessary manifests to deploy phpMyAdmin on Kubernetes for managing MariaDB and MySQL databases.
📌 Requirements
- Kubernetes cluster (v1.24+)
- An existing MySQL or MariaDB service running in the cluster
- phpMyAdmin will connect using ClusterIP service name
🗂 Deployment Files
1. phpMyAdmin Deployment
# phpmyadmin-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: phpmyadmin
spec:
replicas: 1
selector:
matchLabels:
app: phpmyadmin
template:
metadata:
labels:
app: phpmyadmin
spec:
containers:
- name: phpmyadmin
image: phpmyadmin:5.2
env:
- name: PMA_HOST
value: "mysql" # or "mariadb" depending on your DB service
- name: PMA_PORT
value: "3306"
ports:
- containerPort: 80
2. phpMyAdmin Service
# phpmyadmin-service.yaml
apiVersion: v1
kind: Service
metadata:
name: phpmyadmin
spec:
type: NodePort # or ClusterIP if exposing internally only
selector:
app: phpmyadmin
ports:
- port: 80
targetPort: 80
nodePort: 30080
🚀 Deploy phpMyAdmin
kubectl apply -f phpmyadmin-deployment.yaml
kubectl apply -f phpmyadmin-service.yaml
🌐 Accessing phpMyAdmin
- If
NodePortis used:http://<NodeIP>:30080 - Login using the DB credentials of your
MySQLorMariaDBinstance.
⚙️ Customization
- Change
PMA_HOSTto point to the correct database service:mysqlfor MySQLmariadbfor MariaDB
🛡️ Security
For production, consider enabling HTTPS and protecting access using Ingress or authentication.
📄 License
MIT
MySQL Standalone on Kubernetes with NFS
📦 MySQL Standalone on Kubernetes with NFS
This repository contains Kubernetes manifests to deploy a standalone MySQL instance using an external NFS server for persistent storage.
📌 Requirements
- Kubernetes cluster (v1.24+)
- NFS Server:
192.168.88.61 - Exported path:
/nfs/mysqlwith write permission
📁 NFS Server Setup
sudo mkdir -p /nfs/mysql
sudo chmod -R 777 /nfs/mysql
🗂 Deployment Files
1. PersistentVolume and PersistentVolumeClaim
# mysql-pv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: mysql-pv
spec:
capacity:
storage: 5Gi
accessModes:
- ReadWriteOnce
nfs:
server: 192.168.88.61
path: /nfs/mysql
persistentVolumeReclaimPolicy: Retain
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mysql-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
2. MySQL Secret
# mysql-secret.yaml
apiVersion: v1
kind: Secret
metadata:
name: mysql-secret
type: Opaque
data:
root-password: bXktc2VjcmV0LXB3
📌 root-password is base64-encoded value of my-secret-pw
Generate a new one using:
echo -n 'your-password' | base64
3. MySQL Deployment
# mysql-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql
spec:
replicas: 1
selector:
matchLabels:
app: mysql
template:
metadata:
labels:
app: mysql
spec:
containers:
- name: mysql
image: mysql:8.4
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mysql-secret
key: root-password
ports:
- containerPort: 3306
volumeMounts:
- name: mysql-data
mountPath: /var/lib/mysql
volumes:
- name: mysql-data
persistentVolumeClaim:
claimName: mysql-pvc
4. MySQL Service
# mysql-service.yaml
apiVersion: v1
kind: Service
metadata:
name: mysql
spec:
selector:
app: mysql
ports:
- port: 3306
targetPort: 3306
type: ClusterIP
🚀 Deploy All Components
Apply in order:
kubectl apply -f mysql-secret.yaml
kubectl apply -f mysql-pv.yaml
kubectl apply -f mysql-deployment.yaml
kubectl apply -f mysql-service.yaml
🧪 Test the Connection
kubectl run mysql-client --rm -it --image=mysql:8.4 -- bash
# Inside pod:
mysql -h mysql -u root -pmy-secret-pw
⚠️ Notes
ReadWriteOncemay not be optimal for NFS in all CSI environments. ConsiderReadWriteManyif your setup supports it.- Do not share
/nfs/mysqlpath across multiple MySQL instances simultaneously. - Ensure proper export and firewall settings on the NFS server.
- Always use Secrets for sensitive data such as passwords.
📄 License
MIT
MariaDB Standalone on Kubernetes with NFS
📦 MariaDB Standalone on Kubernetes with NFS
This repository contains YAML manifests to deploy a standalone MariaDB instance on Kubernetes using an NFS server for persistent storage.
📌 Requirements
- Kubernetes cluster (v1.24+ recommended)
- NFS Server accessible at
192.168.88.61:/nfs - NFS path:
/nfs/mariadbmust exist and have write permission
📁 Folder Structure on NFS Server
sudo mkdir -p /nfs/mariadb
sudo chmod -R 777 /nfs/mariadb
🗂 Deployment Files
1. PersistentVolume and PersistentVolumeClaim
# mariadb-pv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: mariadb-pv
spec:
capacity:
storage: 5Gi
accessModes:
- ReadWriteOnce
nfs:
server: 192.168.88.61
path: /nfs/mariadb
persistentVolumeReclaimPolicy: Retain
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mariadb-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
2. MariaDB Secret
# mariadb-secret.yaml
apiVersion: v1
kind: Secret
metadata:
name: mariadb-secret
type: Opaque
data:
root-password: bXktc2VjcmV0LXB3
📌 root-password is the base64-encoded value of my-secret-pw.
Generate a new one using:
echo -n 'your-password' | base64
3. MariaDB Deployment
# mariadb-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: mariadb
spec:
replicas: 1
selector:
matchLabels:
app: mariadb
template:
metadata:
labels:
app: mariadb
spec:
containers:
- name: mariadb
image: mariadb:11.3
env:
- name: MARIADB_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mariadb-secret
key: root-password
ports:
- containerPort: 3306
volumeMounts:
- name: mariadb-data
mountPath: /var/lib/mysql
volumes:
- name: mariadb-data
persistentVolumeClaim:
claimName: mariadb-pvc
4. MariaDB Service
# mariadb-service.yaml
apiVersion: v1
kind: Service
metadata:
name: mariadb
spec:
selector:
app: mariadb
ports:
- port: 3306
targetPort: 3306
type: ClusterIP
🚀 Deploy MariaDB
Apply all manifests in order:
kubectl apply -f mariadb-secret.yaml
kubectl apply -f mariadb-pv.yaml
kubectl apply -f mariadb-deployment.yaml
kubectl apply -f mariadb-service.yaml
📌 Notes:
- Make sure your cluster has a working StorageClass or access to NFS.
- Use
Secretinstead of plaintext for security (as shown above).
🧪 Test Connection
Run a temporary MariaDB client pod and connect:
kubectl run mariadb-client --rm -it --image=mariadb:11.3 -- bash
# Inside pod:
mariadb -h mariadb -u root -pmy-secret-pw
⚠️ Notes
ReadWriteOnceis sufficient for standalone use. For multi-access, useReadWriteMany.- Avoid sharing the same NFS path across multiple DB pods.
- Secure NFS and database access in production environments.
📄 License
MIT
How to Set Up NFS Server for Kubernetes Persistent Volumes
🛠️ How to Set Up NFS Server for Kubernetes Persistent Volumes
This guide walks you through installing and configuring an NFS server for use with Kubernetes PersistentVolumes (PV) and PersistentVolumeClaims (PVC).
🧩 Step 1: Install NFS Server
sudo apt update
sudo apt install nfs-kernel-server
📁 Step 2: Create Shared Directories
Create directories for Kubernetes apps:
sudo mkdir -p /nfs/mysql
sudo mkdir -p /nfs/mariadb
sudo mkdir -p /nfs/wordpress
sudo mkdir -p /nfs/moodle
sudo mkdir -p /nfs/moodledata
sudo mkdir -p /nfs/grafana
sudo mkdir -p /nfs/prometheus
sudo chown -R nobody:nogroup /nfs
sudo chmod -R 777 /nfs
✅ These directories match the
path:fields used in your Kubernetes PersistentVolumes.
📝 Step 3: Configure NFS Exports
Edit the NFS export configuration:
sudo nano /etc/exports
Add the following lines (replace with your actual subnet):
/nfs/mysql 192.168.88.0/24(rw,sync,no_subtree_check,no_root_squash)
/nfs/mariadb 192.168.88.0/24(rw,sync,no_subtree_check,no_root_squash)
/nfs/wordpress 192.168.88.0/24(rw,sync,no_subtree_check,no_root_squash)
/nfs/moodle 192.168.88.0/24(rw,sync,no_subtree_check,no_root_squash)
/nfs/moodledata 192.168.88.0/24(rw,sync,no_subtree_check,no_root_squash)
/nfs/grafana 192.168.88.0/24(rw,sync,no_subtree_check,no_root_squash)
/nfs/prometheus 192.168.88.0/24(rw,sync,no_subtree_check,no_root_squash)
Explanation:
rw: read/write accesssync: write operations are flushed immediatelyno_subtree_check: improves reliabilityno_root_squash: allows root access from clients (needed for containers)
🔄 Step 4: Export Shared Directories
Apply the configuration:
sudo exportfs -a
🚀 Step 5: Start and Enable NFS Server
sudo systemctl restart nfs-kernel-server
sudo systemctl enable nfs-kernel-server
🧪 Step 6: Test from a Kubernetes Node or Client
Install NFS client (on client or node):
sudo apt install nfs-common
Create a mount point and test:
sudo mkdir -p /mnt/nfs-test
sudo mount 192.168.88.61:/nfs/mysql /mnt/nfs-test
Check permissions:
touch /mnt/nfs-test/testfile.txt
📌 Optional: Make NFS Mount Persistent (Not Required for K8s)
If testing outside of Kubernetes, add to /etc/fstab:
192.168.88.61:/nfs/mysql /mnt/nfs-test nfs defaults 0 0
✅ Ready for Kubernetes
Now you can create PersistentVolumes using:
nfs:
server: 192.168.88.61
path: /nfs/mysql # or /nfs/mariadb, /nfs/wordpress, /nfs/prometheus, etc.
Make sure these paths are exported and accessible from all Kubernetes nodes.