Merge k8s config into one file

This commit is contained in:
Florian RICHER 2025-03-27 10:58:47 +01:00
parent 4dc2cb0977
commit d0e4ee91a4
12 changed files with 209 additions and 201 deletions

View file

@ -1,9 +0,0 @@
apiVersion: v1
kind: Secret
metadata:
name: mysql-secret
type: Opaque
data:
# Encoded base64 string required by kubernetes
# echo -n '<wanted_value>' | base64
mysql-root-password: cm9vdA==

View file

@ -1,46 +0,0 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mysql-db-deployment
labels:
app: mysql-db
spec:
serviceName: mysql-db-service
replicas: 1
selector:
matchLabels:
app: mysql-db
template:
metadata:
labels:
app: mysql-db
spec:
containers:
- name: mysql
image: mysql:9
resources:
requests:
memory: "512Mi"
cpu: "1000m"
limits:
memory: "2048Mi"
cpu: "2000m"
ports:
- containerPort: 3306
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mysql-secret
key: mysql-root-password
volumeMounts:
- name: mysql-data
mountPath: /var/lib/mysql
volumeClaimTemplates:
- metadata:
name: mysql-data
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 1Gi

View file

@ -1,12 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: mysql-db-service
spec:
type: ClusterIP
selector:
app: mysql-db
ports:
- protocol: TCP
port: 3306
targetPort: 3306

View file

@ -1,6 +0,0 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: mysql-configmap
data:
mysql-server: mysql-db-service

View file

@ -1,38 +0,0 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql-phpmyadmin-deployment
labels:
app: mysql-phpmyadmin
spec:
replicas: 2
selector:
matchLabels:
app: mysql-phpmyadmin
template:
metadata:
labels:
app: mysql-phpmyadmin
spec:
containers:
- name: phpmyadmin
image: phpmyadmin:5.2
resources:
limits:
memory: "256Mi"
cpu: "1000m"
ports:
- containerPort: 80
env:
- name: PMA_HOST
valueFrom:
configMapKeyRef:
name: mysql-configmap
key: mysql-server
- name: PMA_USER
value: root
- name: PMA_PASSWORD
valueFrom:
secretKeyRef:
name: mysql-secret
key: mysql-root-password

View file

@ -1,14 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: mysql-phpmyadmin-service
labels:
app: mysql-phpmyadmin
spec:
type: ClusterIP
selector:
app: mysql-phpmyadmin
ports:
- protocol: TCP
port: 80
targetPort: 80

View file

@ -1,18 +0,0 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: mysql-phpmyadmin-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
ingressClassName: nginx
rules:
- http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: mysql-phpmyadmin-service
port:
number: 80

149
mysql/k8s/kube.yaml Normal file
View file

@ -0,0 +1,149 @@
apiVersion: v1
kind: Secret
metadata:
name: mysql-secret
type: Opaque
data:
# Encoded base64 string required by kubernetes
# echo -n '<wanted_value>' | base64
mysql-root-password: cm9vdA==
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mysql-db-deployment
labels:
app: mysql-db
spec:
serviceName: mysql-db-service
replicas: 1
selector:
matchLabels:
app: mysql-db
template:
metadata:
labels:
app: mysql-db
spec:
containers:
- name: mysql
image: mysql:9
resources:
requests:
memory: "512Mi"
cpu: "1000m"
limits:
memory: "2048Mi"
cpu: "2000m"
ports:
- containerPort: 3306
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mysql-secret
key: mysql-root-password
volumeMounts:
- name: mysql-data
mountPath: /var/lib/mysql
volumeClaimTemplates:
- metadata:
name: mysql-data
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 1Gi
---
apiVersion: v1
kind: Service
metadata:
name: mysql-db-service
spec:
type: ClusterIP
selector:
app: mysql-db
ports:
- protocol: TCP
port: 3306
targetPort: 3306
---
apiVersion: v1
kind: ConfigMap
metadata:
name: mysql-configmap
data:
mysql-server: mysql-db-service
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql-phpmyadmin-deployment
labels:
app: mysql-phpmyadmin
spec:
replicas: 2
selector:
matchLabels:
app: mysql-phpmyadmin
template:
metadata:
labels:
app: mysql-phpmyadmin
spec:
containers:
- name: phpmyadmin
image: phpmyadmin:5.2
resources:
limits:
memory: "256Mi"
cpu: "1000m"
ports:
- containerPort: 80
env:
- name: PMA_HOST
valueFrom:
configMapKeyRef:
name: mysql-configmap
key: mysql-server
- name: PMA_USER
value: root
- name: PMA_PASSWORD
valueFrom:
secretKeyRef:
name: mysql-secret
key: mysql-root-password
---
apiVersion: v1
kind: Service
metadata:
name: mysql-phpmyadmin-service
labels:
app: mysql-phpmyadmin
spec:
type: ClusterIP
selector:
app: mysql-phpmyadmin
ports:
- protocol: TCP
port: 80
targetPort: 80
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: mysql-phpmyadmin-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
ingressClassName: nginx
rules:
- http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: mysql-phpmyadmin-service
port:
number: 80

View file

@ -1,28 +0,0 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
resources:
requests:
memory: "32Mi"
cpu: 128m
limits:
memory: "64Mi"
cpu: 256m

View file

@ -1,12 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
type: ClusterIP
selector:
app: nginx
ports:
- protocol: TCP
port: 8000
targetPort: 80

View file

@ -1,18 +0,0 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nginx-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
ingressClassName: nginx
rules:
- http:
paths:
- path: /nginx
pathType: Prefix
backend:
service:
name: nginx-service
port:
number: 8000

60
nginx/k8s/kube.yaml Normal file
View file

@ -0,0 +1,60 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
resources:
requests:
memory: "32Mi"
cpu: 128m
limits:
memory: "64Mi"
cpu: 256m
---
apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
type: ClusterIP
selector:
app: nginx
ports:
- protocol: TCP
port: 8000
targetPort: 80
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nginx-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
ingressClassName: nginx
rules:
- http:
paths:
- path: /nginx
pathType: Prefix
backend:
service:
name: nginx-service
port:
number: 8000