I created a deployment file which runs some service. The service uses port 7777. I want to access the same service from the outside by typing the address x.x.x.x:7777. I am attaching my deployment file which is currently working properly without service. If I download the Ports part from the Deployment and apply to the service, nothing works. I need to prepare a service file because I will soon connect more additional services that will each use the same IP address but on different ports. What is the best way to work in order to achieve my goal?
It should be noted that the Pod also answers on the same port, therefore I also need access to the outside through the same port both from the inside to the outside and from the outside to the inside on the same port 7777.
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
kompose.cmd: kompose convert -f docker-compose.yml
kompose.version: 1.7.0 (HEAD)
creationTimestamp: null
labels:
io.kompose.service: xyz
name: xyz
spec:
replicas: 1
strategy: {}
selector:
matchLabels:
io.kompose.service: xyz
template:
metadata:
creationTimestamp: null
labels:
io.kompose.service: xyz
spec:
nodeSelector:
node: w1
imagePullSecrets:
- name: registry-secret1
volumes:
- name: zzz
hostPath:
path: z/z/z
type: DirectoryOrCreate
- name: yyy
hostPath:
path: y/y/y
type: FileOrCreate
- name: aaa
hostPath:
path: x/x/x
type: FileOrCreate
containers:
- env:
- name: x
value: "x"
- name: y
value: "y"
name: quic-image
image: "xxxyyyzzz"
name: x-y-z
volumeMounts:
- mountPath: x/x/x
name: aaa
- mountPath: y/y/y
name: yyy
- mountPath: z/z/z
name: zzz
ports:
- containerPort: 7777
hostPort: 7777
protocol: UDP
- containerPort: 7777
hostPort: 7777
protocol: TCP
resources: {}
restartPolicy: Always
status: {}
apiVersion: v1
kind: Service
metadata:
annotations:
kompose.cmd: kompose convert -f docker-compose.yml
kompose.version: 1.7.0 (HEAD)
creationTimestamp: null
labels:
io.kompose.service: xyz
name: xyz
spec:
type: NodePort
ports:
- protocol: TCP
name: tcp
port: 7777
- protocol: UDP
name: udp
port: 7777
# targetPort: 7777
selector:
io.kompose.service: xyz
status:
loadBalancer: {}