如何在 minikube kafka 集群上设置 Cruise Control GUI

How to set up Cruise Control GUI on a minikube kafka cluster

我已经使用 linkedin Cruise Control 在 minikube 上设置了一个 kafka 集群。我正尝试按照 Cruise Control ui git hub page 上的步骤启用 Cruise Control GUI,但它不起作用。

当我从 pod 中卷曲地址时,它 returns 来自我要输入的页面的 html 代码,但是当我在我的网络浏览器中尝试时,该页面没有连接。我想我需要通过服务公开 pod,但它也不起作用。我也尝试更改 cruisecontrol.properties 上的属性,但没有。

Pod 的 运行:

cruise-control-cbdd6bf54-prfts       1/1     Running     2          23h
kafka-0                              1/1     Running     1          23h
kafka-1                              1/1     Running     3          23h
kafka-2                              1/1     Running     1          23h
pzoo-0                               1/1     Running     0          23h
pzoo-1                               1/1     Running     0          23h
pzoo-2                               1/1     Running     1          23h
topic-cruise-control-metrics-fjdlw   0/1     Completed   0          23h
zoo-0                                1/1     Running     1          23h
zoo-1                                1/1     Running     1          23h

定速巡航吊舱

Containers:
  cruise-control:
    Container ID:   docker://b6d43bb8db047480374b19671a761013a2fba39a398215276ffb456a1d9a9f2d
    Image:          solsson/kafka-cruise-control@sha256:f48acf73d09e6cf56f15fd0b9057cad36b3cee20963a52d263732bf7e5c1aae1
    Image ID:       docker-pullable://solsson/kafka-cruise-control@sha256:f48acf73d09e6cf56f15fd0b9057cad36b3cee20963a52d263732bf7e5c1aae1
    Port:           8090/TCP
    Host Port:      0/TCP
    State:          Running
      Started:      Tue, 21 Jul 2020 10:32:27 -0300
    Last State:     Terminated
      Reason:       Error
      Exit Code:    1
      Started:      Tue, 21 Jul 2020 10:31:47 -0300
      Finished:     Tue, 21 Jul 2020 10:31:59 -0300
    Ready:          True
    Restart Count:  2
    Requests:
      cpu:        100m
      memory:     512Mi
    Readiness:    tcp-socket :8090 delay=0s timeout=1s period=10s #success=1 #failure=3
    Environment:  <none>
    Mounts:
      /opt/cruise-control/config from config (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-5kp9f (ro)

cruisecontrol.properties

configurations for the webserver
# ================================

# HTTP listen port
webserver.http.port=8090

# HTTP listen address
webserver.http.address=0.0.0.0

# Whether CORS support is enabled for API or not
webserver.http.cors.enabled=false

# Value for Access-Control-Allow-Origin
webserver.http.cors.origin=http://localhost:8080/

# Value for Access-Control-Request-Method
webserver.http.cors.allowmethods=OPTIONS,GET,POST

# Headers that should be exposed to the Browser (Webapp)
# This is a special header that is used by the
# User Tasks subsystem and should be explicitly
# Enabled when CORS mode is used as part of the
# Admin Interface
webserver.http.cors.exposeheaders=User-Task-ID

# REST API default prefix
# (dont forget the ending *)
webserver.api.urlprefix=/kafkacruisecontrol/*

# Location where the Cruise Control frontend is deployed
webserver.ui.diskpath=./cruise-control-ui/dist/

# URL path prefix for UI
# (dont forget the ending *)
webserver.ui.urlprefix=/*

抄送服务

Name:              cruise-control
Namespace:         mindlabs
Labels:            <none>
Annotations:       Selector:  app=cruise-control
Type:              ClusterIP
IP:                10.98.201.106
Port:              <unset>  8090/TCP
TargetPort:        8090/TCP
Endpoints:         172.18.0.14:8090
Session Affinity:  None
Events:            <none>

感谢您的帮助!

原来我必须将本地 8090 端口转发到集群 8090 端口。 我使用以下方法解决了它:kubectl port-forward svc/cruise-control 8090:8090

默认情况下,Pod 只能通过其在 Kubernetes 集群中的内部 IP 地址访问。

要从 Kubernetes 虚拟网络外部访问容器,您必须将 Pod 公开为 Kubernetes 服务。

在 Minikube 上,LoadBalancer 类型使服务可以通过 minikube service command 访问。需要两个步骤:

kubectl expose deployment _deployment_name_  --type=LoadBalancer --port=8080
minikube service _deployment_name_

对于这种特殊情况,需要将“deployment_name”替换为“cruise-control”

这会打开一个浏览器 window,为您的应用提供服务并显示应用的响应。