1.06k likes | 1.2k Views
Load Balancing with Kubernetes: concepts, use-cases, and implementation details Kubernetes Master Class Series. #Rancherk8s. April 30, 2019. Murali Paluru Principal Software Engineer Rancher Git: leodotcloud @ leodotcloud. Matthew Scheer Marketing Manager Rancher
E N D
Load Balancing with Kubernetes: concepts, use-cases, and implementation detailsKubernetes Master Class Series #Rancherk8s April 30, 2019
Murali Paluru Principal Software Engineer Rancher Git: leodotcloud @leodotcloud Matthew Scheer Marketing Manager Rancher @matthew_scheer matthew@rancher.com #RancherK8s
Rancher Master Class Series: Trying to keep this to 40-45 minutes Questions are always welcome Use the questions tab to write your questions We may respond to all, so mark your question as private if needed. #Rancherk8s
This session is being recorded! http://youtube.com/c/rancher #Rancherk8s
Join the conversation on Slack http://slack.rancher.io #masterclass #RancherK8s
Upcoming Classes http://rancher.com/kubernetes-master-class/ More Resources https://info.rancher.com/kubernetes-networking-deep-dive #RancherK8s
Load Balancing in K8S Murali Paluru • https://slack.rancher.io(leodotcloud)https://github.com/leodotcloud • https://twitter.com/leodotcloudhttps://linkedin.com/in/leodotcloud
Agenda • Load Balancer: What/Why • Load Balancer types • L4 • L7 • LB in K8S (Internal/External) • Service Types: ClusterIP, NodePort, LoadBalancer • Ingress • Demo • Questions Code will be uploaded here: https://github.com/leodotcloud/k8s-load-balancing-master-class
What is Load Balancing/a Load Balancer? • Load balancing refers to efficiently distributing incoming network traffic across a group of backend servers/microservices. • A Load Balancer is a device(physical/virtual) that distributes network or application traffic across a cluster of servers.
Summarize SSL Offloading Load Distribution Routing (Host/Path) Version Upgrades
Many Load Balancers! • HAProxy • Nginx • F5 • Cisco • Avi • Cloud Providers (AWS, GCE, Azure, DO, etc.) • etc
Load Balancer Types • L4 (Layer 4) • Inspects the packet only upto Layer 4 of the networking stack (TCP/UDP) • L7 (Layer 7), Application Load Balancer • Inspects the packet all the way up to Layer 7 of the networking stack (HTTP/HTTPS) Image Source
Comparison • Layer 7 LB • Load distribution • SSL offloading • App Upgrades • Routing • Layer 4 LB • Load distribution • SSL offloading • App Upgrades
Cluster IP • Layer 4 Load balancing (Provides Load distribution, Version Upgrades) • Internal to the cluster • Configured via K8S Service • Service Discovery using name of the service • There are no network interfaces associated with the Cluster IP. • If you want to expose your application, always use a Cluster IP, do not rely on the POD IP address. • Pods and their IP addresses are ephemeral! • Majority of DNS clients are not good citizens. (More info here)
Service discovery • Within the same namespace, services are discoverable using their names. • service-name • Across different namespaces, services are discoverable using the format: • service-name.namespace-name • Default domain: cluster.local • DNS A records: service-name.namespace-name.svc.cluster.local
Cluster IP Internal Clients
Sample App for Demo purposes • Docker image: leodotcloud/swiss-army-knife • Single Go binary that serves a web server on a given port • Renders a simple webpage • Displays English alphabets and their mapping NATO phonetic alphabets • Displays the hostname and IP address of container • Has all basic tools needed for debugging • Environments Variables • PORT: Specify the port for the web server to listen on • Default: 80 • ALPHABET: To show a specific alphabet only • Default: “” (shows all alphabets)
NodePort • Layer 4 Load balancing (Provides Load distribution, Version Upgrades) • External access using a “port of all nodes” • Under the hood, creates an internal Cluster IP for LB purposes • And NO service discovery for external clients • Note: Can be accessed on/over the internet if the node IP addresses are public (Or Direct Connect/VPN)