GUI Free Life View on GitHub

Configuring OpenShift with Multiple Sharded Routers

haproxy kubernetes OCP3.3 openshift router

Jan 29, 2017

I needed to host a service that would be consumed by a closed client that insists on speaking HTTPS on port 50,000. To solve this, I added a 2nd router deployment and used the OpenShift router sharding feature to selectively enable routes on the 2nd router by way of selectors.

To summarize:

Existing HA router:

Added HA router:

How To

Open infra node firewalls

 iptables -A OS_FIREWALL_ALLOW -m tcp -p tcp --dport 49999 -j ACCEPT
 iptables -A OS_FIREWALL_ALLOW -m tcp -p tcp --dport 50000 -j ACCEPT
- hosts: infra-nodes

    os_firewall_use_firewalld: False
      - service: teradici-http
        port: 49999/tcp
      - service: teradici-https
        port: 50000/tcp

    - os_firewall

Create a router

[root@ose-test-master-01 ~]# oc get nodes --show-labels
NAME                           STATUS    AGE       LABELS   Ready     180d,region=master,zone=rhev   Ready     180d,region=master,zone=rhev     Ready     180d      ha-router=primary,,region=infra,zone=rhev     Ready     180d      ha-router=primary,,region=infra,zone=rhev     Ready     180d,region=primary,zone=rhev     Ready     180d,region=primary,zone=rhev

[root@ose-test-master-01 ~]#  oadm router ha-router-teradici \
    --ports='49999:49999,50000:50000' \
    --stats-port=51936 \
    --replicas=2 \
    --selector="ha-router=primary" \
    --selector="region=infra" \
    --labels="ha-router=teradici" \ \

GOOD: I see that the ports are set properly in the haproxy.config and the service objects

[root@ose-test-master-01 ~]# oc get all -l ha-router=teradici
NAME                            REVISION        DESIRED       CURRENT   TRIGGERED BY
dc/ha-router-teradici           1               2             2         config
NAME                            DESIRED         CURRENT       AGE
rc/ha-router-teradici-1         2               2             15m
NAME                            CLUSTER-IP      EXTERNAL-IP   PORT(S)                         AGE
svc/ha-router-teradici   <none>        49999/TCP,50000/TCP,51936/TCP   15m
NAME                            READY           STATUS        RESTARTS                        AGE
po/ha-router-teradici-1-3ctx5   1/1             Running       0                               14m
po/ha-router-teradici-1-w8plh   1/1             Running       0                               14m

BAD: However, the env in the DC is partially incorrect:

[root@ose-test-master-01 ~]# oc get dc ha-router-teradici -o json \
  | jq -c '. | .spec.template.spec.containers[].env[] | select(.name | contains("PORT")) '

I think that should be considered a bug in the oadm router command.

The haproxy template uses those values to bind ports like this:

$ docker run --rm --interactive=true --tty --entrypoint=cat \ haproxy-config.template | grep -B1 'bind '
frontend public
  bind :
  frontend public_ssl
  bind :
    # terminate ssl on edge
  bind ssl no-sslv3 crt crt /var/lib/haproxy/conf/default_pub_keys.pem crt /certs accept-proxy
    # terminate ssl on edge
  bind ssl no-sslv3 crt crt /var/lib/haproxy/conf/default_pub_keys.pem accept-proxy

Fix the router deploymentconfig

[root@ose-test-master-01 ~]# oc set env dc/ha-router-teradici  ROUTER_SERVICE_HTTP_PORT=49999
[root@ose-test-master-01 ~]# oc set env dc/ha-router-teradici  ROUTER_SERVICE_HTTPS_PORT=50000

BAD: Docker inspect still shows me the container is on port 80 and 443. That is because of the hardcoded EXPOSE directive in the Dockerfile. Based on the ENV this seems to be a non-issue.

[root@ose-test-node-01 ~]# docker inspect --format=''  dd02066d4845
map[443/tcp:{} 53/tcp:{} 80/tcp:{} 8443/tcp:{}]

[root@ose-test-master-01 ~]# docker run --rm --interactive=true --tty --entrypoint=grep \ \
  EXPOSE /var/lib/haproxy/Dockerfile-openshift3-ose-haproxy-router-v3.3.1.7-0
EXPOSE 80 443

Add labels for sharding

[root@ose-test-master-01 ~]# oc set env dc/ha-router-teradici  ROUTE_LABELS="router=teradici"
[root@ose-test-master-01 ~]# oc label route v3simplebottle -n user1 router=teradici

I did not preclude the route from also being reachable on the first existing router as well.


[root@ose-test-master-01 ~]# curl
<h1> hello OpenShift ninjas</h1>

[root@ose-test-master-01 ~]#  curl -k
<h1> hello OpenShift ninjas</h1>

Bugs / Issues

The following things oadm router does not do, and they feel like bugs:

Apparently this isn’t exactly a bug.

See Also