Monday, March 25, 2019

How To Switch Service Without Changing Apps Connection Details in K8S

Requirement:

    In enterprise world, we often have  standby or DR services.  Sometimes we have active and active services too.  When we do switch over service, we need to modify Apps connection details to point to new service. It generates workloads and confusion when we touch Apps configurations  In Kubernetes world, the power and flexibility of service save us from these hassles . We can switch services without changing Apps connection details.

Solution:

We can use selector in K8S service component to choose which Apps the service is sitting on.
For example:
Primary DB service is on label livesqlsb-db-service and Standby DB service is on label livesqlsb-db-dr-service

To update service to point to standby DB , we simple update selector from livesqlsb-db-service --> livesqlsb-db-dr-service in the yaml file
Then kubectl apply -f  <yaml file>

apiVersion: v1
kind: Service
metadata:
  labels:
     name: livesqlsb-db-service
  name: livesqlsb-db-service
  namespace: default
spec:
  ports:
  - port: 1521
    protocol: TCP
    targetPort: 1521
  selector:
     name: livesqlsb-db-service  or  livesqlsb-db-dr-service (update it to be livesqlsb-db-dr-service for standby DB service)

No comments:

Post a Comment