Kubernetes Classroom Series – 08/Jul/2021

Singleton Service

  • Overview: Singleton Pattern ensures only one instance of an application is active at a time and is highly available
  • Problem:
    • In some cases only one instance of the service is allowed to run
  • Solution:
    • Out of Application Locking:
      • Stateful set or replicat set with replicas = 1
    • In-Application Locking
      • In a distribute environment one way to control the service instance count is through a distributed lock
      • We can implement leader election using kubernetes api’s. For example apache camel has a K8s connector that also provides leader election and Singleton capabilities
      • This connector access the etcd api directly and k8s api to use Config Maps to acquire a distributed lock Refer Here
      • Refer Here for sample leader election in k8s.

DNS For Services and Pods

  • Refer Here for the manifests used Preview
  • Lets create the test pod Preview
  • Make a note of service names and ip addresses of pods Preview
  • Now login into test pod
kubectl exec -it test -- /bin/sh
  • Look into resolve.conf Preview

  • What objects in k8s gets DNS records

    • Services
    • Pods
  • Refer Here for the K8s DNS Based Service Discovery

  • DNS A record Refer Here

  • DNS CNAME Refer Here

  • DNS SRV Refer Here

  • K8s Services:

    • A/AAAA records
      • Normal Services are assigned a DNS A record depending on the IP family of the service for the name in the form of my-svc.my-namespace.svc.cluster-domain.example
    • SRV records:
      • SRV records are created for each named ports that are part of normal or Headless Services. For each name port the SRV record would have the form _my-port-name._my-port-protocol.my-svc.my-namespace.svc.cluster.local
  • K8S Pods

    • A/AAAA records:
      • Pod has the following dns resolution
      pod-ip-address.my-namespace.pod.cluster.local
      
  • In kubernetes in addition to DNS records k8s create environmental variables with service information Preview

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Social Network Integration by Acurax Social Media Branding Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube