Kubernetes StorageClass for AWS EBS
Change-Id: I401fd8adc7e9ff828fe539ef75b4ca24e97f2b12
diff --git a/README.rst b/README.rst
index de35b08..489c455 100644
--- a/README.rst
+++ b/README.rst
@@ -571,6 +571,26 @@
port: 24007
...
+Kubernetes Storage Class
+------------------------
+
+AWS EBS storageclass integration. It also requires to create IAM policy and profiles for instances and tag all resources by KubernetesCluster in EC2.
+
+.. code-block:: yaml
+
+ kubernetes:
+ common:
+ addons:
+ storageclass:
+ aws_slow:
+ name: slow
+ enabled: True
+ default: True
+ provisioner: aws-ebs
+ type: gp2
+ iopspergb: "10"
+ zones: xxx
+
Kubernetes namespaces
---------------------
diff --git a/kubernetes/files/kube-addons/storageclass/aws-ebs.yaml b/kubernetes/files/kube-addons/storageclass/aws-ebs.yaml
new file mode 100644
index 0000000..557f86f
--- /dev/null
+++ b/kubernetes/files/kube-addons/storageclass/aws-ebs.yaml
@@ -0,0 +1,14 @@
+{%- from "kubernetes/map.jinja" import common with context %}
+kind: StorageClass
+apiVersion: storage.k8s.io/v1
+metadata:
+ name: {{ storageclass.name }}
+ {%- if storageclass.default %}
+ annotations:
+ storageclass.beta.kubernetes.io/is-default-class: "true"
+ {%- endif %}
+ labels:
+ addonmanager.kubernetes.io/mode: Reconcile
+provisioner: kubernetes.io/{{ storageclass.provisioner}}
+parameters:
+ type: {{ storageclass.get('type', 'gp2') }}
diff --git a/kubernetes/master/kube-addons.sls b/kubernetes/master/kube-addons.sls
index 812c84b..c4b7ad2 100644
--- a/kubernetes/master/kube-addons.sls
+++ b/kubernetes/master/kube-addons.sls
@@ -62,6 +62,25 @@
{% endif %}
+{%- if common.addons.storageclass is defined %}
+
+{%- for storageclass_name, storageclass in common.addons.get('storageclass', {}).iteritems() %}
+
+/etc/kubernetes/addons/storageclass/{{ storageclass_name }}.yaml:
+ file.managed:
+ - source: salt://kubernetes/files/kube-addons/storageclass/{{ storageclass.provisioner }}.yaml
+ - template: jinja
+ - makedirs: True
+ - dir_mode: 755
+ - group: root
+ - defaults:
+ storageclass_name: {{ storageclass_name }}
+ storageclass: {{ storageclass|yaml }}
+
+{%- endfor %}
+
+{% endif %}
+
{%- if common.addons.netchecker.enabled %}
{%- for resource in ['svc', 'server', 'agent'] %}