Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Stateless and Stateful Services in Kubernetes - Mohit Saxena - Citrix - CC18

2,452 views

Published on

This presentation was made by Mohit Saxena as part of the Container Conference 2018.

"Stateless and Stateful services in Kubernetes
Kubernetes (K8s) cluster infrastructure is getting more and more traction industry wide. Different kinds of workload are getting shifted from tradition three tier to micorservice architecture. Every application comes with its own need of infrastructure components be its scaling of application to loadbalancing(LB) these application. K8s also trying to cater the different requirement of these workload one such example is headless services which is basically used for stateful service set. Role of LB is most important when it comes to scaling of services and service discovery be it ingress or E-W. For stateful services exposed using clusterIP/NodePort to ingress default Round Robin loadbalancing will not work. We need intelligent services discovery and LB modules when working with a set of apps consisting of both stateful and stateless services."

Conference URL: www.containerconf.in

Published in: Software
  • Be the first to comment

  • Be the first to like this

Stateless and Stateful Services in Kubernetes - Mohit Saxena - Citrix - CC18

  1. 1. © 2018 Citrix | Confidential Stateless and Stateful Services in Kubernetes AUGUST 6, 2018 Mohit Saxena
  2. 2. 2 © 2018 Citrix | Confidential • Core concepts • Services • Stateless vs Stateful • Proxy and DNS • Deploying Stateful Services • Load Balancing Stateful set • Citrix ADC for Microservices Agenda
  3. 3. 3 © 2018 Citrix | Confidential • Pods – Group of Containers – Shared Namespaces (Mount , Net, IPC) • Deployments – Defining Pods – Managing Pods • Labels – Key/Value Pair – Naming of Objects • Label selectors – Identify a set of objects – Equality-based and set-based Core Concepts Sample Deployment File apiVersion: apps/v1 kind: Deployment metadata: name: cpx-deployment labels: app: cpx spec: replicas: 5 selector: matchLabels: app: cpx template: metadata: labels: app: cpx spec: containers: - name: cpx image: store/citrix/netscalercpx:12.0-56.20 ports: - containerPort: 80 env: - name: "EULA" value: "yes“ securityContext: capabilities: add: - NET_ADMIN
  4. 4. 4 © 2018 Citrix | Confidential • Logical Collection of pods • Abstraction for endpoints • Represented by Cluster IP • External Service – No Selector defined – Manual Endpoints • Headless Service – No Cluster IP defined – Accessed by referring endpoints Services Sample Service File kind: Service apiVersion: v1 metadata: name: cpx-service spec: selector: app: cpx ports: - protocol: TCP port: 80 targetPort: 80 Sample Headless Service File kind: Service apiVersion: v1 metadata: name: cpx-service spec: selector: app: cpx ports: - protocol: TCP port: 80 clusterIP: None
  5. 5. 5 © 2018 Citrix | Confidential • Stateless – No Persistent Storage – Mortal – Scaling can be done independently – Client side cookies can be used to make stateless service • Stateful – Stable, unique network identifiers. – Stable, persistent storage. – Ordered, graceful deployment and scaling. – Ordered, graceful deletion and termination. – Ordered, automated rolling updates. Stateless vs Stateful Service
  6. 6. 6 © 2018 Citrix | Confidential • DNS maintains the ClusterIP/endpoints • Proxy load balance on the basis of Cluster IP • Proxy talks to API server to get the endpoints linked with Cluster IP • Headless service has no Cluster IP – proxy will not help in load balancing • DNS based load balancing has its own side effect • Sateful sets requires headless service Role of Kube Proxy and DNS
  7. 7. 7 © 2018 Citrix | Confidential apiVersion: v1 kind: Service metadata: name: web labels: app: web spec: ports: - port: 80 name: web clusterIP: None selector: app: web Defining Stateful service apiVersion: apps/v1 kind: StatefulSet metadata: name: web spec: serviceName: "web" replicas: 10 selector: matchLabels: app: web template: metadata: labels: app: web spec: containers: - name: web image: apache ports: - containerPort: 80 name: web volumeMounts: - name: www mountPath: /usr/share/htdocs/html volumeClaimTemplates: - metadata: name: www spec: accessModes: [ "ReadWriteOnce" ] resources: requests: storage: 1Gi Service Definition CNAME for Web-0 web-0.web.default.svc.cluster.local
  8. 8. 8 © 2018 Citrix | Confidential apiVersion: v1 kind: Service metadata: name: web-service labels: app: web spec: ports: - port: 80 name: web clusterIP: None selector: app: web Load Balancing of Stateful Services apiVersion: apps/v1 kind: StatefulSet metadata: name: web spec: serviceName: "web" replicas: 10 selector: matchLabels: app: web template: metadata: labels: app: web spec: containers: - name: web image: apache ports: - containerPort: 80 name: web volumeMounts: - name: www mountPath: /usr/share/htdocs/html volumeClaimTemplates: - metadata: name: www spec: accessModes: [ "ReadWriteOnce" ] resources: requests: storage: 1Gi apiVersion: v1 kind: Service metadata: name: web labels: app: cpx spec: ports: - port: 80 name: cpx clusterIP: None selector: app: cpx apiVersion: apps/v1 kind: Deployment metadata: name: cpx-deployment labels: app: cpx spec: replicas: 5 selector: matchLabels: app: cpx template: metadata: labels: app: cpx spec: containers: - name: cpx image: store/citrix/netscalercpx:12.0-56.20 ports: - containerPort: 80 env: - name: "EULA" value: "yes" <Proxy Configuration> Service - web-service LB Policy Authentication Policy Service Definition Proxy Definition
  9. 9. CPX Micro Services CPXDBS Service to Service CPX Proxy Per Service CPX Load Balancing of Stateful Services
  10. 10. 10 © 2016 Citrix | Confidential CPX Safely Bridges Your Services CPX Subnet 1 Subnet 3 Subnet 2
  11. 11. 11 © 2016 Citrix | Confidential • Scale Up and Down in response to load • Monitor the health of your service instances • Adapt Session Persistence, caching, etc. to your service needs • Gain Visibility into service traffic Load Balance and Scale Your Services
  12. 12. 12 © 2016 Citrix | Confidential Secure Your Microservices Connections CPX Microservice D Microservice A Microservice B Microservice C
  13. 13. 13 © 2016 Citrix | Confidential Secure Your Microservices Connections CPX Microservice D Microservice A Microservice B Microservice C
  14. 14. 14 © 2016 Citrix | Confidential A/B or Canary Testing Microservice A Microservice B Microservice D (Old Version) Microservice D (New Version)
  15. 15. 15 © 2016 Citrix | Confidential A/B or Canary Testing: Easier, Faster, Better CPX Microservice A Microservice B Microservice D (Old Version) Microservice D (New Version)
  16. 16. 16 © 2016 Citrix | Confidential Unify North-South and East-West Traffic Handling MPX/SDX/VPX
  17. 17. 17 © 2016 Citrix | Confidential Unify North-South and East-West Traffic Handling MPX/SDX/VPX CPX
  18. 18. 18 © 2016 Citrix | Confidential Unify North-South and East-West Traffic Handling MPX/SDX/VPX CPX CPX North-South East-West
  19. 19. 19 © 2016 Citrix | Confidential Unify North-South and East-West Traffic Handling MPX/SDX/VPX CPX CPX NetScaler MAS North-South East-West
  20. 20. 20 © 2016 Citrix | Confidential Key CPX and MAS Differentiation • MAS and CPX provides a combined solution for deploying microservices, unlike open source solutions that need other ecosystem components • Load balancing, L7 policies • Fleet management, SSL certificate management and APIs to orchestration systems and analytics platforms • Service discovery is built in with auto-configuration • Analytics and visibility • CPX provides deep load balancing functions and layer 7 DDoS not available from other containerized LBs • CPX provides in-service hitless upgrades not at all available from all containerized load balancers
  21. 21. 21 © 2018 Citrix | Confidential

×