🐳 pifanctl is a CLI tool for PWM fan control on Raspberry Pi. It can be easily run via Docker and Kubernetes and is optimized for ARM64 architecture. The project features a CI/CD pipeline using GitHub Actions with Actions Runner Controller (ARC), ensuring all builds are tested in actual Raspberry Pi environments. Please enjoy it!
- Raspberry Pi (ARM64)
- Python 3.8+
You should access the Raspberry Pi (ARM64) to run the following commands.
curl -fsSL https://raw.githubusercontent.com/jyje/pifanctl/main/install.sh -o install-pifanctl.sh
chmod +x install-pifanctl.sh
./install-pifanctl.sh
rm install-pifanctl.sh
## Uninstall
# rm -rf $HOME/.pifanctl
After installation, you can use the following command to control the fan, pifanctl --help
docker run -it ghcr.io/jyje/pifanctl python main.py --help
Then you can use the following command to control the fan:
And you can run the following command to start the fan:
docker run --privileged -it ghcr.io/jyje/pifanctl python main.py start
Currently, --privileged
is required to access and control the GPIO pins.
We will try to find a better solution in the future.
Run the following command to install the pifanctl on Kubernetes with Raspberry Pies and a PWM Fan.
kubectl create namespace pifanctl
kubectl apply -n pifanctl -f https://raw.githubusercontent.com/jyje/pifanctl/main/k8s/manifests/deployments.yaml
You can check the status of the pifanctl with the following command:
kubectl get pods -n pifanctl
You can check the logs of the pifanctl with the following command:
kubectl logs -n pifanctl -l app=pifanctl
git clone https://github.com/jyje/pifanctl ~/.pifanctl
cd ~/.pifanctl/sources
pip install --upgrade -r requirements.raspi.txt
python ~/.pifanctl/sources/main.py --help
If you want to build it yourself, you can do the following:
Important
The package RPi.GPIO
is available on the Raspberry Pi OS or Linux OS tuned by Raspberry Pi Foundation. So you should run following command on Raspberry Pi.
git clone https://github.com/jyje/pifanctl ~/.pifanctl
cd ~/.pifanctl/sources
pip install --upgrade -r requirements.raspi.txt
Then you can debug the source code with the following command:
python ~/.pifanctl/sources/main.py --help
python ~/.pifanctl/sources/main.py --version
python ~/.pifanctl/sources/main.py status
This project uses GitHub Actions with Actions Runner Controller (ARC) for ARM64-based CI/CD pipeline. The builds are executed on self-hosted Raspberry Pi runners, ensuring native ARM64 compatibility.
You can check the environment of CI/CD pipeline in app.jyje.live#stack
-
Main Branch (
build-image-main.yaml
)- Builds and publishes to
ghcr.io/jyje/pifanctl:latest
- Tags with commit SHA
- Runs on production-ready code
- Builds and publishes to
-
Develop Branch (
build-image-develop.yaml
)- Builds and publishes to
ghcr.io/jyje/pifanctl-dev:latest
- Used for development and testing
- Builds and publishes to
-
Issue Branches (
build-image-issue.yaml
)- Builds and publishes to
ghcr.io/jyje/pifanctl-issue:latest
- Builds feature branches with pattern
issue-**
- Tags only with commit SHA for temporary testing
- Builds and publishes to
- Native ARM64 builds using self-hosted runners (
r4spi-microk8s
) - Automatic version tagging using commit SHA
- Skip CI option with
--no-ci
flag in commit messages - GitHub Container Registry (ghcr.io) integration
- Automated testing of built images
- Initialize and check for CI skip flag
- Build Docker image for ARM64 platform
- Push to GitHub Container Registry
- Run automated tests on the built image
Is there any problem? see trouble-shooting.md