cp-docker-images icon indicating copy to clipboard operation
cp-docker-images copied to clipboard

Make URL's in Confluent Control-Center front-end UI relative iso absolute

Open boeboe opened this issue 7 years ago • 8 comments

Hi all,

I am using the docker images of confluent to deploy the confluent stack (kafka, zookeeper, schema-registry, rest-proxy and control-center) on Kubernetes. I am using an nginx ingress controller to expose the control center's dashboard (using path routing):

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress-control-center
  annotations:
    ingress.kubernetes.io/rewrite-target: /
    ingress.kubernetes.io/add-base-url: "true"
spec:
  rules:
  - http:
      paths:
      - path: /control-center
        backend:
          serviceName: control-center-svc
          servicePort: 9021

The ingress.kubernetes.io/add-base-url ensures that in the HTML returned, a base-url header is injected in order for later scripts/urls to be correctly resolvable over the path based ingress controller. The result looks like this:

<!DOCTYPE html>
<html>
  <head><base href="https://kubernetes-ingress.mydomain.com/control-center/">
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <title>Control Center</title>
  <link rel="shortcut icon" href="/dist/favicon.ico"><link href="/dist/main-14ed7341cd326a596d21.css" rel="stylesheet"></head>
  <body>
    <div id="controlcenter" style="height: 100%"></div>
  <script type="text/javascript" src="/dist/manifest.js"></script><script type="text/javascript" src="/dist/vendor.js"></script><script type="text/javascript" src="/dist/main.js"></script></body>
</html>

As one can see, the links however all are using absolute URL's, which is why the page is not properly loading behind this nginx reverse proxy.

I was wondering if you would be willing to switch the URL's to be relative (I would try to change this myself using some linux sed magic, but it seems that the code is embedded in a jar).

REF: https://github.com/kubernetes/ingress-nginx/blob/master/docs/annotations.md

PS: not sure this is the right repo, but I could not find a control-center specific one. PPS: the result of the port-confluent-to-kubernetes exercise (I had to extend the docker images of Kafka and Zookeeper to make it work FYI):

# kubectl version
Client Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.1", GitCommit:"3a1c9449a956b6026f075fa3134ff92f7d55f812", GitTreeState:"clean", BuildDate:"2018-01-04T19:58:48Z", GoVersion:"go1.9.2", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"8", GitVersion:"v1.8.6", GitCommit:"6260bb08c46c31eea6cb538b34a9ceb3e406689c", GitTreeState:"clean", BuildDate:"2017-12-21T06:23:29Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}

# kubectl get pods -o wide
NAME                              READY     STATUS              RESTARTS   AGE       IP              NODE
control-center-ff6995d6-l2pbd     1/1       Running             0          1h        172.24.38.205   node-172-16-24-36
kafka-0                           1/1       Running             0          1h        172.24.27.107   node-172-16-24-24
kafka-1                           1/1       Running             0          1h        172.24.28.23    node-172-16-24-28
kafka-2                           1/1       Running             0          1h        172.24.38.192   node-172-16-24-36
kafka-connect-6c7f78cf4f-lwjn5    1/1       Running             0          16m       172.24.39.107   node-172-16-24-36
rest-proxy-578494fd86-b4cmg       1/1       Running             0          11m       172.24.39.117   node-172-16-24-36
schema-registry-b8996c9b5-xj4qj   1/1       Running             0          1h        172.24.27.114   node-172-16-24-24
zookeeper-0                       1/1       Running             0          1h        172.24.38.180   node-172-16-24-36
zookeeper-1                       1/1       Running             0          1h        172.24.27.100   node-172-16-24-24
zookeeper-2                       1/1       Running             0          1h        172.24.21.14    node-172-16-24-20

boeboe avatar Jan 12 '18 23:01 boeboe

Do you mind share you're experience with kubernetes ? Stability etc...

Patafix avatar Mar 19 '18 18:03 Patafix

We didn't see stability issues so far. Partitioning/replication in combo with a flexible scalable kubernetes platform is an ideal combo.

boeboe avatar Mar 19 '18 18:03 boeboe

We are running into the same issue; actually we run 2 CP releases on one k8s cluster and like to route both control-center UI's over one ingress-controller. We use the sub_filter to rewrite paths in the response but it doesn't work for .js packages being send back that initialize the frontend.

What is needed is support for proxy on a path by the app itself.

annotations:
  kubernetes.io/ingress.class: "nginx"
  nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
  nginx.ingress.kubernetes.io/rewrite-target: /$2
  nginx.ingress.kubernetes.io/use-regex: "true"
  nginx.ingress.kubernetes.io/auth-type: basic
  nginx.ingress.kubernetes.io/auth-secret: basic-auth-admin
  nginx.ingress.kubernetes.io/auth-realm: "Authentication Required"
  nginx.ingress.kubernetes.io/configuration-snippet: |
    proxy_set_header Accept-Encoding "";
    sub_filter_once off;
    sub_filter 'href="/dist/' 'href="/control-center/dist/';
    sub_filter 'src="/dist/' 'src="/control-center/dist/';

Alternatives would be to distinguish on host or port on the ingress and leave the control-center in the root (but both are not an option for us).

Paul424 avatar Dec 18 '19 08:12 Paul424

It should be a simple change in the jar file, but that's up to Confluent team to take this issue serious.

boeboe avatar Dec 18 '19 08:12 boeboe

Can we get this fixed quickly? Not good for an enterprise tool!!

Durairaj avatar Feb 28 '20 16:02 Durairaj

Was looking for the setting to do this and found it doesn't yet exist! This feature is a must have for our deployment.

thejml avatar Sep 02 '20 12:09 thejml

Because of security it should be possible to access the control center through kubectl proxy instead of an ingress but this isn't possible because of the absolute urls.

head1328 avatar Mar 06 '21 09:03 head1328

Did anybody find a solution for this issue, so far? Any clue is highly appreciated!

sashati avatar May 21 '21 15:05 sashati