Skip to Content
Kubernetes Cookbook - Second Edition
book

Kubernetes Cookbook - Second Edition

by Hideto Saito, Hui-Chuan Chloe Lee, Ke-Jou Carol Hsu
May 2018
Intermediate to advanced
554 pages
13h 51m
English
Packt Publishing
Content preview from Kubernetes Cookbook - Second Edition

Linking Service to Pods or ReplicaSets using label selectors

As of Kubernetes version 1.9, Service only supports the equality-based selector to bind to Pods or ReplicaSet.

Let's create one Service that binds to nginx, which belongs to the production environment and the pilot project. Remember that nginx also belongs to the frontend tier:

//check your selector filter is correct or not$ kubectl get pods -l 'environment=production,project=pilot,tier=frontend'NAME READY STATUS RESTARTS AGEpilot.prod.nginx 1/1 Running 0 19m//create Service yaml that specify selector$ cat pilot-nginx-svc.yaml apiVersion: v1kind: Servicemetadata:  name: pilot-nginx-svcspec:  type: NodePort  ports:    - protocol: TCP      port: 80  selector:    project: pilot environment: production ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Kubernetes Cookbook

Kubernetes Cookbook

Sébastien Goasguen, Michael Hausenblas
DevOps with Kubernetes - Second Edition

DevOps with Kubernetes - Second Edition

Hideto Saito, Hui-Chuan Chloe Lee, Cheng-Yang Wu

Publisher Resources

ISBN: 9781788837606Supplemental Content