add PV storageclass
Change-Id: I58702cc02925ab7a5b492d04551274e96efeab74
diff --git a/.kitchen.travis.yml b/.kitchen.travis.yml
index 32d5bae..645a273 100644
--- a/.kitchen.travis.yml
+++ b/.kitchen.travis.yml
@@ -3,4 +3,15 @@
- name: <%= ENV['SUITE'] %>
provisioner:
pillars-from-files:
- kubernetes.sls: tests/pillar/<%= ENV['SUITE'] %>.sls
+ <%# to parse SUITE=kubernetes:pillar1,kubernetes_extra:pillar2 %>
+ <%- ENV['SUITE'].split(',').each |suite| %>
+ <%- set suite = [suite.split(':')].flatten %>
+ <%- if suite.length > 1 %>
+ <%- set key=suite[0] %>
+ <%- set file=suite[1] %>
+ <%- else %>
+ <%- set key='kubernetes' %>
+ <%- set file=suite[0] %>
+ <%- end %>
+ <%= key %>.sls: tests/pillar/<%= file %>.sls
+ <%- end %>
diff --git a/.kitchen.yml b/.kitchen.yml
index bdcae80..79f2140 100644
--- a/.kitchen.yml
+++ b/.kitchen.yml
@@ -35,6 +35,8 @@
- linux_repo_opencontrail
- linux
- kubernetes
+ - kubernetes_extra
+ kubernetes_extra.sls: {}
linux.sls:
linux:
system:
@@ -85,4 +87,10 @@
pillars-from-files:
kubernetes.sls: tests/pillar/pool_contrail4_0.sls
+ - name: common_storageclass
+ provisioner:
+ pillars-from-files:
+ kubernetes.sls: tests/pillar/master_cluster.sls
+ kubernetes_extra.sls: tests/pillar/common_storageclass.sls
+
# vim: ft=yaml sw=2 ts=2 sts=2 tw=125
diff --git a/.travis.yml b/.travis.yml
index bdf3c65..95434f9 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -28,6 +28,7 @@
- PLATFORM=trevorj/salty-whales:xenial SUITE=master_contrail4_0
- PLATFORM=trevorj/salty-whales:trusty SUITE=pool_contrail4_0
- PLATFORM=trevorj/salty-whales:xenial SUITE=pool_contrail4_0
+ - PLATFORM=trevorj/salty-whales:trusty SUITE=common_storageclass
before_script:
- set -o pipefail
diff --git a/README.rst b/README.rst
index 71739b6..c3df5f7 100644
--- a/README.rst
+++ b/README.rst
@@ -583,13 +583,22 @@
addons:
storageclass:
aws_slow:
- name: slow
enabled: True
default: True
provisioner: aws-ebs
+ name: slow
type: gp2
iopspergb: "10"
zones: xxx
+ nfs_shared:
+ name: elasti01
+ enabled: True
+ provisioner: nfs
+ spec:
+ name: elastic_data
+ nfs:
+ server: 10.0.0.1
+ path: /exported_path
Kubernetes namespaces
---------------------
diff --git a/kubernetes/files/kube-addons/storageclass/nfs.yaml b/kubernetes/files/kube-addons/storageclass/nfs.yaml
new file mode 100644
index 0000000..c24c6d0
--- /dev/null
+++ b/kubernetes/files/kube-addons/storageclass/nfs.yaml
@@ -0,0 +1,25 @@
+{%- from "kubernetes/map.jinja" import common with context %}
+kind: PersistentVolume
+apiVersion: v1
+metadata:
+ name: {{ storageclass_name }}
+ {%- if storageclass.default is defined %}
+ annotations:
+ {%- if storageclass.default %}
+ storageclass.beta.kubernetes.io/is-default-class: "true"
+ {%- endif %}
+ {%- endif %}
+spec:
+ {%- if storageclass.spec.capacity is mapping %}
+ capacity:
+ storage: {{ storageclass.spec.capacity.storage }}
+ {%- endif %}
+ accessModes:
+ {%- for mode in storageclass.spec.get('access_modes', ['ReadWriteOnce']) %}
+ - {{ mode }}
+ {%- endfor %}
+ persistentVolumeReclaimPolicy: {{ storageclass.spec.get('reclaim_policy', 'Recycle') }}
+ storageClassName: {{ storageclass.spec.name }}
+ nfs:
+ path: {{ storageclass.spec.nfs.path }}
+ server: {{ storageclass.spec.nfs.server }}
diff --git a/kubernetes/master/kube-addons.sls b/kubernetes/master/kube-addons.sls
index c4b7ad2..8344337 100644
--- a/kubernetes/master/kube-addons.sls
+++ b/kubernetes/master/kube-addons.sls
@@ -51,7 +51,7 @@
{% endif %}
-{%- if common.addons.helm.enabled %}
+{%- if common.addons.get('helm', {'enabled': False}).enabled %}
/etc/kubernetes/addons/helm/helm-tiller-deploy.yml:
file.managed:
- source: salt://kubernetes/files/kube-addons/helm/helm-tiller-deploy.yml
@@ -65,6 +65,7 @@
{%- if common.addons.storageclass is defined %}
{%- for storageclass_name, storageclass in common.addons.get('storageclass', {}).iteritems() %}
+{%- set storageclass_name = storageclass.get('name', storageclass_name) %}
/etc/kubernetes/addons/storageclass/{{ storageclass_name }}.yaml:
file.managed:
@@ -81,7 +82,7 @@
{% endif %}
-{%- if common.addons.netchecker.enabled %}
+{%- if common.addons.get('netchecker', {'enabled': False}).enabled %}
{%- for resource in ['svc', 'server', 'agent'] %}
@@ -97,7 +98,7 @@
{% endif %}
-{%- if common.addons.dns.enabled %}
+{%- if common.addons.get('dns', {'enabled': False}).enabled %}
/etc/kubernetes/addons/dns/kubedns-svc.yaml:
file.managed:
@@ -180,9 +181,10 @@
- group: root
- dir_mode: 755
- makedirs: True
+
{% endif %}
-{%- if common.addons.dashboard.enabled %}
+{%- if common.addons.get('dashboard', {'enabled': False}).enabled %}
/etc/kubernetes/addons/dashboard/dashboard-service.yaml:
file.managed:
@@ -202,7 +204,7 @@
{% endif %}
-{%- if common.addons.heapster_influxdb.enabled %}
+{%- if common.addons.get('heapster_influxdb', {'enabled': False}).enabled %}
/etc/kubernetes/addons/heapster-influxdb/heapster-address.yaml:
file.managed:
diff --git a/tests/pillar/common_storageclass.sls b/tests/pillar/common_storageclass.sls
new file mode 100644
index 0000000..47c3cec
--- /dev/null
+++ b/tests/pillar/common_storageclass.sls
@@ -0,0 +1,72 @@
+kubernetes:
+ master:
+ enabled: true
+ admin:
+ password: password
+ username: admin
+ version: v1.2.4
+ host:
+ name: node040
+ etcd:
+ members:
+ - host: 10.0.175.100
+ name: node040
+ namespace:
+ kube-system:
+ enabled: true
+ network:
+ engine: calico
+ hash: fb5e30ebe6154911a66ec3fb5f1195b2
+ private_ip_range: 10.150.0.0/16
+ version: v0.19.0
+ etcd:
+ members:
+ - host: 127.0.0.1
+ port: 4001
+ - host: 127.0.0.1
+ port: 4001
+ - host: 127.0.0.1
+ port: 4001
+ service_addresses: 10.254.0.0/16
+ storage:
+ engine: glusterfs
+ members:
+ - host: 10.0.175.101
+ port: 24007
+ - host: 10.0.175.102
+ port: 24007
+ - host: 10.0.175.103
+ port: 24007
+ port: 24007
+ registry:
+ host: tcpcloud
+ common:
+ network:
+ engine: none
+ addons:
+ storageclass:
+ nfs_elastic_1:
+ enabled: True
+ provisioner: nfs
+ spec:
+ name: elastic_data
+ nfs:
+ server: 10.0.0.1
+ path: /exported_path/elastic01
+ nfs_elastic_2:
+ enabled: True
+ provisioner: nfs
+ spec:
+ name: elastic_data
+ nfs:
+ server: 10.0.0.1
+ path: /exported_path/elastic02
+ nfs_influx:
+ name: influx01
+ enabled: False
+ provisioner: nfs
+ spec:
+ name: influx
+ nfs:
+ server: 10.0.0.1
+ path: /exported_path/inlfux01