DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. Updating HAProxy Configurations in OpenShift

Updating HAProxy Configurations in OpenShift

A quick tutorial on how to fine tune the OpenShift router to make it more secure.

Miloslav Vlach user avatar by
Miloslav Vlach
·
Feb. 06, 17 · Tutorial
Like (1)
Save
Tweet
Share
3.07K Views

Join the DZone community and get the full member experience.

Join For Free

For security reason we need to tune up the OpenShift router. OpenShift router uses the HAProxy. HAProxy has this settings:

acl network_allowed src 20.30.40.50 20.30.40.40
http-request deny if !network_allowed

If there would be any possibility to update the HAProxy configuration it should be working. But how to update the configuration?

The solution is to update the Docker image with the router.

Download the OpenShift proxy from https://github.com/openshift/origin/tree/master/images/router/haproxy and update file conf/haproxy-config.template like this (find the section backend and add those 4 lines):

backend be_edge_http_{{$cfgIdx}}
...
  {{ if (index $cfg.Annotations "rohlik.cz/acl") }}
        acl network_allowed src {{ index $cfg.Annotations "rohlik.cz/acl" }}
        http-request deny if !network_allowed
  {{ end }}  
...

After updating the file you have to build docker image and update the router definition. 

docker build -t rohlik-haproxy:v1.3.1 .

And update the router definition (dc/router in namespace default):

spec:
  strategy:
    type: Rolling
    rollingParams:
      updatePeriodSeconds: 1
      intervalSeconds: 1
      timeoutSeconds: 600
      maxUnavailable: 25%
      maxSurge: 0
      updatePercent: -25
    resources:
  triggers:
    -
      type: ConfigChange
  replicas: 1
  test: false
  selector:
    router: router
  template:
    metadata:
      creationTimestamp: null
      labels:
        router: router
    spec:
      volumes:
        -
          name: server-certificate
          secret:
            secretName: router-certs
      containers:
        -
          name: router
          image: 'rohlik-haproxy:v1.3.1'

Now you are able to use the annotations section in your route definition:

apiVersion: v1
kind: Route
metadata:
  name: rohlik
  namespace: rohlik
  selfLink: /oapi/v1/namespaces/rohlik/routes/rohlik
  labels:
    app: rohlik
  annotations:
    rohlik.cz/acl: 22.22.22.22

Finished :) I hope this article helps you.

OpenShift HAProxy

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • 5 Factors When Selecting a Database
  • Load Balancing Pattern
  • The Quest for REST
  • The Future of Cloud Engineering Evolves

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: