0% found this document useful (0 votes)
10 views

Haproxy installation in OCP Document

The document outlines the steps to install HAProxy in OpenShift Container Platform (OCP), starting with creating a new namespace and defining service and deployment files. It includes configuration for HAProxy, setting up endpoints, and applying necessary YAML files for deployment. Finally, it suggests checking the configuration by accessing a specified URL.

Uploaded by

akshayb.hase
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Haproxy installation in OCP Document

The document outlines the steps to install HAProxy in OpenShift Container Platform (OCP), starting with creating a new namespace and defining service and deployment files. It includes configuration for HAProxy, setting up endpoints, and applying necessary YAML files for deployment. Finally, it suggests checking the configuration by accessing a specified URL.

Uploaded by

akshayb.hase
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Haproxy installation in OCP

1.​ Create new namespace


oc new-project haprxy-bll

2.​ Create haproxy-service file


---
apiVersion: v1
kind: Service
metadata:
name: haproxy-stats
namespace: haprxy-bll
spec:
selector:
app: haproxy
ports:
- name: haproxy-stats
port: 1936
targetPort: 1936
---
apiVersion: v1
kind: Service
metadata:
name: sts-bll-servers
namespace: haprxy-bll
spec:
type: NodePort
selector:
app: haproxy
ports:
- name: sts-bll-servers
protocol: TCP
port: 8004
targetPort: 8004
nodePort: 32753 # Choose a suitable NodePort
3.​ Create haproxy-deployment file
apiVersion: apps/v1
kind: Deployment
metadata:
name: haproxy
namespace: haprxy-bll
spec:
replicas: 20
selector:
matchLabels:
app: haproxy
template:
metadata:
labels:
app: haproxy
spec:
#serviceAccountName: haproxy

containers:
- name: haproxy
#image:
registry.apigw.finopaymentbank.in:9443/haproxy/haproxy:1.8.23-1624151643
#image: registry.connect.redhat.com/haproxytech/haproxy
image: registry.connect.redhat.com/haproxytech/haproxy:1.8.23-1624151643
env:
- name: TZ
value: "Asia/Kolkata"

ports:
- containerPort: 8004

volumeMounts:
- name: haproxy-config-volume
mountPath: /etc/haproxy/haproxy.cfg
subPath: haproxy.cfg

volumes:
- name: haproxy-config-volume
configMap:
name: haproxy-config
4.​ Create HAproxy.cfg file
global
log 10.181.0.68:514 len 1024 local5 info

pidfile /var/lib/haproxy/haproxy.pid
maxconn 4000

# turn on stats unix socket


stats socket /var/lib/haproxy/stats

#---------------------------------------------------------------------
# common defaults that all the 'listen' and 'backend' sections will
# use if not designated in their block
#---------------------------------------------------------------------
defaults
mode http
log global
option httplog
option dontlognull
option http-server-close
option forwardfor except 127.0.0.0/8
option redispatch
retries 3
timeout http-request 90s
timeout queue 90s
timeout connect 90s
timeout client 90s
timeout server 90s
timeout http-keep-alive 90s
timeout check 130s
maxconn 3000
default-server init-addr last,libc,none

#---------------------------------------------------------------------
# round robin balancing between the various backends
#---------------------------------------------------------------------

listen sts-bll-servers
bind *:8004
log-format %H\ %ci:%cp\ [%t]\ %ft\ %b/%s\ %Tq/%Tw/%Tc/%Tr/%Tt\ %ST\ %B\
%CC\ %fp\ %CS\ %tsc\ %ac/%fc/%bc/%sc/%rc\ %sq/%bq\ %hr\ %hs\ %{+Q}r
log 10.181.0.68 local5
balance roundrobin
server node1_10.182.0.200 10.182.0.200:8003 check inter 20s
server node2_10.182.0.201 10.182.0.201:8003 check inter 20s
server node3_10.182.0.202 10.182.0.202:8003 check inter 20s
server node4_10.182.0.203 10.182.0.203:8003 check inter 20s
5.​ Create service to call HAProxy BLL
kind: Service
apiVersion: v1
metadata:
namespace: 3scale-apicast
name: sts-api-servers
spec:
ports:
- name: sts-api-servers
port: 80
targetPort: 8004

6.​ Create Endpoint.yml


kind: Endpoints
apiVersion: v1
metadata:
namespace: 3scale-apicast
name: sts-api-servers
subsets:
- addresses:
- ip: 10.182.1.54
ports:
- port: 32753
name: sts-api-servers

7.​ Create Configmap

8.​ Apply haproxy-service.yaml file


9.​ Apply haproxy-deploymet.yaml file

10.​Apply endpoint.yml file

11.​Apply k8s_service.yaml file

12.​Check configuration by Hitting URL.

You might also like