node-affinity-guard
Manages node labels for node affinity rules to maintain the desired state within the cluster.
373
node-affinity-guard is a Kubernetes utility designed to ensure that a specific StatefulSet or Deployment is running on the same node as a given floating IP (VIP).
It manages node labels for node affinity rules to maintain the desired state within the cluster.
Clone the repository:
git clone https://github.com/conclusionlogic/node-affinity-guard.git
cd node-affinity-guard
Build the binary:
go build -o node-affinity-guard main.go
or with Docker:
docker build .
Set up the required environment variables:
export HOSTNAME=<your-node-hostname>
export CHECK_INTERVAL=<interval-duration>
export IP_ADDRESS=<floating-ip-address>
export NODE_LABEL_KEY=<node-label-key>
export NODE_LABEL_VALUE_ACTIVE=<node-label-active-value>
export NODE_LABEL_VALUE_INACTIVE=<node-label-inactive-value>
export LOG_LEVEL=<log-level> # Options: debug, info, warn, error
Run the node-affinity-guard binary:
./node-affinity-guard
The program will start monitoring the specified VIP and managing the node labels to ensure that the StatefulSet or Deployment is running on the same node as the VIP.
HOSTNAME: The hostname of the node to monitor.CHECK_INTERVAL: The interval at which to check the presence of the VIP (e.g., "30s", "5m").IP_ADDRESS: The floating IP address to monitor.NODE_LABEL_KEY: The key of the node label to manage.NODE_LABEL_VALUE_ACTIVE: The value of the node label when the VIP is present on the node.NODE_LABEL_VALUE_INACTIVE: The value of the node label when the VIP is not present on the node.LOG_LEVEL: The level of logging detail (options: debug, info, warn, error).This repository contains the Helm chart for deploying the node-affinity-guard. Follow the steps below to add the Helm repository and deploy the chart.
Add the Helm repository:
helm repo add node-affinity-guard https://conclusionlogic.github.io/node-affinity-guard/
Update the Helm repository to ensure you have the latest version of the chart:
helm repo update
Install the node-affinity-guard chart with a release name of your choice (e.g., my-release):
helm install my-release node-affinity-guard/node-affinity-guard
To customize the deployment, you can pass custom values via the --set flag or provide a values.yaml file. For example:
helm install my-release node-affinity-guard/node-affinity-guard --set hostname=node-1,checkInterval=1m,ipAddress=192.168.1.100,nodeLabelKey=vip-active,nodeLabelValueActive=true,nodeLabelValueInactive=false,logLevel=info
To upgrade the chart to a new version:
helm upgrade my-release node-affinity-guard/node-affinity-guard
To uninstall the deployed release:
helm uninstall my-release
The following table lists the configurable parameters of the node-affinity-guard chart and their default values.
| Parameter | Description | Default |
|---|---|---|
hostname | The hostname of the node to monitor | "" |
checkInterval | The interval at which to check the VIP | "1m" |
ipAddress | The floating IP address to monitor | "" |
nodeLabelKey | The key of the node label to manage | "vip-active" |
nodeLabelValueActive | The value of the node label when VIP is present | "true" |
nodeLabelValueInactive | The value of the node label when VIP is not present | "false" |
logLevel | The level of logging detail | "info" |
To deploy the node-affinity-guard with specific values:
helm install my-release node-affinity-guard/node-affinity-guard --set hostname=node-1,checkInterval=1m,ipAddress=192.168.1.100,nodeLabelKey=vip-active,nodeLabelValueActive=true,nodeLabelValueInactive=false,logLevel=info
For more details, refer to the Helm documentation.
Contributions are welcome! Please submit a pull request or open an issue to discuss any changes.
This project is licensed under the MIT License. See the LICENSE file for details.
Content type
Image
Digest
sha256:44111d6a8…
Size
19.9 MB
Last updated
about 2 years ago
docker pull conclusionlogic/node-affinity-guard:v0.0.1