improve affinity spread of rw cores

Change-Id: Iaf6460710e4b7497ffc431beabf1a0bfa6fd7f1d
diff --git a/README.md b/README.md
index 3ff2914..ebe9c7d 100644
--- a/README.md
+++ b/README.md
@@ -184,6 +184,14 @@
 this environment can be found in JIRA via a [JIRA Issue
 Search](https://jira.opencord.org/issues/?jql=status%20not%20in%20%28closed%2C%20Done%2CResolved%29%20and%20labels%20in%20%28helm%29%20and%20affectedVersion%20in%20%28%22VOLTHA%20v2.0%22%29).
 
+### Small Kubernetes Deployments
+Kubernetes affinity is used to ensure the distribution of read-write core pods
+across the Kubernetes nodes in support of optimum high availability. While
+this *seems* to work for production sized Kubernetes clusters (2n+1 nodes,
+where n >= 1) on smaller Kubernetes deployments it may mean that members
+of a r/w core pair are scheduled on the same node, which may mean that on a
+smaller Kubnernetes deployment *true* high availability is not achieved.
+
 ## Pre-patchset submission Checks
 
 On patchset submission, jobs are run in Jenkins that validate the correctness
diff --git a/voltha/Chart.yaml b/voltha/Chart.yaml
index 5e199c8..aa52ca8 100644
--- a/voltha/Chart.yaml
+++ b/voltha/Chart.yaml
@@ -17,5 +17,5 @@
 description: A Helm chart for Voltha based on K8S resources in Voltha project
 icon: https://guide.opencord.org/logos/cord.svg
 
-version: 2.0.0
+version: 2.0.1
 appVersion: 2.0.0
diff --git a/voltha/templates/rw-core.yaml b/voltha/templates/rw-core.yaml
index 4dd0e06..5be011d 100644
--- a/voltha/templates/rw-core.yaml
+++ b/voltha/templates/rw-core.yaml
@@ -17,7 +17,7 @@
 {{- $tag := tpl .Values.images.rw_core.tag . }}
 {{- range $i, $e := until $count }}
 {{- $core_idx := add $i 1 }}
-{{- $pair_idx := div $i 2 | int }}
+{{- $affinity_group := add1 (mod $i 2) }}
 ---
 apiVersion: apps/v1
 kind: Deployment
@@ -33,19 +33,29 @@
     metadata:
       labels:
         app: rw-core
-        affinity-index: anti-affinity-{{ $pair_idx }}
+        affinity-group: affinity-group-{{ $affinity_group }}
       annotations:
         cni: "calico"
     spec:
       affinity:
         podAntiAffinity:
+          preferredDuringSchedulingIgnoredDuringExecution:
+          - weight: 100
+            podAffinityTerm:
+              labelSelector:
+                matchExpressions:
+                - key: app
+                  operator: In
+                  values:
+                  - rw-core
+              topologyKey: "kubernetes.io/hostname"
           requiredDuringSchedulingIgnoredDuringExecution:
           - labelSelector:
               matchExpressions:
-              - key: affinity-index
+              - key: affinity-group
                 operator: In
                 values:
-                - anti-affinity-{{ $pair_idx }}
+                - affinity-group-{{ $affinity_group }}
             topologyKey: "kubernetes.io/hostname"
       serviceAccountName: {{ $root.Values.serviceaccount }}
       containers: