问题描述
顾名思义,我想让我的 Spring Boot pod 从 Spring Cloud Config Server pod 中获取配置属性,所有这些都在 Kubernetes 的帮助下,但我被困在两件事上,我不知道怎么办,我认为这是使用 Kubernetes Networking 的错误:
apiVersion: v1
kind: Service
Metadata:
name: fotbalist-service
spec:
selector:
app: fotbalist
ports:
- protocol: 'TCP'
port: 2000
targetPort: 2000
type: LoadBalancer
---
apiVersion: apps/v1
kind: Deployment
Metadata:
name: fotbalist
spec:
replicas: 1
selector:
matchLabels:
app: fotbalist
template:
Metadata:
labels:
app: fotbalist
spec:
containers:
- name: fotbalist-container
image: cinevacineva/fotbalist
imagePullPolicy: Always
ports:
- containerPort: 2000
env:
- name: CONfig
valueFrom:
configMapKeyRef:
name: config-map
key: host
和我的 Spring Cloud Config Server ConfigMap:
#Config ConfigMap
apiVersion: v1
kind: ConfigMap
Metadata:
name: config-map
data:
host: CONfig_SERVICE_HOST
当我尝试以这种方式使用它时得到下一个输出,并且没有连接到获取属性:
c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://CONfig_SERVICE_HOST
c.c.c.ConfigServicePropertySourceLocator : Connect Timeout Exception on Url -http://CONfig_SERVICE_HOST. Will be trying the next url if available
我的另一个应用尝试了不同的方法,连接到 Config 的 app.properties 是相同的,但使用的 ENV 不同:
env:
- name: CONfig
value: CONfig_SERVICE_HOST
输出:
c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: Invalid URL: http://CONfig_SERVICE_HOST:tcp://10.101.163.39:3000
c.p.again.InfoEurekaServerApplication : No active profile set,falling back to default profiles: default
我的 Spring Cloud Config 应用清单/服务:
#service Config
apiVersion: v1
kind: Service
Metadata:
name: config #DNS NAME
labels:
app: config
spec:
selector:
app: config
ports:
- protocol: 'TCP'
port: 3000
targetPort: 3000
type: ClusterIP
---
#Deployment Config
apiVersion: apps/v1
kind: Deployment
Metadata:
name: config
spec:
selector:
matchLabels:
app: config
replicas: 1
template:
Metadata:
labels:
app: config
spec:
containers:
- image: cinevacineva/config
name: config
imagePullPolicy: Always
ports:
- containerPort: 3000
name: config
我做错了什么?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)