Kubernetes Service Resource needs Deployment Resource Manifest to be applied first in order to forward traffic

6/18/2021

I have the following yaml manifest for the deployment of Orion NGSI Context Broker Pub/Sub mechanism:

apiVersion: apps/v1
kind: Deployment
metadata:
    name: orion
    namespace: kostas
    labels:
        app: orion
spec:
    replicas: 1
    selector:
        matchLabels:
            app: orion
    template:
        metadata:
            labels:
                app: orion
        spec:
            containers:
              - name: orion
                image: fiware/orion:latest
                imagePullPolicy: IfNotPresent
                ports:
                 - containerPort: 1026
                args: ["-dbhost", "mongo:27017", "-logLevel", "INFO"]

And below is the yaml manifest for the relative Nodeport Service

apiVersion: v1
kind: Service
metadata:
  name: orion
  namespace: kostas
spec:
  selector:
    app: orion
  clusterIP: 10.48.0.8
  type: NodePort
  ports:
  - protocol: TCP
    port: 1026
    targetPort: 1026
    nodePort: 32001

The problem is that the service manifest must be applied after the deployment manifest in order to reach the pod.

On the other hand, if i apply the service manifest first, it cannot be mapped with the deployment when it is applied.

Any ideas about why does it happen?

For other microservices there is not such problem.

Should i include an init container field on my deployment manifest? How should i change my deployment manifest for such a case?

-- Kostas Tsakos
fiware-orion
kubernetes

0 Answers