OPENSHIFT

Custom OpenShift 4 Ingress Router

#router , #ingress , #kubernetes

Custom OpenShift 4 Ingress Router

This solution is incomplete and is mostly scratch notes. This design is NOT supported by Red Hat! Use at your own risk.

  1. Create custom HAProxy Template

  2. Create a ConfigMap From the HAProxy Template (these are incomplete Ansible tasks/plays)

- name: slurp
  slurp:
    src: template file
  register: haproxy-template

- name:
  k8s:
    state: present
    namespace: openshift-ingress
    definition:
      apiVersion: v1
      kind: ConfigMap
      metadata:
        name: haproxy-template
      data:
        haproxy-config.template: "{{ haproxy-template | b64decode }}"
  1. Create a TLS secret for the Custom Domain (use your favorite Secrets sync solution)

  2. Create a Custom Router Deployment

    1. get deployment

    2. remove unneeded fields, rename object

    3. oc volume add --dry-run

    4. create deployment

  3. Create the internal Service for the Custom Router

    1. get service

    2. remove unneeded fields, rename object

    3. modify fields

    4. create service

  4. Create the LoadBalancer Service (AWS) for the Custom Router

    1. get service

    2. remove unneeded fields, rename object

    3. modify fields

    4. create service

  5. Wait for the LoadBalancer Service to create an ELB

- name: Wait
  k8s:
    state: present
    name: router-custom
    namespace: openshift-ingress
    api_version: v1
    kind: Service
  delay: 5
  retries: 10
  register: loadbalancer
  until: (loadbalancer.results.status.loadBalancer is defined) and (loadbalancer.result.status.loadBalancer.ingress is defined) and (loadbalancer.result.status.loadBalancer.ingress[0].hostname is defined) and (loadbalancer.result.status.loadBalancer.ingress[0].hostname|length > 0)

. Get the Generated ELB name (loadbalancer.result.status.loadBalancer.ingress[0].hostname)

- name:
  set_fact:
    generated_elb_name: "{{ loadbalancer.result.status.loadBalancer.ingress[0].hostname }}"
  1. Create a DNSRecord in openshift-ingress-operator namespace for the Custom Router

- name:
  k8s:
    state: present
    definition:
      TODO