This repository contains Kubernetes manifests to run the Git Pull add-on functionality as a pod in your Kubernetes cluster. This allows you to automatically sync your Home Assistant configuration from a Git repository, just like the official Home Assistant add-on.
- ✅ Pulls configuration from a Git repository
- ✅ Supports both
pullandresetgit commands - ✅ Optional automatic Home Assistant restart on config changes
- ✅ Configurable file ignore list for restart triggers
- ✅ Runs as a CronJob (periodic) or Deployment (continuous)
- ✅ Supports SSH and HTTPS authentication
- ✅ Uses the same PVC as your Home Assistant deployment
- Kubernetes cluster with Home Assistant already deployed
- Home Assistant running in the
homeassistantnamespace - PVC named
homeassistant-config(or update the manifest) kubectlconfigured to access your cluster
Edit k8s-git-pull.yaml and set your repository URL:
- name: REPOSITORY
value: "https://github.com/yourusername/your-config-repo.git" # CHANGE THISOr for SSH:
- name: REPOSITORY
value: "git@github.com:yourusername/your-config-repo.git"-
Generate an SSH key (if you don't have one):
ssh-keygen -t ed25519 -f ~/.ssh/git-pull-key -N ""
-
Add the public key to your Git provider (GitHub, GitLab, etc.)
-
Create a Kubernetes secret:
kubectl create secret generic git-pull-ssh-key \ --from-file=id_ed25519=~/.ssh/git-pull-key \ --from-file=known_hosts=<(ssh-keyscan github.com) \ -n homeassistant
-
Update
k8s-git-pull.yamlto mount the secret (see SSH configuration section below)
kubectl create secret generic git-pull-credentials \
--from-literal=username=your-username \
--from-literal=password=your-password \
-n homeassistantThen update the repository URL to include credentials:
- name: REPOSITORY
value: "https://username:password@github.com/user/repo.git"Note: For GitHub, personal access tokens are recommended over passwords.
Edit the environment variables in k8s-git-pull.yaml:
- name: GIT_BRANCH
value: "master" # or "main", or your branch name
- name: GIT_COMMAND
value: "pull" # or "reset" for hard reset (WARNING: overwrites local changes)
- name: AUTO_RESTART
value: "true" # Set to "true" to auto-restart HA on changes
- name: RESTART_IGNORE
value: "ui-lovelace.yaml,.gitignore" # Files that won't trigger restartEdit the schedule in k8s-git-pull.yaml:
schedule: "*/5 * * * *" # Every 5 minutes
# schedule: "*/30 * * * *" # Every 30 minutes
# schedule: "0 * * * *" # Every hour# Apply service account and RBAC
kubectl apply -f service-account.yaml
# Apply the git pull CronJob
kubectl apply -f k8s-git-pull.yamlCheck the logs:
# View recent jobs
kubectl get jobs -n homeassistant
# View logs of the latest job
kubectl logs -n homeassistant -l app=git-pull --tail=50
# Or follow logs
kubectl logs -n homeassistant -f job/git-pull-<timestamp>To use SSH authentication, update k8s-git-pull.yaml to mount the SSH secret:
Add to the container's volumeMounts:
- name: ssh-key
mountPath: /root/.ssh
readOnly: trueAdd to the pod's volumes:
- name: ssh-key
secret:
secretName: git-pull-ssh-key
defaultMode: 0600And add to the container's command to set up SSH:
command:
- /bin/sh
- -c
- |
# Set up SSH
mkdir -p /root/.ssh
cp /root/.ssh/id_ed25519 /root/.ssh/id_ed25519 2>/dev/null || true
chmod 600 /root/.ssh/id_ed25519
chmod 644 /root/.ssh/known_hosts
# Install kubectl and run script
apk add --no-cache curl
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl && mv kubectl /usr/local/bin/
cp /scripts/git-pull.sh /tmp/git-pull.sh
chmod +x /tmp/git-pull.sh
/tmp/git-pull.sh- Runs on a schedule (e.g., every 5 minutes)
- More resource-efficient
- Recommended for most use cases
- Runs continuously, checking at intervals
- Uncomment the Deployment section in
k8s-git-pull.yaml - Comment out the CronJob section
- Useful if you want immediate updates
| Environment Variable | Default | Description |
|---|---|---|
REPOSITORY |
required | Git repository URL |
GIT_BRANCH |
master |
Branch to pull from |
GIT_COMMAND |
pull |
pull or reset (reset overwrites local changes) |
GIT_REMOTE |
origin |
Remote name |
GIT_PRUNE |
false |
Prune deleted remote branches |
CONFIG_DIR |
/config |
Path to HA config directory |
AUTO_RESTART |
false |
Auto-restart HA on config changes |
RESTART_IGNORE |
- | Comma-separated list of files to ignore |
REPEAT_ACTIVE |
false |
Enable repeat mode (Deployment only) |
REPEAT_INTERVAL |
300 |
Interval in seconds (Deployment only) |
- Verify the PVC name matches:
kubectl get pvc -n homeassistant - Check the pod has the correct volume mount
- For SSH: Verify the secret is created and mounted correctly
- For HTTPS: Check credentials in the repository URL or secret
- View pod logs:
kubectl logs -n homeassistant -l app=git-pull
- Verify
AUTO_RESTART=true - Check the service account has permissions:
kubectl get rolebinding -n homeassistant - Check logs for restart attempts
- WARNING: Make sure your Git repository has your config files before first run
- The add-on will clone the repository, potentially overwriting local config
- Always backup your config before first run
- SSH keys are stored as Kubernetes secrets (encrypted at rest)
- The service account has minimal permissions (only restart HA deployment)
- Consider using read-only Git access tokens/keys
- Review RBAC permissions in
service-account.yaml
- Runs as a Kubernetes pod instead of a Home Assistant add-on
- Uses
kubectl rollout restartinstead of Home Assistant API restart - Config validation is skipped (can be enhanced to use HA API)
- No web UI - configure via YAML manifests
This is based on the Home Assistant Git Pull add-on functionality. Use at your own risk.
For issues with this Kubernetes implementation, check:
- Pod logs:
kubectl logs -n homeassistant -l app=git-pull - Job status:
kubectl get jobs -n homeassistant - CronJob status:
kubectl get cronjob -n homeassistant
For Home Assistant Git Pull add-on issues, see: