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
metadata:
  name: cloud-proxy-ui
spec:
  type: LoadBalancer
  selector:
    app: cloud-proxy-ui
  ports:
    - 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   10.100.134.74   <pending>     80:30459/TCP   12d
kubernetes            ClusterIP      10.96.0.1       <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.

defaults
        log     global
        mode    tcp
        option  tcplog
        option  dontlognull

        timeout connect 5000
        timeout client  50000
        timeout server  50000

frontend ui
    bind 192.168.10.10:80
    default_backend ui_pool

backend ui_pool
    balance roundrobin
    mode tcp
    server k8s-wp1 192.168.10.14:30459 check
    server k8s-wp2 192.168.10.15:30459 check

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