我有一个在纯 docker 环境中运行的应用程序。我想在 k8s 中部署它。因此,我创建了配置映射、部署等。下面是部署到 k8s 之前的配置文件。
config:
message:
- type: "fusion:expense:expense_type:v1"
versions:
- version: "v1"
handler:
request_uri: "http://localhost:8082/api/v1/expenses/"
- version: "v2"
handler:
request_uri: "http://localhost:8082/api/v2/expenses/"
- type: "card_type"
versions:
- version: "v1"
handler:
request_uri: "http://localhost:8082/api/v1/cardtype"
ossprovider:
endpoint: "http://localhost:19000"
adaptors:
endpoint: http://localhost:8092/adaptors/
我创建了一个服务
kind: Service
metadata:
name: fin-service
spec:
type: ClusterIP
ports:
- port: 8090
targetPort: 8090
protocol: TCP
name: http
- port: 8082
targetPort: 8082
protocol: TCP
- port: 19000
targetPort: 19000
protocol: TCP
selector:
fin-app
我的部署如下所示:
apiVersion: apps/v1
kind: Deployment
metadata:
name: fin
namespace: {{ .Values.namespace }}
labels:
fin
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
fin
template:
metadata:
labels:
fin
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ .Values.containers.oss_messaginglayer.name }}
image: {{ .Values.image.oss_messaginglayer.repository }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 8090
protocol: TCP
由于我创建了一个服务,我想在配置文件中使用这个服务端点作为 fin-service 而不是 localhost。
app:
config:
message:
- type: "fusion:expense:expense_type:v1"
versions:
- version: "v1"
handler:
request_uri: "http://fin-service:8082/api/v1/expenses/"
- version: "v2"
handler:
request_uri: "http://fin-service:8082/api/v2/expenses/"
- type: "card_type"
versions:
- version: "v1"
handler:
request_uri: "http://fin-service:8082/api/v1/cardtype"
ossprovider:
endpoint: "http://fin-service:19000"
adaptors:
endpoint: http://fin-service:8092/adaptors/
但是我在http://fin-service:19000收到连接被拒绝错误。我在哪里偏离轨道?