staticpage exmpl

This commit is contained in:
chris 2019-05-19 13:37:13 +02:00
parent 78e51c18a7
commit b4a9b30a3f
4 changed files with 122 additions and 2 deletions

View File

@ -57,8 +57,8 @@ http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-da
scp haproxy.conf root@ssh root@$(hetzner-kube cluster master-ip k8s-test):
ssh root@$(hetzner-kube cluster master-ip k8s-test)
apt install haproxy
mv haproxy.conf /etc/haproxy/haproxy.cfg
apt install -y haproxy
mv haproxy.cfg /etc/haproxy/haproxy.cfg
systemctl restart haproxy
### frontend LB variante 2
@ -66,6 +66,22 @@ http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-da
ssh root@$(hetzner-kube cluster master-ip k8s-test) apt install -y python
ansible-playbook -i "$(hetzner-kube cluster master-ip k8s-test)," -u root ansible-haproxy.yaml
## static page
kubectl apply -f staticpage.yaml
kubectl proxy
http://localhost:8001/api/v1/namespaces/testsite/pods/http:static-nginx:/proxy/#!
### add ingress
kubectl apply -f staticpage-ingress.yaml
## set up SSL
### add ssl to testsite
kubectl apply -f staticpage-ingress-ssl.yaml
## test deployment
helm install --namespace k8spress --name wordpress -f helm-wordpress.yaml stable/wordpress

View File

@ -0,0 +1,37 @@
apiVersion: v1
kind: Service
metadata:
name: web-service
namespace: testsite
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
name: http
selector:
app: web-backend
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: testsite-ingress
namespace: testsite
annotations:
kubernetes.io/ingress.class: "nginx"
certmanager.k8s.io/cluster-issuer: letsencrypt-staging
certmanager.k8s.io/acme-challenge-type: http01
spec:
rules:
- host: test.k.zknt.org
http:
paths:
- backend:
serviceName: web-service
servicePort: 80
path: /
tls:
- hosts:
- test.k.zknt.org
secretName: testsite-certificate

27
staticpage-ingress.yaml Normal file
View File

@ -0,0 +1,27 @@
apiVersion: v1
kind: Service
metadata:
name: web-service
namespace: testsite
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
app: web-backend
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: testsite-ingress
namespace: testsite
spec:
rules:
- host: test.k.zknt.org
http:
paths:
- backend:
serviceName: web-service
servicePort: 80
path: /

40
staticpage.yaml Normal file
View File

@ -0,0 +1,40 @@
apiVersion: v1
kind: Namespace
metadata:
name: testsite
---
apiVersion: v1
kind: ConfigMap
metadata:
name: webdir
namespace: testsite
data:
index.html: |
<html>
<head>
<title>Blank page</title>
</head>
<body>
Nothing here to see.
</body>
</html>
---
apiVersion: v1
kind: Pod
metadata:
name: static-nginx
namespace: testsite
labels:
app: web-backend
spec:
containers:
- name: webserver
image: nginx:alpine
volumeMounts:
- name: webdir
mountPath: /usr/share/nginx/html
volumes:
- name: webdir
configMap:
name: webdir