Mount extra 80Gb volume
This PS mounts extra 80Gb volume if available and mounts it to /opt/ext_vol. It also alters docker and containerd configs to move their root folder to that extra volume. This helps zuul gates to succeed when a node with 40Gb volume is assigned to a zuul gate. Change-Id: I1c91b13c233bac5ebfe6e3cb16d4288df2c2fe80
This commit is contained in:
parent
07c735f632
commit
f9b0360418
@ -14,4 +14,5 @@
|
|||||||
- hosts: all
|
- hosts: all
|
||||||
roles:
|
roles:
|
||||||
- start-zuul-console
|
- start-zuul-console
|
||||||
|
- mount-extra-volume
|
||||||
...
|
...
|
||||||
|
@ -13,4 +13,8 @@
|
|||||||
kubectl:
|
kubectl:
|
||||||
user: zuul
|
user: zuul
|
||||||
group: zuul
|
group: zuul
|
||||||
|
docker:
|
||||||
|
root_path: /var/lib/docker
|
||||||
|
containerd:
|
||||||
|
root_path: /var/lib/containerd
|
||||||
...
|
...
|
||||||
|
@ -3,7 +3,7 @@ imports = []
|
|||||||
oom_score = 0
|
oom_score = 0
|
||||||
plugin_dir = ""
|
plugin_dir = ""
|
||||||
required_plugins = []
|
required_plugins = []
|
||||||
root = "/var/lib/containerd"
|
root = "{{ containerd.root_path }}"
|
||||||
state = "/run/containerd"
|
state = "/run/containerd"
|
||||||
temp = ""
|
temp = ""
|
||||||
version = 2
|
version = 2
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"data-root": "{{ docker.root_path }}",
|
||||||
"exec-opts": ["native.cgroupdriver=systemd"],
|
"exec-opts": ["native.cgroupdriver=systemd"],
|
||||||
"log-driver": "json-file",
|
"log-driver": "json-file",
|
||||||
"log-opts": {
|
"log-opts": {
|
||||||
|
@ -54,7 +54,7 @@
|
|||||||
executable: /bin/bash
|
executable: /bin/bash
|
||||||
|
|
||||||
- name: Configure Docker daemon
|
- name: Configure Docker daemon
|
||||||
copy:
|
template:
|
||||||
src: files/daemon.json
|
src: files/daemon.json
|
||||||
dest: /etc/docker/daemon.json
|
dest: /etc/docker/daemon.json
|
||||||
|
|
||||||
|
18
roles/mount-extra-volume/defaults/main.yml
Normal file
18
roles/mount-extra-volume/defaults/main.yml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
---
|
||||||
|
extra_volume:
|
||||||
|
size: 80G
|
||||||
|
type: Linux
|
||||||
|
mount_point: /opt/ext_vol
|
||||||
|
...
|
52
roles/mount-extra-volume/tasks/main.yaml
Normal file
52
roles/mount-extra-volume/tasks/main.yaml
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
---
|
||||||
|
- name: Mount additional {{ extra_volume.size }} volume if available
|
||||||
|
when:
|
||||||
|
- ansible_distribution == 'Ubuntu'
|
||||||
|
- (ansible_mounts|selectattr("mount", "equalto", "/")|list)[0].size_available < 50000000000
|
||||||
|
block:
|
||||||
|
- name: Mount additional {{ extra_volume.size }} volume if available
|
||||||
|
shell: |
|
||||||
|
set -ex
|
||||||
|
sudo fdisk --list
|
||||||
|
df -h
|
||||||
|
sudo mkdir -p ${EXTRA_VOLUME_MOUNT_POINT}
|
||||||
|
BIG_VOLUME=$(sudo fdisk -l 2>&1 | grep -E ${EXTRA_VOLUME_SIZE} | grep ${EXTRA_VOLUME_TYPE} | awk '{print $1}')
|
||||||
|
if ! mount | grep "${BIG_VOLUME}"
|
||||||
|
then
|
||||||
|
sudo mkfs.ext4 "${BIG_VOLUME}"
|
||||||
|
sudo mount "${BIG_VOLUME}" ${EXTRA_VOLUME_MOUNT_POINT}
|
||||||
|
df -h
|
||||||
|
fi
|
||||||
|
environment:
|
||||||
|
EXTRA_VOLUME_MOUNT_POINT: "{{ extra_volume.mount_point }}"
|
||||||
|
EXTRA_VOLUME_SIZE: "{{ extra_volume.size }}"
|
||||||
|
EXTRA_VOLUME_TYPE: "{{ extra_volume.type }}"
|
||||||
|
|
||||||
|
- name: Print configured docker root path
|
||||||
|
debug:
|
||||||
|
msg: "Docker root_path: {{ docker.root_path }}"
|
||||||
|
|
||||||
|
- name: Print configured containerd root path
|
||||||
|
debug:
|
||||||
|
msg: "containerd root_path: {{ containerd.root_path }}"
|
||||||
|
|
||||||
|
- name: Create mountpoints
|
||||||
|
shell: |
|
||||||
|
sudo mkdir -pv "${DOCKER_ROOT_PATH}"
|
||||||
|
sudo mkdir -pv "${CONTAINERD_ROOT_PATH}"
|
||||||
|
environment:
|
||||||
|
DOCKER_ROOT_PATH: "{{ docker.root_path }}"
|
||||||
|
CONTAINERD_ROOT_PATH: "{{ containerd.root_path }}"
|
||||||
|
...
|
@ -83,6 +83,14 @@
|
|||||||
- playbooks/deploy-env.yaml
|
- playbooks/deploy-env.yaml
|
||||||
- playbooks/run-scripts.yaml
|
- playbooks/run-scripts.yaml
|
||||||
vars:
|
vars:
|
||||||
|
extra_volume:
|
||||||
|
size: 80G
|
||||||
|
type: Linux
|
||||||
|
mount_point: /opt/ext_vol
|
||||||
|
docker:
|
||||||
|
root_path: "/opt/ext_vol/docker"
|
||||||
|
containerd:
|
||||||
|
root_path: "/opt/ext_vol/containerd"
|
||||||
# the k8s package versions are available here
|
# the k8s package versions are available here
|
||||||
# https://packages.cloud.google.com/apt/dists/kubernetes-xenial/main/binary-amd64/Packages
|
# https://packages.cloud.google.com/apt/dists/kubernetes-xenial/main/binary-amd64/Packages
|
||||||
kube_version: "1.26.3-00"
|
kube_version: "1.26.3-00"
|
||||||
|
Loading…
Reference in New Issue
Block a user