Merge "Add kubernetes addon manager manifest"
diff --git a/kubernetes/files/manifest/kube-addon-manager.yml b/kubernetes/files/manifest/kube-addon-manager.yml
new file mode 100644
index 0000000..93211b1
--- /dev/null
+++ b/kubernetes/files/manifest/kube-addon-manager.yml
@@ -0,0 +1,46 @@
+{%- from "kubernetes/map.jinja" import common with context %}
+
+apiVersion: v1
+kind: Pod
+metadata:
+  name: kube-addon-manager
+  namespace: kube-system
+  annotations:
+    scheduler.alpha.kubernetes.io/critical-pod: ''
+    seccomp.security.alpha.kubernetes.io/pod: 'docker/default'
+  labels:
+    component: kube-addon-manager
+spec:
+  hostNetwork: true
+  containers:
+  - name: kube-addon-manager
+    image: {{ common.get('addonmanager', {}).get('image', 'k8s.gcr.io/kube-addon-manager:v8.9') }}
+    command:
+    - /bin/bash
+    - -c
+    - exec /opt/kube-addons.sh 1>>/var/log/kube-addon-manager.log 2>&1
+    resources:
+      requests:
+        cpu: 5m
+        memory: 50Mi
+    volumeMounts:
+    - mountPath: /etc/kubernetes/
+      name: addons
+      readOnly: true
+    - mountPath: /var/log
+      name: varlog
+      readOnly: false
+    env:
+    - name: TEST_ADDON_CHECK_INTERVAL_SEC
+      value: "30"
+    - name: ADDON_MANAGER_LEADER_ELECTION
+      value: "true"
+    - name: KUBECTL_EXTRA_PRUNE_WHITELIST
+      value: "storage.k8s.io/v1/StorageClass"
+  volumes:
+  - hostPath:
+      path: /etc/kubernetes/
+    name: addons
+  - hostPath:
+      path: /var/log
+    name: varlog
diff --git a/kubernetes/master/setup.sls b/kubernetes/master/setup.sls
index 7eff28d..8b40455 100644
--- a/kubernetes/master/setup.sls
+++ b/kubernetes/master/setup.sls
@@ -17,6 +17,44 @@
     - watch:
       - file: /etc/kubernetes/kubeconfig.sh
 
+/etc/kubernetes/addons/namespace.yaml:
+  file.managed:
+    - source: salt://kubernetes/files/kube-addon-manager/namespace.yaml
+    - user: root
+    - group: root
+    - mode: 644
+    - makedirs: True
+
+{%- if common.get('addonmanager', {}).get('container', false) %}
+
+/etc/kubernetes/manifests/kube-addon-manager.yml:
+  file.managed:
+    - source: salt://kubernetes/files/manifest/kube-addon-manager.yml
+    - template: jinja
+    - user: root
+    - group: root
+    - mode: 644
+    - makedirs: True
+
+/etc/default/kube-addon-manager:
+  file.absent
+
+/usr/bin/kube-addons.sh:
+  file.absent
+
+kube-addon-manager_service_dead:
+  service.dead:
+  - name: kube-addon-manager
+  - enable: False
+
+/etc/systemd/system/kube-addon-manager.service:
+  file.absent
+
+{%- else %}
+
+/etc/kubernetes/manifests/kube-addon-manager.yml:
+  file.absent
+
 /etc/default/kube-addon-manager:
   file.managed:
     - source: salt://kubernetes/files/kube-addon-manager/kube-addons.config
@@ -41,14 +79,6 @@
     - mode: 644
     - makedirs: True
 
-/etc/kubernetes/addons/namespace.yaml:
-  file.managed:
-    - source: salt://kubernetes/files/kube-addon-manager/namespace.yaml
-    - user: root
-    - group: root
-    - mode: 644
-    - makedirs: True
-
 kube-addon-manager_service:
   service.running:
   - name: kube-addon-manager
@@ -61,6 +91,8 @@
   - onlyif: /bin/false
   {%- endif %}
 
+{%- endif %}
+
 /srv/kubernetes/conformance.yml:
   file.managed:
     - source: salt://kubernetes/files/conformance/conformance.yml
diff --git a/metadata/service/common.yml b/metadata/service/common.yml
index 95e9c77..aabc8a4 100644
--- a/metadata/service/common.yml
+++ b/metadata/service/common.yml
@@ -6,6 +6,9 @@
     kubernetes_cluster_domain: ${_param:cluster_domain}
   kubernetes:
     common:
+      addonmanager:
+        container: true
+        image: k8s.gcr.io/kube-addon-manager:v8.9
       addons:
         alertmanager:
           enabled: False