From d58059aa7a2ca2e4b0992ab97398cb88702dc2a9 Mon Sep 17 00:00:00 2001
From: Steve Wilkerson <wilkers.steve@gmail.com>
Date: Tue, 27 Jun 2017 15:16:53 -0500
Subject: [PATCH] Introduce rolling updates for daemonsets

Kubernetes 1.6 introduced the ability to declare an update
strategy for daemonsets. As weve made >1.6 a requirement, we
should adopt the ability to update our daemonsets just as we do
with deployments. This brings the daemonset templates in our
charts in line with other patterns developed.

Change-Id: I317560b24d65274b69bec2df4f6225f1255b7ae6
---
 neutron/templates/daemonset-dhcp-agent.yaml   |  9 +++++
 neutron/templates/daemonset-l3-agent.yaml     |  9 +++++
 .../templates/daemonset-metadata-agent.yaml   |  9 +++++
 neutron/templates/daemonset-ovs-agent.yaml    |  9 +++++
 neutron/templates/daemonset-ovs-db.yaml       |  9 +++++
 neutron/templates/daemonset-ovs-vswitchd.yaml |  9 +++++
 neutron/templates/deployment-server.yaml      | 10 ++---
 neutron/values.yaml                           | 37 ++++++++++++++++---
 nova/templates/daemonset-compute.yaml         |  9 +++++
 nova/templates/daemonset-libvirt.yaml         |  9 +++++
 nova/templates/deployment-api-metadata.yaml   | 10 ++---
 nova/templates/deployment-api-osapi.yaml      | 10 ++---
 nova/templates/deployment-conductor.yaml      | 10 ++---
 nova/templates/deployment-consoleauth.yaml    | 10 ++---
 nova/templates/deployment-scheduler.yaml      | 10 ++---
 nova/values.yaml                              | 21 ++++++++---
 16 files changed, 150 insertions(+), 40 deletions(-)

diff --git a/neutron/templates/daemonset-dhcp-agent.yaml b/neutron/templates/daemonset-dhcp-agent.yaml
index 6735ee8588..9f4669ed6b 100644
--- a/neutron/templates/daemonset-dhcp-agent.yaml
+++ b/neutron/templates/daemonset-dhcp-agent.yaml
@@ -21,6 +21,15 @@ kind: DaemonSet
 metadata:
   name: neutron-dhcp-agent
 spec:
+  {{ if .Values.upgrades.daemonsets.dhcp_agent.enabled }}
+  minReadySeconds: {{ .Values.upgrades.daemonsets.dhcp_agent.min_ready_seconds }}
+  updateStrategy:
+    type: {{ .Values.upgrades.daemonsets.pod_replacement_strategy }}
+    {{ if eq .Values.upgrades.daemonsets.pod_replacement_strategy "RollingUpdate" }}
+    rollingUpdate:
+      maxUnavailable: {{ .Values.upgrades.daemonsets.dhcp_agent.max_unavailable }}
+    {{ end }}
+  {{ end }}
   template:
     metadata:
       labels:
diff --git a/neutron/templates/daemonset-l3-agent.yaml b/neutron/templates/daemonset-l3-agent.yaml
index 99dcadec0d..a7067c1282 100644
--- a/neutron/templates/daemonset-l3-agent.yaml
+++ b/neutron/templates/daemonset-l3-agent.yaml
@@ -21,6 +21,15 @@ kind: DaemonSet
 metadata:
   name: neutron-l3-agent
 spec:
+  {{ if .Values.upgrades.daemonsets.l3_agent.enabled }}
+  minReadySeconds: {{ .Values.upgrades.daemonsets.l3_agent.min_ready_seconds }}
+  updateStrategy:
+    type: {{ .Values.upgrades.daemonsets.pod_replacement_strategy }}
+    {{ if eq .Values.upgrades.daemonsets.pod_replacement_strategy "RollingUpdate" }}
+    rollingUpdate:
+      maxUnavailable: {{ .Values.upgrades.daemonsets.l3_agent.max_unavailable }}
+    {{ end }}
+  {{ end }}
   template:
     metadata:
       labels:
diff --git a/neutron/templates/daemonset-metadata-agent.yaml b/neutron/templates/daemonset-metadata-agent.yaml
index 93cd937b66..090b163889 100644
--- a/neutron/templates/daemonset-metadata-agent.yaml
+++ b/neutron/templates/daemonset-metadata-agent.yaml
@@ -21,6 +21,15 @@ kind: DaemonSet
 metadata:
   name: neutron-metadata-agent
 spec:
+  {{ if .Values.upgrades.daemonsets.metadata_agent.enabled }}
+  minReadySeconds: {{ .Values.upgrades.daemonsets.metadata_agent.min_ready_seconds }}
+  updateStrategy:
+    type: {{ .Values.upgrades.daemonsets.pod_replacement_strategy }}
+    {{ if eq .Values.upgrades.daemonsets.pod_replacement_strategy "RollingUpdate" }}
+    rollingUpdate:
+      maxUnavailable: {{ .Values.upgrades.daemonsets.metadata_agent.max_unavailable }}
+    {{ end }}
+  {{ end }}
   template:
     metadata:
       labels:
diff --git a/neutron/templates/daemonset-ovs-agent.yaml b/neutron/templates/daemonset-ovs-agent.yaml
index 3e3cf7ee01..9edf9afc63 100644
--- a/neutron/templates/daemonset-ovs-agent.yaml
+++ b/neutron/templates/daemonset-ovs-agent.yaml
@@ -21,6 +21,15 @@ kind: DaemonSet
 metadata:
   name: ovs-agent
 spec:
+  {{ if .Values.upgrades.daemonsets.ovs_agent.enabled }}
+  minReadySeconds: {{ .Values.upgrades.daemonsets.ovs_agent.min_ready_seconds }}
+  updateStrategy:
+    type: {{ .Values.upgrades.daemonsets.pod_replacement_strategy }}
+    {{ if eq .Values.upgrades.daemonsets.pod_replacement_strategy "RollingUpdate" }}
+    rollingUpdate:
+      maxUnavailable: {{ .Values.upgrades.daemonsets.ovs_agent.max_unavailable }}
+    {{ end }}
+  {{ end }}
   template:
     metadata:
       labels:
diff --git a/neutron/templates/daemonset-ovs-db.yaml b/neutron/templates/daemonset-ovs-db.yaml
index 9a60dcb9e4..25da657924 100644
--- a/neutron/templates/daemonset-ovs-db.yaml
+++ b/neutron/templates/daemonset-ovs-db.yaml
@@ -17,6 +17,15 @@ kind: DaemonSet
 metadata:
   name: ovs-db
 spec:
+  {{ if .Values.upgrades.daemonsets.ovs_db.enabled }}
+  minReadySeconds: {{ .Values.upgrades.daemonsets.ovs_db.min_ready_seconds }}
+  updateStrategy:
+    type: {{ .Values.upgrades.daemonsets.pod_replacement_strategy }}
+    {{ if eq .Values.upgrades.daemonsets.pod_replacement_strategy "RollingUpdate" }}
+    rollingUpdate:
+      maxUnavailable: {{ .Values.upgrades.daemonsets.ovs_db.max_unavailable }}
+    {{ end }}
+  {{ end }}
   template:
     metadata:
       labels:
diff --git a/neutron/templates/daemonset-ovs-vswitchd.yaml b/neutron/templates/daemonset-ovs-vswitchd.yaml
index 48c479bb55..35ec8f1464 100644
--- a/neutron/templates/daemonset-ovs-vswitchd.yaml
+++ b/neutron/templates/daemonset-ovs-vswitchd.yaml
@@ -17,6 +17,15 @@ kind: DaemonSet
 metadata:
   name: ovs-vswitchd
 spec:
+  {{ if .Values.upgrades.daemonsets.ovs_vswitchd.enabled }}
+  minReadySeconds: {{ .Values.upgrades.daemonsets.ovs_vswitchd.min_ready_seconds }}
+  updateStrategy:
+    type: {{ .Values.upgrades.daemonsets.pod_replacement_strategy }}
+    {{ if eq .Values.upgrades.daemonsets.pod_replacement_strategy "RollingUpdate" }}
+    rollingUpdate:
+      maxUnavailable: {{ .Values.upgrades.daemonsets.ovs_vswitchd.max_unavailable }}
+    {{ end }}
+  {{ end }}
   template:
     metadata:
       labels:
diff --git a/neutron/templates/deployment-server.yaml b/neutron/templates/deployment-server.yaml
index 0f4c19f409..1e58294472 100644
--- a/neutron/templates/deployment-server.yaml
+++ b/neutron/templates/deployment-server.yaml
@@ -22,13 +22,13 @@ metadata:
   name: neutron-server
 spec:
   replicas: {{ .Values.replicas.server }}
-  revisionHistoryLimit: {{ .Values.upgrades.revision_history }}
+  revisionHistoryLimit: {{ .Values.upgrades.deployments.revision_history }}
   strategy:
-    type: {{ .Values.upgrades.pod_replacement_strategy }}
-    {{ if eq .Values.upgrades.pod_replacement_strategy "RollingUpdate" }}
+    type: {{ .Values.upgrades.deployments.pod_replacement_strategy }}
+    {{ if eq .Values.upgrades.deployments.pod_replacement_strategy "RollingUpdate" }}
     rollingUpdate:
-      maxUnavailable: {{ .Values.upgrades.rolling_update.max_unavailable }}
-      maxSurge: {{ .Values.upgrades.rolling_update.max_surge }}
+      maxUnavailable: {{ .Values.upgrades.deployments.rolling_update.max_unavailable }}
+      maxSurge: {{ .Values.upgrades.deployments.rolling_update.max_surge }}
     {{ end }}
   template:
     metadata:
diff --git a/neutron/values.yaml b/neutron/values.yaml
index 3e4df466e7..7b9d73b83c 100644
--- a/neutron/values.yaml
+++ b/neutron/values.yaml
@@ -38,11 +38,38 @@ images:
   pull_policy: "IfNotPresent"
 
 upgrades:
-  revision_history: 3
-  pod_replacement_strategy: RollingUpdate
-  rolling_update:
-    max_unavailable: 1
-    max_surge: 3
+  deployments:
+    revision_history: 3
+    pod_replacement_strategy: RollingUpdate
+    rolling_update:
+      max_unavailable: 1
+      max_surge: 3
+  daemonsets:
+    pod_replacement_strategy: RollingUpdate
+    dhcp_agent:
+      enabled: false
+      min_ready_seconds: 0
+      max_unavailable: 1
+    l3_agent:
+      enabled: false
+      min_ready_seconds: 0
+      max_unavailable: 1
+    metadata_agent:
+      enabled: true
+      min_ready_seconds: 0
+      max_unavailable: 1
+    ovs_agent:
+      enabled: true
+      min_ready_seconds: 0
+      max_unavailable: 1
+    ovs_db:
+      enabled: false
+      min_ready_seconds: 0
+      max_unavailable: 1
+    ovs_vswitchd:
+      enabled: false
+      min_ready_seconds: 0
+      max_unavailable: 1
 
 pod_disruption_budget:
   server:
diff --git a/nova/templates/daemonset-compute.yaml b/nova/templates/daemonset-compute.yaml
index a6f82fea62..e9071512d2 100644
--- a/nova/templates/daemonset-compute.yaml
+++ b/nova/templates/daemonset-compute.yaml
@@ -22,6 +22,15 @@ kind: DaemonSet
 metadata:
   name: nova-compute
 spec:
+  {{ if .Values.upgrades.daemonsets.compute.enabled }}
+  minReadySeconds: {{ .Values.upgrades.daemonsets.compute.min_ready_seconds }}
+  updateStrategy:
+    type: {{ .Values.upgrades.daemonsets.pod_replacement_strategy }}
+    {{ if eq .Values.upgrades.daemonsets.pod_replacement_strategy "RollingUpdate" }}
+    rollingUpdate:
+      maxUnavailable: {{ .Values.upgrades.daemonsets.compute.max_unavailable }}
+    {{ end }}
+  {{ end }}
   template:
     metadata:
       labels:
diff --git a/nova/templates/daemonset-libvirt.yaml b/nova/templates/daemonset-libvirt.yaml
index 32e4b7aba3..66873dc4a9 100644
--- a/nova/templates/daemonset-libvirt.yaml
+++ b/nova/templates/daemonset-libvirt.yaml
@@ -21,6 +21,15 @@ kind: DaemonSet
 metadata:
   name: nova-libvirt
 spec:
+  {{ if .Values.upgrades.daemonsets.libvirt.enabled }}
+  minReadySeconds: {{ .Values.upgrades.daemonsets.libvirt.min_ready_seconds }}
+  updateStrategy:
+    type: {{ .Values.upgrades.daemonsets.pod_replacement_strategy }}
+    {{ if eq .Values.upgrades.daemonsets.pod_replacement_strategy "RollingUpdate" }}
+    rollingUpdate:
+      maxUnavailable: {{ .Values.upgrades.daemonsets.libvirt.max_unavailable }}
+    {{ end }}
+  {{ end }}
   template:
     metadata:
       labels:
diff --git a/nova/templates/deployment-api-metadata.yaml b/nova/templates/deployment-api-metadata.yaml
index ab80909eca..92eb9b0d86 100644
--- a/nova/templates/deployment-api-metadata.yaml
+++ b/nova/templates/deployment-api-metadata.yaml
@@ -22,13 +22,13 @@ metadata:
   name: nova-api-metadata
 spec:
   replicas: {{ .Values.replicas.api_metadata }}
-  revisionHistoryLimit: {{ .Values.upgrades.revision_history }}
+  revisionHistoryLimit: {{ .Values.upgrades.deployments.revision_history }}
   strategy:
-    type: {{ .Values.upgrades.pod_replacement_strategy }}
-    {{ if eq .Values.upgrades.pod_replacement_strategy "RollingUpdate" }}
+    type: {{ .Values.upgrades.deployments.pod_replacement_strategy }}
+    {{ if eq .Values.upgrades.deployments.pod_replacement_strategy "RollingUpdate" }}
     rollingUpdate:
-      maxUnavailable: {{ .Values.upgrades.rolling_update.max_unavailable }}
-      maxSurge: {{ .Values.upgrades.rolling_update.max_surge }}
+      maxUnavailable: {{ .Values.upgrades.deployments.rolling_update.max_unavailable }}
+      maxSurge: {{ .Values.upgrades.deployments.rolling_update.max_surge }}
     {{ end }}
   template:
     metadata:
diff --git a/nova/templates/deployment-api-osapi.yaml b/nova/templates/deployment-api-osapi.yaml
index b75741809c..4b1f671400 100644
--- a/nova/templates/deployment-api-osapi.yaml
+++ b/nova/templates/deployment-api-osapi.yaml
@@ -22,13 +22,13 @@ metadata:
   name: nova-api-osapi
 spec:
   replicas: {{ .Values.replicas.osapi }}
-  revisionHistoryLimit: {{ .Values.upgrades.revision_history }}
+  revisionHistoryLimit: {{ .Values.upgrades.deployments.revision_history }}
   strategy:
-    type: {{ .Values.upgrades.pod_replacement_strategy }}
-    {{ if eq .Values.upgrades.pod_replacement_strategy "RollingUpdate" }}
+    type: {{ .Values.upgrades.deployments.pod_replacement_strategy }}
+    {{ if eq .Values.upgrades.deployments.pod_replacement_strategy "RollingUpdate" }}
     rollingUpdate:
-      maxUnavailable: {{ .Values.upgrades.rolling_update.max_unavailable }}
-      maxSurge: {{ .Values.upgrades.rolling_update.max_surge }}
+      maxUnavailable: {{ .Values.upgrades.deployments.rolling_update.max_unavailable }}
+      maxSurge: {{ .Values.upgrades.deployments.rolling_update.max_surge }}
     {{ end }}
   template:
     metadata:
diff --git a/nova/templates/deployment-conductor.yaml b/nova/templates/deployment-conductor.yaml
index e46ba2fa2f..763f14a09b 100644
--- a/nova/templates/deployment-conductor.yaml
+++ b/nova/templates/deployment-conductor.yaml
@@ -22,13 +22,13 @@ metadata:
   name: nova-conductor
 spec:
   replicas: {{ .Values.replicas.conductor }}
-  revisionHistoryLimit: {{ .Values.upgrades.revision_history }}
+  revisionHistoryLimit: {{ .Values.upgrades.deployments.revision_history }}
   strategy:
-    type: {{ .Values.upgrades.pod_replacement_strategy }}
-    {{ if eq .Values.upgrades.pod_replacement_strategy "RollingUpdate" }}
+    type: {{ .Values.upgrades.deployments.pod_replacement_strategy }}
+    {{ if eq .Values.upgrades.deployments.pod_replacement_strategy "RollingUpdate" }}
     rollingUpdate:
-      maxUnavailable: {{ .Values.upgrades.rolling_update.max_unavailable }}
-      maxSurge: {{ .Values.upgrades.rolling_update.max_surge }}
+      maxUnavailable: {{ .Values.upgrades.deployments.rolling_update.max_unavailable }}
+      maxSurge: {{ .Values.upgrades.deployments.rolling_update.max_surge }}
     {{ end }}
   template:
     metadata:
diff --git a/nova/templates/deployment-consoleauth.yaml b/nova/templates/deployment-consoleauth.yaml
index 73548f6ea8..15dad40a75 100644
--- a/nova/templates/deployment-consoleauth.yaml
+++ b/nova/templates/deployment-consoleauth.yaml
@@ -23,13 +23,13 @@ metadata:
   name: nova-consoleauth
 spec:
   replicas: {{ .Values.replicas.consoleauth }}
-  revisionHistoryLimit: {{ .Values.upgrades.revision_history }}
+  revisionHistoryLimit: {{ .Values.upgrades.deployments.revision_history }}
   strategy:
-    type: {{ .Values.upgrades.pod_replacement_strategy }}
-    {{ if eq .Values.upgrades.pod_replacement_strategy "RollingUpdate" }}
+    type: {{ .Values.upgrades.deployments.pod_replacement_strategy }}
+    {{ if eq .Values.upgrades.deployments.pod_replacement_strategy "RollingUpdate" }}
     rollingUpdate:
-      maxUnavailable: {{ .Values.upgrades.rolling_update.max_unavailable }}
-      maxSurge: {{ .Values.upgrades.rolling_update.max_surge }}
+      maxUnavailable: {{ .Values.upgrades.deployments.rolling_update.max_unavailable }}
+      maxSurge: {{ .Values.upgrades.deployments.rolling_update.max_surge }}
     {{ end }}
   template:
     metadata:
diff --git a/nova/templates/deployment-scheduler.yaml b/nova/templates/deployment-scheduler.yaml
index 4d01adf898..0d1228194f 100644
--- a/nova/templates/deployment-scheduler.yaml
+++ b/nova/templates/deployment-scheduler.yaml
@@ -23,13 +23,13 @@ metadata:
   name: nova-scheduler
 spec:
   replicas: {{ .Values.replicas.scheduler }}
-  revisionHistoryLimit: {{ .Values.upgrades.revision_history }}
+  revisionHistoryLimit: {{ .Values.upgrades.deployments.revision_history }}
   strategy:
-    type: {{ .Values.upgrades.pod_replacement_strategy }}
-    {{ if eq .Values.upgrades.pod_replacement_strategy "RollingUpdate" }}
+    type: {{ .Values.upgrades.deployments.pod_replacement_strategy }}
+    {{ if eq .Values.upgrades.deployments.pod_replacement_strategy "RollingUpdate" }}
     rollingUpdate:
-      maxUnavailable: {{ .Values.upgrades.rolling_update.max_unavailable }}
-      maxSurge: {{ .Values.upgrades.rolling_update.max_surge }}
+      maxUnavailable: {{ .Values.upgrades.deployments.rolling_update.max_unavailable }}
+      maxSurge: {{ .Values.upgrades.deployments.rolling_update.max_surge }}
     {{ end }}
   template:
     metadata:
diff --git a/nova/values.yaml b/nova/values.yaml
index df1e99ed98..dfbe4c4013 100644
--- a/nova/values.yaml
+++ b/nova/values.yaml
@@ -70,11 +70,22 @@ images:
   pull_policy: "IfNotPresent"
 
 upgrades:
-  revision_history: 3
-  pod_replacement_strategy: RollingUpdate
-  rolling_update:
-    max_unavailable: 1
-    max_surge: 3
+  deployments:
+    revision_history: 3
+    pod_replacement_strategy: RollingUpdate
+    rolling_update:
+      max_unavailable: 1
+      max_surge: 3
+  daemonsets:
+    pod_replacement_strategy: RollingUpdate
+    compute:
+      enabled: true
+      min_ready_seconds: 0
+      max_unavailable: 1
+    libvirt:
+      enabled: true
+      min_ready_seconds: 0
+      max_unavailable: 1
 
 pod_disruption_budget:
   metadata: