Answer the question
In order to leave comments, you need to log in
Kubernetes: Can't link 2 pods together?
Good afternoon.
Started learning kubernetes. There is an API that receives requests via http on port 8085, then connects to gRPC on port 9000, which acts as a data store. Created container images in docker and pushed them.
Wrote 2 Deployment files and 2 Services.
apiVersion: apps/v1
kind: Deployment
metadata:
name: http-http-deployment
labels:
app: http-http
spec:
replicas: 1
selector:
matchLabels:
app: http-http
template:
metadata:
labels:
app: http-http
spec:
containers:
- name: http-http
image: stasbigunenko/http_http
ports:
- containerPort: 8085
apiVersion: apps/v1
kind: Deployment
metadata:
name: http-grpc-deployment
labels:
app: http-grpc
spec:
replicas: 1
selector:
matchLabels:
app: http-grpc
template:
metadata:
labels:
app: http-grpc
spec:
containers:
- name: http-grpc
image: stasbigunenko/http_grpc
ports:
- containerPort: 9000
apiVersion: v1
kind: Service
metadata:
name: http-service
spec:
selector:
app: http-http
ports:
- protocol: TCP
port: 80
targetPort: 8085
apiVersion: v1
kind: Service
metadata:
name: grpc-service
spec:
selector:
app: http-grpc
ports:
- protocol: TCP
port: 81
targetPort: 9000
Answer the question
In order to leave comments, you need to log in
One of the fixes would be manifests like this
apiVersion: apps/v1
kind: Deployment
metadata:
name: http-http-deployment
labels:
app: http-http
spec:
replicas: 1
selector:
matchLabels:
app: http-http
template:
metadata:
labels:
app: http-http
spec:
containers:
- name: http-http
image: stasbigunenko/http_http
env:
- name: PORT_HTTP
value: ":8085"
- name: GRPC
value: "grpc-service:9000"
ports:
- containerPort: 8085
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: http-grpc-deployment
labels:
app: http-grpc
spec:
replicas: 1
selector:
matchLabels:
app: http-grpc
template:
metadata:
labels:
app: http-grpc
spec:
containers:
- name: http-grpc
image: stasbigunenko/http_grpc
env:
- name: TCP_PORT
value: ":9000"
ports:
- containerPort: 9000
---
apiVersion: v1
kind: Service
metadata:
name: http-service
spec:
selector:
app: http-http
ports:
- protocol: TCP
port: 8085
---
apiVersion: v1
kind: Service
metadata:
name: grpc-service
spec:
selector:
app: http-grpc
ports:
- protocol: TCP
port: 9000
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question