【发布时间】:2017-05-24 20:30:30
【问题描述】:
我目前在一个 K8S 集群中工作,我暴露了以下端点。
http://172.16.46.16:8080/websocket/metrics
现在我拥有的应用程序与 Sprint Boot 相关。为了点击这个 URL,它目前是敏感的,这意味着它需要一个用户名/密码。
根据documentation,我可以关闭metrics上的敏感功能,这样我就不需要用户名/密码来授权自己了。由于我不想在配置中对此进行硬编码,因此我在运行时传递了所需的参数。
我的 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
我能够访问我的 pod 并查找任何错误,但我没有看到任何错误。
我在这里缺少什么吗?
【问题讨论】:
标签: spring spring-boot kubernetes spring-boot-actuator prometheus