ansible-role-k8s-cinder/tasks/backends/iscsi.yml

208 lines
5.3 KiB
YAML

- name: Upload config files
template:
src: "{{item}}"
dest: /tmp/{{item}}
backup: yes
mode: 0644
with_items:
- lvm.conf
- name: Read configs into memory
slurp:
src: "/tmp/lvm.conf"
register: "lvm_conf"
- name: Create iscsid configmap
ignore_errors: yes
k8s_v1_config_map:
name: iscsid
namespace: '{{ namespace }}'
state: present
verify_ssl: false
labels:
app: iscsid
service: iscsid
data:
config.json: |
{
"command": "/usr/sbin/iscsid -f",
"config_files": [
{
"source": "/var/lib/kolla/config_files/initiatorname.iscsi",
"dest": "/etc/iscsi/initiatorname.iscsi",
"owner": "root",
"perm": "0600"
}
]
}
initiatorname.iscsi: |
InitiatorName=iqn.1994-05.com.redhat:da4a2a2d0d1
- name: Create cinder-volume-iscsi configmaps
ignore_errors: yes
k8s_v1_config_map:
name: cinder-volume-iscsi
namespace: "{{ namespace }}"
state: present
debug: yes
labels:
service: cinder-volume-iscsi
data:
config.json: |
{
"command": "/usr/bin/cinder-volume --config-file /usr/share/cinder/cinder-dist.conf --config-file /etc/cinder/cinder.conf",
"config_files": [
{
"source": "/var/lib/kolla/config_files/cinder.conf",
"dest": "/etc/cinder/cinder.conf",
"owner": "cinder",
"perm": "0600"
},
{
"source": "/var/lib/kolla/config_files/lvm.conf",
"dest": "/etc/lvm/lvm.conf",
"owner": "root",
"perm": "0644"
}
],
"permissions": [
{
"path": "/var/lib/cinder",
"owner": "cinder:cinder",
"recurse": true
},
{
"path": "/var/log/kolla/cinder",
"owner": "cinder:cinder",
"recurse": true
}
]
}
cinder.conf: |
{{cinder_conf['content'] | b64decode}}
lvm.conf: |
{{lvm_conf['content'] | b64decode}}
- name: Create Cinder Volume Deployment
k8s_apps_v1beta1_deployment:
name: cinder-volume-iscsi
namespace: "{{ namespace }}"
service_account_name: '{{ privileged_service_account }}'
labels:
app: cinder-volume-iscsi
service: cinder-volume-iscsi
replicas: 1
spec_template_metadata_labels:
app: cinder-volume-iscsi
service: cinder-volume-iscsi
containers:
- name: cinder-volume
securityContext:
privileged: true
image: tripleoupstream/centos-binary-cinder-volume:latest
volumeMounts:
- name: kolla-config
mountPath: /var/lib/kolla/config_files/
- mountPath: /etc/localtime
name: host-etc-localtime
readOnly: true
- mountPath: /run
name: run
- mountPath: /dev
name: dev
- mountPath: /sys/fs/cgroup
name: sys-fs-cgroup
- mountPath: /lib/modules
name: lib-modules
env:
- name: TZ
value: UTC
- name: KOLLA_CONFIG_STRATEGY
value: COPY_ALWAYS
- name: KOLLA_KUBERNETES
value: ""
volumes:
- name: host-etc-localtime
hostPath:
path: /etc/localtime
- name: lib-modules
hostPath:
path: /lib/modules
- name: run
hostPath:
path: /run
- name: dev
hostPath:
path: /dev
- name: sys-fs-cgroup
hostPath:
path: /sys/fs/cgroup
- name: kolla-config
config_map:
name: cinder-volume-iscsi
- name: Create Iscsid Deployment
k8s_apps_v1beta1_deployment:
name: iscsid
namespace: '{{ namespace }}'
service_account_name: '{{ privileged_service_account }}'
node_selector:
controller: "true"
labels:
app: iscsid
service: iscsid
replicas: 1
spec_template_metadata_labels:
app: iscsid
service: iscsid
containers:
- name: iscsid
securityContext:
privileged: true
image: tripleoupstream/centos-binary-iscsid:latest
volumeMounts:
- mountPath: /etc/localtime
name: host-etc-localtime
readOnly: true
- mountPath: /run
name: run
- mountPath: /dev
name: dev
- mountPath: /sys/fs/cgroup
name: sys-fs-cgroup
- mountPath: /lib/modules
name: lib-modules
- name: kolla-config
mountPath: /var/lib/kolla/config_files/
env:
- name: TZ
value: UTC
- name: KOLLA_CONFIG_STRATEGY
value: COPY_ALWAYS
- name: KOLLA_KUBERNETES
value: ""
volumes:
- name: host-etc-localtime
hostPath:
path: /etc/localtime
- name: lib-modules
hostPath:
path: /lib/modules
- name: run
hostPath:
path: /run
- name: dev
hostPath:
path: /dev
- name: sys-fs-cgroup
hostPath:
path: /sys/fs/cgroup
- name: kolla-config
config_map:
name: iscsid