SprintBoot - 无法禁用敏感指标

问题描述:

我目前正在K8S群集中工作,并且我已经公开了以下端点。SprintBoot - 无法禁用敏感指标

http://172.16.46.16:8080/websocket/metrics 

现在我有的应用程序是Sprint Boot相关的。为了打这个URL,它目前是敏感的,这意味着它需要一个用户名/密码。

根据documentation,我可以关闭指标的敏感功能,这样我就不需要用户名/密码来授权我自己了。由于我不想在配置中对此进行硬编码,所以我在运行时传递了所需的参数。

我的K8S控制器文件是::

# cat websocket-replication-controller.yaml 
apiVersion: v1 
kind: ReplicationController 
metadata: 
    name: websocket-backend-controller 
spec: 
    replicas: 2 
    selector: 
    name: websocket-backend 
    template: 
    metadata: 
     labels: 
     name: websocket-backend 
     annotations: 
     prometheus.io/scrape: 'true' 
     prometheus.io/path: /websocket/metrics 
     prometheus.io/port: '8080' 
    spec: 
     containers: 
     - name: websocket-backend 
     image: armdocker.rnd.ericsson.se/proj_csdp/websocket_backend:3.0.6 
     imagePullPolicy: IfNotPresent 
     ports: 
      - containerPort: 8080 
     livenessProbe: 
      httpGet: 
      port: 8080 
      path: /websocket/health 
      initialDelaySeconds: 300 
      timeoutSeconds: 30 
     volumeMounts: 
      - name: nfs 
      mountPath: "/vault" 
     command: 
      - java 
      - -Duser.timezone=UTC 
      - -jar 
      - -Dspring.profiles.active=clustered 
      - websocket.jar 
      - --endpoints.metrics.sensitive=false 
     volumes: 
     - name: nfs 
      nfs: 
      server: kube-nfs 
      path: "/kubenfs/vault" 
      readOnly: true 

最后一个命令是这样的:

java -Duser.timezone=UTC -jar -Dspring.profiles.active=clustered websocket.jar --endpoints.metrics.sensitive=false 

启动应用程序这种方式似乎并没有被骑过的指标敏感的行为。我仍然得到server returned HTTP status 401 Unauthorized

enter image description here

我能够进入我的吊舱和寻找任何错误,但我没有看到任何。

有什么我在这里失踪?

尝试禁用Spring Security进行管理太--management.security.enabled=false,命令:

java -Duser.timezone=UTC -jar -Dspring.profiles.active=clustered websocket.jar 
    --endpoints.metrics.sensitive=false 
    --management.security.enabled=false 

在这种情况下是揭露自定义端口如管理端点好主意:management.port=9081

您还可以启用安全性并提供默认用户和密码:

management.security.enabled=true 
security.user.name=user 
security.user.password=pa55word 

请阅读Spring Documentation:Monitoring and management over HTTP