How do i tie a service to a pod or a set of pods

0 votes
How to tie a specific service to a pod or a set of pods?
Jul 16, 2019 in Kubernetes by Namik
• 1,230 points
1,325 views

1 answer to this question.

0 votes

By declaring pods with the label(s) and by having a selector in the service which acts as a glue to stick the service to the pods.

kind: Service

apiVersion: v1
metadata:
name: my-service
spec:
  selector:
    app: MyApp
ports:
- protocol: TCP
port: 80

Let's say if we have a set of Pods that carry a label "app=MyApp" the service will start routing to those pods.

answered Jul 16, 2019 by Sirajul
• 59,230 points

Related Questions In Kubernetes

0 votes
2 answers

How do I force a pod to run on a specific node?

By default, anti-affinity is not attempted by Kubernetes as ...READ MORE

answered Aug 6, 2019 in Kubernetes by Sirajul
• 59,230 points
4,282 views
0 votes
1 answer

How do I create a service account for my dashboard and get all the credentails

Run the following commands: This command will create ...READ MORE

answered Oct 8, 2018 in Kubernetes by Kalgi
• 52,360 points
1,454 views
+1 vote
1 answer
0 votes
3 answers

Error while joining cluster with node

Hi Kalgi after following above steps it ...READ MORE

answered Jan 17, 2019 in Others by anonymous
14,494 views
+4 votes
1 answer

Installing Web UI (Dashboard):kubernetes-dashboard on main Ubuntu 16.04.6 LTS (Xenial Xerus) server

Follow these steps: $ kubeadm reset $ kubeadm init ...READ MORE

answered Apr 12, 2019 in Kubernetes by Kalgi
• 52,360 points

reshown Apr 12, 2019 by Kalgi 5,957 views
0 votes
1 answer

How do I expose a service to a host outside the cluster?

There are two ways by which we ...READ MORE

answered Jul 12, 2019 in Kubernetes by Sirajul
• 59,230 points
552 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP