test-project

This commit is contained in:
tusuii
2026-03-09 22:50:46 +05:30
parent 24dbab7cce
commit 86a1f0b15c
20 changed files with 1192 additions and 3 deletions

View File

@@ -0,0 +1,18 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: mysql-init-sql
namespace: react-mysql
data:
script.sql: |
-- Create the appdb database
CREATE DATABASE IF NOT EXISTS appdb;
-- Use the appdb database
USE appdb;
-- Create the apptb table
CREATE TABLE `appdb`.`apptb` (
`id` INT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(45) NOT NULL,
PRIMARY KEY (`id`));

View File

@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: mysql
namespace: react-mysql
spec:
clusterIP: None
selector:
app: mysql
ports:
- port: 3306
targetPort: 3306

View File

@@ -0,0 +1,66 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mysql
namespace: react-mysql
spec:
serviceName: mysql
replicas: 1
selector:
matchLabels:
app: mysql
template:
metadata:
labels:
app: mysql
spec:
containers:
- name: mysql
image: mysql:8.0
ports:
- containerPort: 3306
envFrom:
- configMapRef:
name: app-config
- secretRef:
name: app-secret
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: app-secret
key: MYSQL_ROOT_PASSWORD
volumeMounts:
- name: mysql-data
mountPath: /var/lib/mysql
- name: mysql-init
mountPath: /docker-entrypoint-initdb.d
resources:
requests:
cpu: 250m
memory: 512Mi
limits:
cpu: 500m
memory: 1Gi
readinessProbe:
exec:
command: ["mysqladmin", "ping", "-h", "localhost"]
initialDelaySeconds: 20
periodSeconds: 10
livenessProbe:
exec:
command: ["mysqladmin", "ping", "-h", "localhost"]
initialDelaySeconds: 40
periodSeconds: 20
volumes:
- name: mysql-init
configMap:
name: mysql-init-sql
volumeClaimTemplates:
- metadata:
name: mysql-data
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 2Gi