A simple Node.js API service for managing Kubernetes deployments and triggering GitHub Actions workflows.
- Restarts Kubernetes deployments via
/devops/restart - Retrieves pod logs via
/devops/logs - Triggers GitHub Actions workflows via
/devops/deploy - Provides Slack integration points for slash commands and event handling
- Supports Docker deployment and Kubernetes manifests for in-cluster use
- Node.js
- Express
@kubernetes/client-node- GitHub Actions API via Axios
- Slack API integration via Axios
- Node.js 20+
- npm
- Docker (optional, but recommended for container testing)
npm installCreate a .env file at the project root with at least:
API_KEY=your_api_key
GITHUB_TOKEN=your_github_token
SLACK_SIGNING_SECRET=your_slack_signing_secret
SLACK_BOT_TOKEN=your_slack_bot_tokenThen start the server:
node src/server.jsThe app listens on port 3000 by default.
curl http://localhost:3000/healthcurl -X POST http://localhost:3000/devops/restart \
-H "x-api-key: your_api_key" \
-H "Content-Type: application/json" \
-d '{"name":"my-deployment","namespace":"staging"}'curl "http://localhost:3000/devops/logs?pod=my-pod&namespace=staging" \
-H "x-api-key: your_api_key"curl -X POST http://localhost:3000/devops/deploy \
-H "x-api-key: your_api_key" \
-H "Content-Type: application/json" \
-d '{"owner":"your-org","repo":"your-repo","workflow":"deploy.yml"}'Build the image:
docker build -t devops-assistant .Run the container:
docker run --rm -p 3000:3000 -e API_KEY=your_api_key devops-assistantFor real cluster access, mount your kubeconfig and add secrets:
docker run --rm -p 3000:3000 \
-e API_KEY=your_api_key \
-e GITHUB_TOKEN=your_github_token \
-e SLACK_SIGNING_SECRET=your_slack_signing_secret \
-e SLACK_BOT_TOKEN=your_slack_bot_token \
-v /path/to/kubeconfig:/root/.kube/config \
devops-assistantManifests are provided in the k8s/ directory:
serviceaccount-role.yaml- service account and RBAC permissionssecret.yaml- secret template for API key and tokensdeployment.yaml- deployment manifestservice.yaml- cluster service
Apply them with:
kubectl apply -f k8s/serviceaccount-role.yaml -f k8s/secret.yaml -f k8s/deployment.yaml -f k8s/service.yamlThe app exposes Slack endpoints at:
POST /slack/commandPOST /slack/events
These endpoints require SLACK_SIGNING_SECRET and SLACK_BOT_TOKEN.
API_KEYis required for/devopsroutes.- Kubernetes actions will work only when the app has cluster access (
KUBECONFIGlocally or in-cluster config). - Slack requires a public URL for event subscription and slash command callback.