cm-and-secret

This commit is contained in:
xcad2k 2021-11-12 15:38:36 +01:00
parent 75ce1f3e7a
commit 8f62f0c812
10 changed files with 202 additions and 1 deletions

View File

@ -0,0 +1,30 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql
spec:
replicas: 1
selector:
matchLabels:
app: mysql
template:
metadata:
labels:
app: mysql
spec:
containers:
- image: mysql:5.6
name: mysql
env:
- name: MYSQL_ROOT_PASSWORD
value: "password-in-cleartext"
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:
root-pass: test123

View File

@ -0,0 +1,21 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-http-cm
data:
nginx.conf: |
user nginx;
worker_processes 1;
events {
worker_connections 10240;
}
http {
server {
listen 80;
server_name _;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
}
}

View File

@ -0,0 +1,32 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-http
spec:
replicas: 1
selector:
matchLabels:
app: nginx-http
template:
metadata:
labels:
app: nginx-http
spec:
containers:
- name: nginx-http
image: nginx
ports:
- name: web
containerPort: 80
volumeMounts:
- name: nginx-http-cm
mountPath: /etc/nginx
- name: nginx-http-vol
mountPath: /usr/share/nginx/html
volumes:
- name: nginx-http-cm
configMap:
name: nginx-http-cm
- name: nginx-http-vol
hostPath:
path: /var/nginxserver

View File

@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: nginx-http-svc
labels:
app: nginx-http
spec:
type: LoadBalancer
ports:
- port: 30080
targetPort: 80
protocol: TCP
name: http
selector:
app: nginx-http

View File

@ -0,0 +1,27 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-https-cm
data:
nginx.conf: |
user nginx;
worker_processes 1;
events {
worker_connections 10240;
}
http {
server {
listen 80;
listen 443 ssl;
server_name _;
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;
}
}
}

View File

@ -0,0 +1,38 @@
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: secureweb
containerPort: 443
volumeMounts:
- name: nginx-https-cm
mountPath: /etc/nginx
- name: nginx-https-secret
mountPath: /etc/nginx/ssl
readOnly: true
- name: nginx-https-vol
mountPath: /usr/share/nginx/html
volumes:
- name: nginx-https-cm
configMap:
name: nginx-https-cm
- name: nginx-https-secret
secret:
secretName: nginx-https-secret
- name: nginx-https-vol
hostPath:
path: /var/nginxserver

View File

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

View File

@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
name: nginx-https-svc
labels:
app: nginx-https
spec:
type: LoadBalancer
ports:
- port: 31080
targetPort: 80
protocol: TCP
name: http
- port: 31443
targetPort: 443
protocol: TCP
name: https
selector:
app: nginx-https

View File

@ -24,4 +24,4 @@ spec:
volumes: volumes:
- name: local - name: local
hostPath: hostPath:
path: /usr/share/nginx/html path: /var/nginxserver