add scaling haproxy
This commit is contained in:
parent
35e43110b5
commit
ee63e4576d
4 changed files with 155 additions and 2 deletions
|
@ -28,8 +28,8 @@ Re-encrypty | terminate, apply routing rules, re-encrypt | nginx | Advanced
|
|||
|
||||
Name | Description | Platform | Complexity Level
|
||||
-----| ----------- | ---------- | ----------------
|
||||
Daemonset | run multiple controllers in a daemonset | nginx | Intermediate
|
||||
Deployment | run multiple controllers as a deployment | nginx | Intermediate
|
||||
Daemonset | run multiple controllers in a daemonset | nginx/haproxy | Intermediate
|
||||
Deployment | run multiple controllers as a deployment | nginx/haproxy | Intermediate
|
||||
Multi-zone | bridge different zones in a single cluster | gce | Intermediate
|
||||
Static-ip | a single ingress gets a single static ip | * | Intermediate
|
||||
Geo-routing | route to geographically closest endpoint | nginx | Advanced
|
||||
|
|
65
examples/scaling-deployment/haproxy/README.md
Normal file
65
examples/scaling-deployment/haproxy/README.md
Normal file
|
@ -0,0 +1,65 @@
|
|||
# Deploying multi Haproxy Ingress Controllers
|
||||
|
||||
This example aims to demonstrate the Deployment of multi haproxy ingress controllers.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
This ingress controller doesn't yet have support for
|
||||
[ingress classes](/examples/PREREQUISITES.md#ingress-class). You MUST turn
|
||||
down any existing ingress controllers before running HAProxy Ingress controller or
|
||||
they will fight for Ingresses. This includes any cloudprovider controller.
|
||||
|
||||
This document has also the following prerequisites:
|
||||
|
||||
* Create a [TLS secret](/examples/PREREQUISITES.md#tls-certificates) named `tls-secret` to be used as default TLS certificate
|
||||
|
||||
Creating the TLS secret:
|
||||
|
||||
```console
|
||||
$ openssl req \
|
||||
-x509 -newkey rsa:2048 -nodes -days 365 \
|
||||
-keyout tls.key -out tls.crt -subj '/CN=localhost'
|
||||
$ kubectl create secret tls tls-secret --cert=tls.crt --key=tls.key
|
||||
$ rm -v tls.crt tls.key
|
||||
```
|
||||
|
||||
## Default Backend
|
||||
|
||||
The default backend is a service of handling all url paths and hosts the haproxy controller doesn't understand. Deploy the default-http-backend as follow:
|
||||
|
||||
```console
|
||||
$ kubectl create -f default-backend.yaml
|
||||
deployment "default-http-backend" created
|
||||
service "default-http-backend" created
|
||||
|
||||
$ kubectl get svc
|
||||
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
|
||||
default-http-backend 192.168.3.4 <none> 80/TCP 30m
|
||||
|
||||
$ kubectl get pods
|
||||
NAME READY STATUS RESTARTS AGE
|
||||
default-http-backend-q5sb6 1/1 Running 0 30m
|
||||
```
|
||||
|
||||
## Ingress Deployment
|
||||
|
||||
Deploy the Deployment of multi controllers as follows:
|
||||
|
||||
```console
|
||||
$ kubectl apply -f haproxy-ingress-deployment.yaml
|
||||
deployment "haproxy-ingress" created
|
||||
```
|
||||
|
||||
Check if the controller was successfully deployed:
|
||||
```console
|
||||
$ kubectl get deployment
|
||||
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
|
||||
default-http-backend 1 1 1 1 30m
|
||||
haproxy-ingress 2 2 2 2 45s
|
||||
|
||||
$ kubectl get pods
|
||||
NAME READY STATUS RESTARTS AGE
|
||||
default-http-backend-q5sb6 1/1 Running 0 35m
|
||||
haproxy-ingress-1779899633-k045t 1/1 Running 0 1m
|
||||
haproxy-ingress-1779899633-mhthv 1/1 Running 0 1m
|
||||
```
|
49
examples/scaling-deployment/haproxy/default-backend.yaml
Normal file
49
examples/scaling-deployment/haproxy/default-backend.yaml
Normal file
|
@ -0,0 +1,49 @@
|
|||
apiVersion: extensions/v1beta1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: default-http-backend
|
||||
labels:
|
||||
k8s-app: default-http-backend
|
||||
spec:
|
||||
replicas: 1
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
k8s-app: default-http-backend
|
||||
spec:
|
||||
terminationGracePeriodSeconds: 60
|
||||
containers:
|
||||
- name: default-http-backend
|
||||
# Any image is permissable as long as:
|
||||
# 1. It serves a 404 page at /
|
||||
# 2. It serves 200 on a /healthz endpoint
|
||||
image: gcr.io/google_containers/defaultbackend:1.0
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /healthz
|
||||
port: 8080
|
||||
scheme: HTTP
|
||||
initialDelaySeconds: 30
|
||||
timeoutSeconds: 5
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
resources:
|
||||
limits:
|
||||
cpu: 10m
|
||||
memory: 20Mi
|
||||
requests:
|
||||
cpu: 10m
|
||||
memory: 20Mi
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: default-http-backend
|
||||
labels:
|
||||
k8s-app: default-http-backend
|
||||
spec:
|
||||
ports:
|
||||
- port: 80
|
||||
targetPort: 8080
|
||||
selector:
|
||||
k8s-app: default-http-backend
|
|
@ -0,0 +1,39 @@
|
|||
apiVersion: extensions/v1beta1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
run: haproxy-ingress
|
||||
name: haproxy-ingress
|
||||
spec:
|
||||
replicas: 2
|
||||
selector:
|
||||
matchLabels:
|
||||
run: haproxy-ingress
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
run: haproxy-ingress
|
||||
spec:
|
||||
containers:
|
||||
- name: haproxy-ingress
|
||||
image: quay.io/jcmoraisjr/haproxy-ingress
|
||||
imagePullPolicy: IfNotPresent
|
||||
args:
|
||||
- --default-backend-service=default/default-http-backend
|
||||
- --default-ssl-certificate=default/tls-secret
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 80
|
||||
- name: https
|
||||
containerPort: 443
|
||||
- name: stat
|
||||
containerPort: 1936
|
||||
env:
|
||||
- name: POD_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.name
|
||||
- name: POD_NAMESPACE
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.namespace
|
Loading…
Reference in a new issue