Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding multipath-tools extension #505

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ TARGETS += kata-containers
TARGETS += lldpd
TARGETS += mdadm
TARGETS += mei
TARGETS += multipath-tools
TARGETS += nut-client
TARGETS += nvidia-container-toolkit-lts
TARGETS += nvidia-container-toolkit-production
Expand Down
8 changes: 8 additions & 0 deletions multipath-tools/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## Multipath-tools
This extension adds multipath-tools to Talos. Mutipath is an essential feature in many enterprise environments because it enables high availability and fault tolerance of storage subsystems. Typically these storage subsystems are connected through a Fiber Channel network, but other methods like iSCSI exist as well. This extension will start the multpath daemon as a Talos service and use a default config file packaged with this extension.

### Customization
The default configuration file is located in src/rootfs/etc/multipath.conf, you may wish to update this to suit the needs of your particular storage subsystem. In particular the load balancing algorithm in there right now is round-robin. This is due to Talos not yet having additional kernel modules available for more advanced load balancing algorithms. In the future this may change and you may want to customize this part of the configuration.

### Limitations
The multipath bindings file in this extension is currently ephemeral. If the Talos node reboots the bindings file will be recreated on startup. This could be troublesome in some envrionments. Future versions of this extension may address this limitation.
10 changes: 10 additions & 0 deletions multipath-tools/manifest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: v1alpha1
metadata:
name: multipath-tools
version: "$VERSION"
author: Cision
description: |
This system extension provides multipath-tools for storage redundancy and reliability.
compatibility:
talos:
version: ">= v1.0.0"
58 changes: 58 additions & 0 deletions multipath-tools/multipath-tools.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: multipath-tools
container:
security:
rootfsPropagation: shared
maskedPaths: []
readonlyPaths: []
writeableSysfs: true
entrypoint: /usr/local/bin/start_multipath
args: []
mounts:
- source: /usr/local
destination: /usr/local
type: bind
options:
- bind
- rw
- source: /lib/modules
destination: /usr/local/lib/modules
type: bind
options:
- bind
- rw
- source: /proc
destination: /usr/local/proc
type: bind
options:
- bind
- rw
- source: /sys
destination: /usr/local/sys
type: bind
options:
- bind
- rw
- source: /dev
destination: /usr/local/dev
type: bind
options:
- bind
- rw
- source: /run
destination: /usr/local/run
type: bind
options:
- bind
- rw
- source: /tmp
destination: /usr/local/etc/multipath
type: bind
options:
- bind
- rw
depends:
- network:
- addresses
- service: udevd
- path: /dev/mapper/control
restart: always
34 changes: 34 additions & 0 deletions multipath-tools/pkg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: multipath-tools
variant: scratch
shell: /toolchain/bin/bash
dependencies:
- stage: base
steps:
- env:
GOPATH: /go
cachePaths:
- /.cache/go-build
- /go/pkg
prepare:
- |
sed -i 's#$VERSION#{{ .VERSION }}#' /pkg/manifest.yaml
build:
- |
export PATH=${PATH}:${TOOLCHAIN}/go/bin

cd /pkg/src/go
CGO_ENABLED=0 go build -o ./start_multipath .
install:
- |
mkdir -p /rootfs/usr/local
cp -ar /pkg/src/rootfs/* /rootfs/usr/local
cp -ar /pkg/src/go/start_multipath /rootfs/usr/local/bin
mkdir -p /rootfs/usr/local/etc/containers
mkdir -p /rootfs/usr/local/lib/containers/multipath-tools
finalize:
- from: /rootfs
to: /rootfs
- from: /pkg/manifest.yaml
to: /
- from: /pkg/multipath-tools.yaml
to: /rootfs/usr/local/etc/containers/
3 changes: 3 additions & 0 deletions multipath-tools/src/go/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/cision/multipath-tools

go 1.21
28 changes: 28 additions & 0 deletions multipath-tools/src/go/start_multipath.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package main

import (
"fmt"
"os"
"os/exec"
"syscall"
)

func main() {
fmt.Println("Starting multipath daemon...")

//setup a chroot environment for the extension
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think we need this, with mountPropogation shared should work as a normal extension service

newRoot := "/usr/local"
if err := syscall.Chroot(newRoot); err != nil {
fmt.Println("Error:", err)
os.Exit(1)
}

//start the multipath daemon in the chroot environment
cmd := exec.Command("/usr/sbin/multipathd", "-d")
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
fmt.Println("Command execution failed:", err)
}
}
Loading