SlideShare a Scribd company logo
1 of 39
BASEL BERN BRUGG DÜSSELDORF FRANKFURT A.M. FREIBURG I.BR. GENF
HAMBURG KOPENHAGEN LAUSANNE MÜNCHEN STUTTGART WIEN ZÜRICH
Service discovery in Kubernetes with
Fabric8Andy Moncsek
Senior Consultant
Andy.Moncsek@trivadis.com
Twitter: @AndyAHCP
Agenda
2 27.10.2017
1. Why service discovery?
2. Some Kubernetes basics
3. Service discovery in Kubernetes
4. Fabric8 & Service discovery
Service discovery in Kubernetes with Fabric8
Why service discovery ?
Service discovery in Kubernetes with Fabric83 27.10.2017
Why Service discovery ?
Service discovery in Kubernetes with Fabric84 27.10.2017
Dynamically
assigned
172.178.178.1:56477
172.178.178.2:66467
172.178.178.3:76767
Client /
API
Gatewa
y
?
Dynamically
changing
Loadbalancing?
Client-side discovery
Service discovery in Kubernetes with Fabric85 27.10.2017
1. register
2. query
3. request
Client knows
specific
service
instance
Server-side discovery
Service discovery in Kubernetes with Fabric86 27.10.2017
1.
register
2. request
3.
query
4.
Loadbalance
Client does
not know a
specific
service
instance
Some Kubernetes basics
Service discovery in Kubernetes with Fabric87 27.10.2017
Some Kubernetes basics: What it is....
 Kubernetes is platform designed to automate deploying,
scaling, and operating application containers.
 Deploy your applications quickly and predictably.
 Scale your applications on the fly.
 Roll out new features seamlessly.
Service discovery in Kubernetes with Fabric88 27.10.2017
Kubernetes Namespaces
”virtual" cluster
Separates DEV, TEST, PROD, ... environments
9 27.10.2017 Service discovery in Kubernetes with Fabric8
Kubernetes Pods
Group of containers
Shares network/namespace/ IP
Shares environmental variables
Shared volumes
10 27.10.2017 Service discovery in Kubernetes with Fabric8
Kubernetes Controller
11 27.10.2017 Service discovery in Kubernetes with Fabric8
Ensure X pods are running
Pod templates
Rolling update
Kubernetes Services
12 27.10.2017 Service discovery in Kubernetes with Fabric8
Pod discovery
IP per service
1-N port numbers
Route to pods
Load balancer
Kubernetes Services (2)
13 27.10.2017 Service discovery in Kubernetes with Fabric8
Kubernetes Services (3)
14 27.10.2017 Service discovery in Kubernetes with Fabric8
External IP depends on:
Service type = LB
Infrastructure
Kubernetes Services (4)
15 27.10.2017 Service discovery in Kubernetes with Fabric8
Cluster IP:
Internal IP address
Accessible by any
component in
namespace
Kubernetes Services (5)
16 27.10.2017 Service discovery in Kubernetes with Fabric8
NodePort:
Unique per service
$NODE_IP:$NODEPORT
ClusterIP references a
NodePort on a specific
Node
Kubernetes Services (6)
17 27.10.2017 Service discovery in Kubernetes with Fabric8
Endpoints:
1:1 Endpoint – Pod
Represents the IP
address of a Pod
Can be queried by API
Service discovery in Kubernetes
Service discovery in Kubernetes with Fabric818 27.10.2017
Service discovery in Kubernetes
 How you can find your services in Kubernetes?
 Install Consul, Zookeeper, ...  Out of scope ;-)
 Discovery using Environment variables
 Discovery using DNS
 Discovery using Kubernetes master (with Fabric8 API)
Service discovery in Kubernetes with Fabric819 27.10.2017
Service discovery in Kubernetes
 Discovery using Environment variables
 When a Pod starts, a set of env variables for each active service
added
 {SVCNAME}_SERVICE_HOST & {SVCNAME}_SERVICE_PORT
 In case of many port definitions the port name is added:
{SVCNAME}_SERVICE_PORT_{PORTNAME}
 Drawback: the Service must already exist!
Service discovery in Kubernetes with Fabric820 27.10.2017
Service discovery in Kubernetes
 Discovery using DNS
 The DNS Server watches the Kubernetes API for new Services
 Creates a set of DNS records for each
 E.g. Service: “myservice”, Namespace: “default” myservice.default
 You can access the service using: http://myservice/…...
 Drawback:
 DNS must be enabled
 No protocol- & port-information
Service discovery in Kubernetes with Fabric821 27.10.2017
Fabric8 & service discovery
Service discovery in Kubernetes with Fabric822 27.10.2017
Fabric8 & service discovery
 What is Fabric8?
Fabric8 is an integrated open source DevOps and Integration
Platform which works out of the box on any Kubernetes or
OpenShift environment and provides Continuous Delivery,
Management, ChatOps and a Chaos Monkey.
Service discovery in Kubernetes with Fabric823 27.10.2017
Fabric8 & service discovery
 The Fabric8 kubernetes-client (http://goo.gl/17Hbp1)
 provides a Java API for working with the Kubernetes and
OpenShift REST API
 The kubernetes-client API is used by many projects:
 Several discovery plugins (e.g. Hazelcast)
 fabric8-spring-boot (https://goo.gl/JgN721)
 K8sdiscovery (https://goo.gl/Hok1gT)
Service discovery in Kubernetes with Fabric824 27.10.2017
Fabric8 & service discovery
 Why & When do you want to use fabric8 kubernetes-client?
 Discover Endpoints (Pods) for Client-side LB or monitoring
 Simple discovery of different ports / protocols
 Discovery using labels!
Service discovery in Kubernetes with Fabric825 27.10.2017
Fabric8 & service discovery - Example
Service discovery in Kubernetes with Fabric826 27.10.2017
client.
endpoints().
inNamespace(„hazelcast
“).
withLabel(„cluster1“).list
()
client.
endpoints().
inNamespace(„hazelcast
“).
withLabel(„cluster2“).list
()
spec:
replicas: 3
template:
metadata:
labels:
cluster1
Demo
Service discovery in Kubernetes with Fabric827 27.10.2017
Fabric8 & service discovery
Service discovery in Kubernetes with Fabric828 27.10.2017
Fabric8 & service discovery
Service discovery in Kubernetes with Fabric829 27.10.2017
One more thing ;-)
Service discovery in Kubernetes with Fabric830 27.10.2017
Service discovery in Kubernetes with Fabric831 27.10.2017
? ?
?
?
??
Service discovery in Kubernetes with Fabric832 27.10.2017
Discover external Services
 Solution:
 Services without selectors
 Service with ExternalName
Service discovery in Kubernetes with Fabric833 27.10.2017
Services without selectors
Service discovery in Kubernetes with Fabric834 27.10.2017
kind: Service
apiVersion: v1
metadata:
name: my-service
spec:
selector:
app: MyApp
ports:
- protocol: TCP
port: 80
targetPort: 9376
kind: Endpoints
apiVersion: v1
metadata:
name: my-service
subsets:
- addresses:
- ip: 1.2.3.4
ports:
- port: 9376
Manually deploy
Service with ExternalName
Service discovery in Kubernetes with Fabric835 27.10.2017
kind: Service
apiVersion: v1
metadata:
name: my-service
namespace: prod
spec:
type: ExternalName
externalName: my.database.com
my-service.prod.svc.CLUSTER  CNAME =
my.database.com
Summary
 Use discovery by Service name (DNS) in simple cases
 Use env variables for Port discovery
 Use Fabric8 Kubernetes-Client discovery when:
 Endpoint discovery needed (Client-Side discovery)
 Labels are working better for you
 Dealing with different ports
 Metadata is needed (monitoring)
Service discovery in Kubernetes with Fabric836 27.10.2017
Thank you
Andy Moncsek
Senior Consultant
Andy.Moncsek@trivadis.com
Twitter: @AndyAHCP
27.10.201737 Service discovery in Kubernetes with Fabric8
Links
 https://maven.fabric8.io
 https://github.com/fabric8io/kubernetes-client
 https://github.com/amoAHCP/K8SDiscoveryPresentation
Service discovery in Kubernetes with Fabric838 27.10.2017
Kubernetes – Key concept (developer view)
39 27.10.2017 Service discovery in Kubernetes with Fabric8

More Related Content

Recently uploaded

Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineeringssuserb3a23b
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 

Recently uploaded (20)

Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineering
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Service discovery in kubernetes with fabric8

  • 1. BASEL BERN BRUGG DÜSSELDORF FRANKFURT A.M. FREIBURG I.BR. GENF HAMBURG KOPENHAGEN LAUSANNE MÜNCHEN STUTTGART WIEN ZÜRICH Service discovery in Kubernetes with Fabric8Andy Moncsek Senior Consultant Andy.Moncsek@trivadis.com Twitter: @AndyAHCP
  • 2. Agenda 2 27.10.2017 1. Why service discovery? 2. Some Kubernetes basics 3. Service discovery in Kubernetes 4. Fabric8 & Service discovery Service discovery in Kubernetes with Fabric8
  • 3. Why service discovery ? Service discovery in Kubernetes with Fabric83 27.10.2017
  • 4. Why Service discovery ? Service discovery in Kubernetes with Fabric84 27.10.2017 Dynamically assigned 172.178.178.1:56477 172.178.178.2:66467 172.178.178.3:76767 Client / API Gatewa y ? Dynamically changing Loadbalancing?
  • 5. Client-side discovery Service discovery in Kubernetes with Fabric85 27.10.2017 1. register 2. query 3. request Client knows specific service instance
  • 6. Server-side discovery Service discovery in Kubernetes with Fabric86 27.10.2017 1. register 2. request 3. query 4. Loadbalance Client does not know a specific service instance
  • 7. Some Kubernetes basics Service discovery in Kubernetes with Fabric87 27.10.2017
  • 8. Some Kubernetes basics: What it is....  Kubernetes is platform designed to automate deploying, scaling, and operating application containers.  Deploy your applications quickly and predictably.  Scale your applications on the fly.  Roll out new features seamlessly. Service discovery in Kubernetes with Fabric88 27.10.2017
  • 9. Kubernetes Namespaces ”virtual" cluster Separates DEV, TEST, PROD, ... environments 9 27.10.2017 Service discovery in Kubernetes with Fabric8
  • 10. Kubernetes Pods Group of containers Shares network/namespace/ IP Shares environmental variables Shared volumes 10 27.10.2017 Service discovery in Kubernetes with Fabric8
  • 11. Kubernetes Controller 11 27.10.2017 Service discovery in Kubernetes with Fabric8 Ensure X pods are running Pod templates Rolling update
  • 12. Kubernetes Services 12 27.10.2017 Service discovery in Kubernetes with Fabric8 Pod discovery IP per service 1-N port numbers Route to pods Load balancer
  • 13. Kubernetes Services (2) 13 27.10.2017 Service discovery in Kubernetes with Fabric8
  • 14. Kubernetes Services (3) 14 27.10.2017 Service discovery in Kubernetes with Fabric8 External IP depends on: Service type = LB Infrastructure
  • 15. Kubernetes Services (4) 15 27.10.2017 Service discovery in Kubernetes with Fabric8 Cluster IP: Internal IP address Accessible by any component in namespace
  • 16. Kubernetes Services (5) 16 27.10.2017 Service discovery in Kubernetes with Fabric8 NodePort: Unique per service $NODE_IP:$NODEPORT ClusterIP references a NodePort on a specific Node
  • 17. Kubernetes Services (6) 17 27.10.2017 Service discovery in Kubernetes with Fabric8 Endpoints: 1:1 Endpoint – Pod Represents the IP address of a Pod Can be queried by API
  • 18. Service discovery in Kubernetes Service discovery in Kubernetes with Fabric818 27.10.2017
  • 19. Service discovery in Kubernetes  How you can find your services in Kubernetes?  Install Consul, Zookeeper, ...  Out of scope ;-)  Discovery using Environment variables  Discovery using DNS  Discovery using Kubernetes master (with Fabric8 API) Service discovery in Kubernetes with Fabric819 27.10.2017
  • 20. Service discovery in Kubernetes  Discovery using Environment variables  When a Pod starts, a set of env variables for each active service added  {SVCNAME}_SERVICE_HOST & {SVCNAME}_SERVICE_PORT  In case of many port definitions the port name is added: {SVCNAME}_SERVICE_PORT_{PORTNAME}  Drawback: the Service must already exist! Service discovery in Kubernetes with Fabric820 27.10.2017
  • 21. Service discovery in Kubernetes  Discovery using DNS  The DNS Server watches the Kubernetes API for new Services  Creates a set of DNS records for each  E.g. Service: “myservice”, Namespace: “default” myservice.default  You can access the service using: http://myservice/…...  Drawback:  DNS must be enabled  No protocol- & port-information Service discovery in Kubernetes with Fabric821 27.10.2017
  • 22. Fabric8 & service discovery Service discovery in Kubernetes with Fabric822 27.10.2017
  • 23. Fabric8 & service discovery  What is Fabric8? Fabric8 is an integrated open source DevOps and Integration Platform which works out of the box on any Kubernetes or OpenShift environment and provides Continuous Delivery, Management, ChatOps and a Chaos Monkey. Service discovery in Kubernetes with Fabric823 27.10.2017
  • 24. Fabric8 & service discovery  The Fabric8 kubernetes-client (http://goo.gl/17Hbp1)  provides a Java API for working with the Kubernetes and OpenShift REST API  The kubernetes-client API is used by many projects:  Several discovery plugins (e.g. Hazelcast)  fabric8-spring-boot (https://goo.gl/JgN721)  K8sdiscovery (https://goo.gl/Hok1gT) Service discovery in Kubernetes with Fabric824 27.10.2017
  • 25. Fabric8 & service discovery  Why & When do you want to use fabric8 kubernetes-client?  Discover Endpoints (Pods) for Client-side LB or monitoring  Simple discovery of different ports / protocols  Discovery using labels! Service discovery in Kubernetes with Fabric825 27.10.2017
  • 26. Fabric8 & service discovery - Example Service discovery in Kubernetes with Fabric826 27.10.2017 client. endpoints(). inNamespace(„hazelcast “). withLabel(„cluster1“).list () client. endpoints(). inNamespace(„hazelcast “). withLabel(„cluster2“).list () spec: replicas: 3 template: metadata: labels: cluster1
  • 27. Demo Service discovery in Kubernetes with Fabric827 27.10.2017
  • 28. Fabric8 & service discovery Service discovery in Kubernetes with Fabric828 27.10.2017
  • 29. Fabric8 & service discovery Service discovery in Kubernetes with Fabric829 27.10.2017
  • 30. One more thing ;-) Service discovery in Kubernetes with Fabric830 27.10.2017
  • 31. Service discovery in Kubernetes with Fabric831 27.10.2017 ? ? ? ? ??
  • 32. Service discovery in Kubernetes with Fabric832 27.10.2017
  • 33. Discover external Services  Solution:  Services without selectors  Service with ExternalName Service discovery in Kubernetes with Fabric833 27.10.2017
  • 34. Services without selectors Service discovery in Kubernetes with Fabric834 27.10.2017 kind: Service apiVersion: v1 metadata: name: my-service spec: selector: app: MyApp ports: - protocol: TCP port: 80 targetPort: 9376 kind: Endpoints apiVersion: v1 metadata: name: my-service subsets: - addresses: - ip: 1.2.3.4 ports: - port: 9376 Manually deploy
  • 35. Service with ExternalName Service discovery in Kubernetes with Fabric835 27.10.2017 kind: Service apiVersion: v1 metadata: name: my-service namespace: prod spec: type: ExternalName externalName: my.database.com my-service.prod.svc.CLUSTER  CNAME = my.database.com
  • 36. Summary  Use discovery by Service name (DNS) in simple cases  Use env variables for Port discovery  Use Fabric8 Kubernetes-Client discovery when:  Endpoint discovery needed (Client-Side discovery)  Labels are working better for you  Dealing with different ports  Metadata is needed (monitoring) Service discovery in Kubernetes with Fabric836 27.10.2017
  • 37. Thank you Andy Moncsek Senior Consultant Andy.Moncsek@trivadis.com Twitter: @AndyAHCP 27.10.201737 Service discovery in Kubernetes with Fabric8
  • 38. Links  https://maven.fabric8.io  https://github.com/fabric8io/kubernetes-client  https://github.com/amoAHCP/K8SDiscoveryPresentation Service discovery in Kubernetes with Fabric838 27.10.2017
  • 39. Kubernetes – Key concept (developer view) 39 27.10.2017 Service discovery in Kubernetes with Fabric8