Skip to content

Commit

Permalink
添加cluster-storage roles
Browse files Browse the repository at this point in the history
  • Loading branch information
lusyoe committed Jul 25, 2018
1 parent 5a7d610 commit 4750465
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 43 deletions.
5 changes: 5 additions & 0 deletions 08.cluster-storage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- hosts:
- deploy
- kube-node
roles:
- cluster-storage
5 changes: 0 additions & 5 deletions roles/cluster-addon/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,3 @@ heapster_offline: "heapster_v1.5.1.tar"

# prometheus 自动安装
#prometheus_install: "no"

# 动态存储自动安装
nfsclient_install: "no"
alicloudnas_install: "no"
storage_install: "no"
29 changes: 0 additions & 29 deletions roles/cluster-addon/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,32 +79,3 @@
when: '"heapster" not in pod_info.stdout and heapster_install == "yes"'
ignore_errors: true

- block:
- name: 准备部署nfs-client动态存储
template:
src: storage/nfs/nfs-client-provisioner.yaml.j2
dest: "{{ base_dir }}/manifests/storage/nfs/nfs-client-provisioner.yaml"
- name: 开始部署nfs-client动态存储
shell: "{{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/storage/nfs/nfs-client-provisioner.yaml"
when: 'nfsclient_install == "yes"'

- block:
- name: 准备部署alicloud-nas动态存储
template:
src: storage/alicloud-nas/alicloud-nas.yaml.j2
dest: "{{ base_dir }}/manifests/storage/alicloud-nas/alicloud-nas.yaml"
- name: 开始部署alicloud-disk存储
shell: "{{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/storage/alicloud-nas/alicloud-disk.yaml"
- name: 开始部署alicloud-nas动态存储
shell: "{{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/storage/alicloud-nas/alicloud-nas.yaml"
when: 'alicloudnas_install == "yes"'

- block:
- name: 准备部署动态存储类
template:
src: storage/dynamic-storageclass.yaml.j2
dest: "{{ base_dir }}/manifests/storage/dynamic-storageclass.yaml"
- name: 开始部署动态存储类
shell: "{{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/storage/dynamic-storageclass.yaml"
when: 'storage_install == "yes"'

8 changes: 8 additions & 0 deletions roles/cluster-storage/cluster-storage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
hosts: deploy
roles:
- cluster-storage
vars:
storage_type: nfs
storage_server: 172.16.3.86
storage_path: /data/nfs
storage_class_name: nfs-dynamic-class
5 changes: 5 additions & 0 deletions roles/cluster-storage/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# 动态存储类型, 目前支持nfs和alicloud-nas
storage_type: nfs
storage_server: 172.16.3.86
storage_path: /data/nfs
storage_class_name: nfs-dynamic-class
27 changes: 27 additions & 0 deletions roles/cluster-storage/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
- block:
- name: 准备部署nfs-client动态存储
template:
src: nfs/nfs-client-provisioner.yaml.j2
dest: "{{ base_dir }}/manifests/storage/nfs/nfs-client-provisioner.yaml"
- name: 开始部署nfs-client动态存储
shell: "{{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/storage/nfs/nfs-client-provisioner.yaml"
when: 'storage_type == "nfs"'

- block:
- name: 准备部署alicloud-nas动态存储
template:
src: alicloud-nas/alicloud-nas.yaml.j2
dest: "{{ base_dir }}/manifests/storage/alicloud-nas/alicloud-nas.yaml"
- name: 开始部署alicloud-disk存储
shell: "{{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/storage/alicloud-nas/alicloud-disk.yaml"
- name: 开始部署alicloud-nas动态存储
shell: "{{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/storage/alicloud-nas/alicloud-nas.yaml"
when: 'storage_type == "alicloud-nas"'

- block:
- name: 准备部署动态存储类
template:
src: dynamic-storageclass.yaml.j2
dest: "{{ base_dir }}/manifests/storage/dynamic-storageclass.yaml"
- name: 开始部署动态存储类
shell: "{{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/storage/dynamic-storageclass.yaml"
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ spec:
- name: PROVISIONER_NAME
value: alicloud/nas
- name: NFS_SERVER
value: {{ STORAGE_SERVER }}
value: {{ storage_server }}
- name: NFS_PATH
value: {{ STORAGE_PATH }}
value: {{ storage_path }}
volumes:
- name: nfs-client-root
nfs:
server: {{ STORAGE_SERVER }}
path: {{ STORAGE_PATH }}
server: {{ storage_server }}
path: {{ storage_path }}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: {{ STORAGE_CLASS_NAME }}
name: {{ storage_class_name }}
provisioner: prov
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ spec:
# 此处供应者名字供storageclass调用
value: prov
- name: NFS_SERVER
value: {{ STORAGE_SERVER }}
value: {{ storage_server }}
- name: NFS_PATH
value: {{ STORAGE_PATH }}
value: {{ storage_path }}
volumes:
- name: nfs-client-root
nfs:
server: {{ STORAGE_SERVER }}
path: {{ STORAGE_PATH }}
server: {{ storage_server }}
path: {{ storage_path }}

0 comments on commit 4750465

Please sign in to comment.