This commit is contained in:
Jarosław Karcewicz 2022-03-27 23:02:36 +02:00
parent 4822459531
commit 3752df60bd
9 changed files with 345 additions and 0 deletions

View File

@ -0,0 +1,33 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql
spec:
replicas: 1
selector:
matchLabels:
app: mysql
template:
metadata:
labels:
app: mysql
spec:
containers:
- image: tobi312/rpi-mariadb:10.5
name: mysql
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mysql-secret
key: roota-haslo
ports:
- name: mysql
containerPort: 3306
# volumeMounts:
# - name: mysql-vol
# mountPath: /var/lib/mysql
# volumes:
# - name: mysql-vol
# hostPath:
# path: /var/mysql-data

View File

@ -0,0 +1,7 @@
apiVersion: v1
kind: Secret
metadata:
name: mysql-secret
type: Opaque
stringData:
roota-haslo: Zaq12wsx

View File

@ -0,0 +1,28 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-cm
data:
# key: value
# file: |
# content
# ---
nginx.conf: |
user nginx;
worker_processes 1;
events {
worker_connections 1024;
}
http {
server {
listen 80;
server_name example.com;
location / {
root /usr/share/nginx/html;
index index.html index.htm index.php;
}
location /test {
return 401;
}
}
}

View File

@ -0,0 +1,64 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
spec:
replicas: 1
selector:
matchLabels:.
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
ports:
- name: web
containerPort: 80
volumeMounts:
- name: nginx-cm
mountPath: /etc/nginx
- name: wolumin1
mountPath: /usr/share/nginx/html
volumes:
- name: nginx-cm
configMap:
name: nginx-cm
- name: wolumin1
hostPath:
path: /var/nginx
type: DirectoryOrCreate
---
apiVersion: v1
kind: Service
metadata:
name: nginx
labels:
app: nginx
spec:
type: LoadBalancer
ports:
- port: 8880
targetPort: 80
protocol: TCP
selector:
app: nginx
---
apiVersion: v1
kind: ConfigMap
metadata:
namespace: metallb-system
name: config
data:
config: |
address-pools:
- name: default
protocol: layer2
addresses:
- 192.168.100.230-192.168.100.235

View File

@ -0,0 +1,104 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-https
spec:
replicas: 1
selector:
matchLabels:
app: nginx-https
template:
metadata:
labels:
app: nginx-https
spec:
containers:
- name: nginx-https
image: nginx
ports:
- name: web
containerPort: 80
ports:
- name: sslweb
containerPort: 443
volumeMounts:
- name: nginx-cm
mountPath: /etc/nginx
- name: nginx-secret
mountPath: /etc/nginx/ssl
readOnly: true
- name: wolumin1
mountPath: /usr/share/nginx/html
volumes:
- name: nginx-cm
configMap:
name: nginx-cm
- name: nginx-secret
configMap:
name: nginx-secret
- name: wolumin1
hostPath:
path: /var/nginx
type: DirectoryOrCreate
---
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-cm
data:
nginx.conf: |
user nginx;
worker_processes 1;
events {
worker_connections 1024;
}
http {
server {
listen 80;
listen 443 ssl;
server_name example.com;
ssl_certificate /etc/nginx/ssl/server-cert.pem;
ssl_certificate_key /etc/nginx/ssl/server-key.pem;
location / {
root /usr/share/nginx/html;
index index.html index.htm index.php;
}
}
}
---
apiVersion: v1
kind: Service
metadata:
name: nginx-https
labels:
app: nginx-https
spec:
type: LoadBalancer
ports:
- port: 8880
targetPort: 80
protocol: TCP
name: http
- port: 8443
targetPort: 443
protocol: TCP
name: https
selector:
app: nginx-https
---
apiVersion: v1
kind: ConfigMap
metadata:
namespace: metallb-system
name: config
data:
config: |
address-pools:
- name: default
protocol: layer2
addresses:
- 192.168.100.230-192.168.100.235

View File

@ -0,0 +1,14 @@
apiVersion: v1
kind: Secret
metadata:
name: nginx-secret
type: Opaque
stringData:
server-cert.pem: |
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
server-key.pem: |
-----BEGIN PRIVATE KEY-----
...
-----END PRIVATE KEY

13
K3S-NFS/nfs-pv.yml Normal file
View File

@ -0,0 +1,13 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: nfs
spec:
capacity:
storage: 500Mi
accessModes:
- ReadWriteMany
storageClassName: nfs
nfs:
server: 192.168.100.185
path: "/volume1/nginx"

11
K3S-NFS/nfs-pvc.yml Normal file
View File

@ -0,0 +1,11 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: nfs
spec:
accessModes:
- ReadWriteMany
storageClassName: nfs
resources:
requests:
storage: 100Mi

View File

@ -0,0 +1,71 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
volumeMounts:
- name: wolumin1
mountPath: /usr/share/nginx/html
volumes:
- name: wolumin1
persistentVolumeClaim:
claimName: nfs
#---
#apiVersion: v1
#kind: PersistentVolumeClaim
#metadata:
# name: nfs
#spec:
# accessModes:
# - ReadWriteMany
# storageClassName: nfs
# resources:
# requests:
# storage: 100Mi
---
apiVersion: v1
kind: Service
metadata:
name: nginx
labels:
app: nginx
spec:
type: LoadBalancer
ports:
- port: 8088
targetPort: 80
protocol: TCP
selector:
app: nginx
---
apiVersion: v1
kind: ConfigMap
metadata:
namespace: metallb-system
name: config
data:
config: |
address-pools:
- name: default
protocol: layer2
addresses:
- 192.168.100.230-192.168.100.235