redo k8spress

This commit is contained in:
chris 2019-05-21 13:37:13 +02:00
parent 838734f7a9
commit c73b3057b8
2 changed files with 181 additions and 1 deletions

View file

@ -98,7 +98,7 @@ http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-da
## test deployment
helm install --namespace k8spress --name wordpress -f helm-wordpress.yaml stable/wordpress
kubectl apply -f k8spress.yaml
(adapt hostname!)
## teardown

180
k8spress.yaml Normal file
View file

@ -0,0 +1,180 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: k8spress
---
apiVersion: v1
kind: Secret
metadata:
name: mysql-root-pass
namespace: k8spress
type: Opaque
stringData:
password: jer5ohshohl0ohz3yeish3Ied
---
apiVersion: v1
kind: Service
metadata:
namespace: k8spress
name: wordpress-mysql
labels:
app: wordpress
spec:
ports:
- port: 3306
selector:
app: wordpress
tier: mysql
clusterIP: None
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
namespace: k8spress
name: mysql-pv-claim
labels:
app: wordpress
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2Gi
---
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
namespace: k8spress
name: wordpress-mysql
labels:
app: wordpress
spec:
selector:
matchLabels:
app: wordpress
tier: mysql
strategy:
type: Recreate
template:
metadata:
labels:
app: wordpress
tier: mysql
spec:
containers:
- image: mysql:5.6
name: mysql
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mysql-root-pass
key: password
ports:
- containerPort: 3306
name: mysql
volumeMounts:
- name: mysql-persistent-storage
mountPath: /var/lib/mysql
volumes:
- name: mysql-persistent-storage
persistentVolumeClaim:
claimName: mysql-pv-claim
---
apiVersion: v1
kind: Service
metadata:
name: wordpress
namespace: k8spress
labels:
app: wordpress
spec:
ports:
- port: 80
selector:
app: wordpress
tier: frontend
type: LoadBalancer
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: wp-pv-claim
namespace: k8spress
labels:
app: wordpress
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2Gi
---
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
name: wordpress
namespace: k8spress
labels:
app: wordpress
spec:
selector:
matchLabels:
app: wordpress
tier: frontend
strategy:
type: Recreate
template:
metadata:
labels:
app: wordpress
tier: frontend
spec:
containers:
- image: wordpress:4.8-apache
name: wordpress
env:
- name: WORDPRESS_DB_HOST
value: wordpress-mysql
- name: WORDPRESS_DB_PASSWORD
valueFrom:
secretKeyRef:
name: mysql-root-pass
key: password
ports:
- containerPort: 80
name: wordpress
volumeMounts:
- name: wordpress-persistent-storage
mountPath: /var/www/html
volumes:
- name: wordpress-persistent-storage
persistentVolumeClaim:
claimName: wp-pv-claim
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: wordpress-ingress
namespace: k8spress
annotations:
kubernetes.io/ingress.class: "nginx"
certmanager.k8s.io/cluster-issuer: letsencrypt
certmanager.k8s.io/acme-challenge-type: http01
spec:
rules:
- host: k8spress.k.zknt.org
http:
paths:
- backend:
serviceName: wordpress
servicePort: 80
path: /
tls:
- hosts:
- k8spres.k.zknt.org
secretName: k8spress-certificate