Merge "[k8s] Fix docker storage of Fedora CoreOS"
This commit is contained in:
commit
126bdb605d
|
@ -1112,7 +1112,7 @@ Network driver (network-driver)
|
|||
`Networking`_ section for more details.
|
||||
|
||||
Volume driver (volume-driver)
|
||||
Specified in the ClusterTemplate to select the volume driver. The supported
|
||||
Specified in the ClusterTemplate to select the volume driver. The supported
|
||||
volume driver is 'cinder', allowing Cinder volumes to be mounted in
|
||||
containers for use as persistent storage. Data written to these volumes
|
||||
will persist after the container exits and can be accessed again from other
|
||||
|
@ -1120,10 +1120,12 @@ Volume driver (volume-driver)
|
|||
will be deleted. Refer to the `Storage`_ section for more details.
|
||||
|
||||
Storage driver (docker-storage-driver)
|
||||
Specified in the ClusterTemplate to select the Docker storage driver. The
|
||||
Specified in the ClusterTemplate to select the Docker storage driver. The
|
||||
default is 'devicemapper'. Refer to the `Storage`_ section for more
|
||||
details.
|
||||
|
||||
**NOTE:** For Fedora CoreOS driver, devicemapper is not supported.
|
||||
|
||||
Image (image)
|
||||
Specified in the ClusterTemplate to indicate the image to boot the servers.
|
||||
The image binary is loaded in Glance with the attribute
|
||||
|
@ -2929,6 +2931,12 @@ of Docker storage drivers available.
|
|||
container isolation, although it still runs in enforcing mode on the
|
||||
cluster compute instances.
|
||||
|
||||
* 'overlay2' is the preferred storage driver, for all currently supported
|
||||
Linux distributions, and requires no extra configuration. When possible,
|
||||
overlay2 is the recommended storage driver. When installing Docker for
|
||||
the first time, overlay2 is used by default.
|
||||
|
||||
|
||||
Persistent storage
|
||||
------------------
|
||||
|
||||
|
|
|
@ -1,55 +1,37 @@
|
|||
ssh_cmd="ssh -F /srv/magnum/.ssh/config root@localhost"
|
||||
|
||||
configure_storage_driver_generic() {
|
||||
|
||||
cat > /etc/systemd/system/var-lib-docker.mount <<EOF
|
||||
[Unit]
|
||||
Description=Mount ephemeral to /var/lib/docker
|
||||
|
||||
[Mount]
|
||||
What=/dev/vdb
|
||||
Where=/var/lib/docker
|
||||
Type=ext4
|
||||
|
||||
[Install]
|
||||
WantedBy=local-fs.target
|
||||
EOF
|
||||
|
||||
|
||||
cat > /etc/sysconfig/enable-docker-mount.sh <<EOF
|
||||
#!/bin/sh
|
||||
. /etc/sysconfig/heat-params
|
||||
if [ -n "$DOCKER_VOLUME_SIZE" ] && [ "$DOCKER_VOLUME_SIZE" -gt 0 ]; then
|
||||
if [[ "$(blkid -o value -s TYPE /dev/vdb)" -eq 0 ]]; then
|
||||
systemctl daemon-reload
|
||||
systemctl start var-lib-docker.mount
|
||||
systemctl enable var-lib-docker.mount
|
||||
else
|
||||
mkfs -t ext4 /dev/vdb
|
||||
systemctl daemon-reload
|
||||
systemctl start var-lib-docker.mount
|
||||
systemctl enable var-lib-docker.mount
|
||||
fi
|
||||
runtime=${CONTAINER_RUNTIME}
|
||||
if [ ${CONTAINER_RUNTIME} = "containerd" ] ; then
|
||||
storage_dir="/var/lib/containerd"
|
||||
else
|
||||
storage_dir="/var/lib/docker"
|
||||
runtime="docker"
|
||||
fi
|
||||
EOF
|
||||
|
||||
chmod +x /etc/sysconfig/enable-docker-mount.sh
|
||||
clear_docker_storage () {
|
||||
# stop docker
|
||||
$ssh_cmd systemctl stop ${runtime}
|
||||
# clear storage graph
|
||||
$ssh_cmd rm -rf ${storage_dir}
|
||||
$ssh_cmd mkdir -p ${storage_dir}
|
||||
}
|
||||
|
||||
cat > /etc/systemd/system/enable-docker-mount.service <<EOF
|
||||
[Unit]
|
||||
Description=Mount docker volume
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
EnvironmentFile=/etc/sysconfig/heat-params
|
||||
ExecStart=/etc/sysconfig/enable-docker-mount.sh
|
||||
|
||||
[Install]
|
||||
RequiredBy=multi-user.target
|
||||
EOF
|
||||
# Configure generic docker storage driver.
|
||||
configure_storage_driver_generic() {
|
||||
clear_docker_storage
|
||||
|
||||
if [ -n "$DOCKER_VOLUME_SIZE" ] && [ "$DOCKER_VOLUME_SIZE" -gt 0 ]; then
|
||||
$ssh_cmd mkfs.xfs -f ${device_path}
|
||||
echo "${device_path} ${storage_dir} xfs defaults 0 0" >> /etc/fstab
|
||||
$ssh_cmd mount -a
|
||||
$ssh_cmd restorecon -R ${storage_dir}
|
||||
fi
|
||||
if [ ${CONTAINER_RUNTIME} = "host-docker" ] ; then
|
||||
sed -i -E 's/^OPTIONS=("|'"'"')/OPTIONS=\1--storage-driver='$1' /' /etc/sysconfig/docker
|
||||
fi
|
||||
}
|
||||
|
||||
configure_devicemapper() {
|
||||
configure_storage_driver_generic
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -269,7 +269,9 @@ parameters:
|
|||
docker_storage_driver:
|
||||
type: string
|
||||
description: docker storage driver name
|
||||
default: "devicemapper"
|
||||
default: "overlay2"
|
||||
constraints:
|
||||
- allowed_pattern: "^(?!devicemapper$).*"
|
||||
|
||||
cgroup_driver:
|
||||
type: string
|
||||
|
|
|
@ -469,7 +469,10 @@ resources:
|
|||
- get_file: ../../common/templates/fragments/configure-docker-registry.sh
|
||||
- get_file: ../../common/templates/kubernetes/fragments/configure-kubernetes-minion.sh
|
||||
- get_file: ../../common/templates/kubernetes/fragments/add-proxy.sh
|
||||
# TODO add docker_storage_setup
|
||||
- str_replace:
|
||||
template: {get_file: ../../common/templates/fragments/configure-docker-storage.sh}
|
||||
params:
|
||||
$configure_docker_storage_driver: {get_file: ../../common/templates/fragments/configure_docker_storage_driver_fedora_coreos.sh}
|
||||
- get_file: ../../common/templates/kubernetes/fragments/enable-services-minion.sh
|
||||
- get_file: ../../common/templates/fragments/enable-docker-registry.sh
|
||||
|
||||
|
|
Loading…
Reference in New Issue