Skip to content

Create Service for Admin UI

To expose the Admin UI to external clients (outside of your cluster) run the following command to create a LoadBalancer service.

kubectl apply -f cloud-proxy-ui-service.yaml --validate

The cloud-proxy-ui-service.yaml file looks like the following.

apiVersion: v1
kind: Service
  name: cloud-proxy-ui
  type: LoadBalancer
    app: cloud-proxy-ui
    - port: 80
      targetPort: 80

To see the status of the created service run kubectl get services, the output should show our service is up and running.

# kubectl get services
NAME                  TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
cloud-proxy-ui        LoadBalancer   <pending>     80:30459/TCP   12d
kubernetes            ClusterIP       <none>        443/TCP        12d

Note that in our on-premises Kubernetes cluster specific NodePort of 30459 was automatically allocated for our service. We can use this port when configuring manual haproxy load balancer for external access to this service. Relevant portions of the /etc/haproxy/haproxy.cfg file are shown below.

        log     global
        mode    tcp
        option  tcplog
        option  dontlognull

        timeout connect 5000
        timeout client  50000
        timeout server  50000

frontend ui
    default_backend ui_pool

backend ui_pool
    balance roundrobin
    mode tcp
    server k8s-wp1 check
    server k8s-wp2 check

In Azure Kubernetes Service or Google Kubernetes Engine such load balancer is configured automatically without any administrative efforts from your side.