Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubernetes deployment without a port

Tags:

kubernetes

I have a service which is long-running (in a while 1 loop) and processes payloads via GCloud pub/sub, after which it writes the result to a DB.

The service doesn't need to listen on any port.

What would the declarative YAML config look like for Kind=Deployment?

I understand ClusterIP is the default type, and the docs go on to say that a headless service just has to define spec.clusterIP as None.

(A better practice would probably be to modify the worker to exit after a successful payload processing, and change the Kind to Job, but this is in the backlog)

like image 862
opyate Avatar asked Jan 14 '18 12:01

opyate


People also ask

Is containerPort mandatory?

containerPort. The containerPort option is optional and tells the service to forward the traffic from the service port (defined in port ) to a different containerPort of a pod.

How do I get rid of port forwarding in Kubernetes?

To cancel or quit the kubectl command, you can simply press Ctrl + C and the port forwarding will end immediately.

What is container port in Kubernetes deployment?

“containerPort” defines the port on which app can be reached out inside the container. once your container is spun up and the pod is running. You may need to expose the POD as a service to the external world sometimes. Kubernetes service comes into the picture here.

What ports does kubectl need?

The ports required for a Kubernetes deployment are: 2379/tcp: Kubernetes etcd server client API (on master nodes in multi-master deployments) 2380/tcp: Kubernetes etcd server client API (on master nodes in multi-master deployments) 6443/tcp: Kubernetes API server (master nodes)


1 Answers

What you're describing sounds more like a job or a deployment than a service. You can run a deployment (which creates a replicaset, which ensures a certain number of replicas are running) without creating a service.

If your pod isn't exposing any network services for others to consume, there's very little reason to create a service.

like image 109
Jordan Liggitt Avatar answered Oct 21 '22 04:10

Jordan Liggitt