Add: Kubernetes guide to README

This commit is contained in:
k.eaven committed 2026-10-21 07:05:21 +00:00
1 parent 4bd84e2c7d
commit 9d092514d9
1 file changed
+187
+187
View File
@@ -10,6 +10,7 @@ A feature-rich Discord bot for monitoring and managing Pterodactyl game servers
- [Discord Bot Setup](#discord-bot-setup) - [Discord Bot Setup](#discord-bot-setup)
- [Traditional Installation](#traditional-installation) - [Traditional Installation](#traditional-installation)
- [Docker Installation](#docker-installation) - [Docker Installation](#docker-installation)
- [Kubernetes Installation](#kubernetes-installation)
- [Configuration](#configuration) - [Configuration](#configuration)
- [Environment Variables](#environment-variables) - [Environment Variables](#environment-variables)
- [Configuration File](#configuration-file) - [Configuration File](#configuration-file)
@@ -244,6 +245,192 @@ Before installing the bot software, you need to create a Discord application and
docker-compose up -d docker-compose up -d
``` ```
### Kubernetes Installation
1. Clone the repository:
```bash
git clone https://git.serendipity.systems/k.eaven/pterodactyl-discord-bot.git
cd pterodactyl-discord-bot
```
2. Build and push the Docker image to your container registry:
```bash
docker build -t your-registry/pterodisbot:latest .
docker push your-registry/pterodisbot:latest
```
3. Create a Kubernetes namespace (optional but recommended):
```bash
kubectl create namespace pterodisbot
```
4. Create a Kubernetes Secret with your configuration:
```bash
kubectl create secret generic pterodisbot-config \
--from-literal=DISCORD_TOKEN='your-discord-bot-token' \
--from-literal=ALLOWED_GUILD_ID='your-discord-guild-id' \
--from-literal=PANEL_URL='https://your.pterodactyl.panel' \
--from-literal=CLIENT_API_KEY='ptlc_your-client-api-key' \
--from-literal=APPLICATION_API_KEY='ptla_your-application-api-key' \
-n pterodisbot
```
5. Create a PersistentVolumeClaim for logs and embed data:
```yaml
# pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pterodisbot-data
namespace: pterodisbot
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
```
```bash
kubectl apply -f pvc.yaml
```
6. Create the Deployment:
```yaml
# deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: pterodisbot
namespace: pterodisbot
labels:
app: pterodisbot
spec:
replicas: 1
selector:
matchLabels:
app: pterodisbot
template:
metadata:
labels:
app: pterodisbot
spec:
containers:
- name: pterodisbot
image: your-registry/pterodisbot:latest
imagePullPolicy: Always
envFrom:
- secretRef:
name: pterodisbot-config
volumeMounts:
- name: pterodisbot-data
mountPath: /app/logs
subPath: logs
- name: pterodisbot-data
mountPath: /app/embed
subPath: embed
resources:
requests:
memory: "256Mi"
cpu: "100m"
limits:
memory: "512Mi"
cpu: "500m"
livenessProbe:
exec:
command: ["python", "-c", "import sys; sys.exit(0)"]
initialDelaySeconds: 30
periodSeconds: 30
readinessProbe:
exec:
command: ["python", "-c", "import sys; sys.exit(0)"]
initialDelaySeconds: 10
periodSeconds: 10
volumes:
- name: pterodisbot-data
persistentVolumeClaim:
claimName: pterodisbot-data
```
```bash
kubectl apply -f deployment.yaml
```
7. (Optional) Create a Service if you need to expose metrics or health checks:
```yaml
# service.yaml
apiVersion: v1
kind: Service
metadata:
name: pterodisbot
namespace: pterodisbot
labels:
app: pterodisbot
spec:
selector:
app: pterodisbot
ports:
- name: http
port: 8080
targetPort: 8080
type: ClusterIP
```
```bash
kubectl apply -f service.yaml
```
8. (Optional) Create a HorizontalPodAutoscaler for automatic scaling:
```yaml
# hpa.yaml
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: pterodisbot
namespace: pterodisbot
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: pterodisbot
minReplicas: 1
maxReplicas: 3
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70
```
```bash
kubectl apply -f hpa.yaml
```
9. Verify the deployment:
```bash
kubectl get pods -n pterodisbot
kubectl logs -n pterodisbot -l app=pterodisbot -f
```
10. For production, consider using a Helm chart or Kustomize for better configuration management. Create a `kustomization.yaml`:
```yaml
# kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: pterodisbot
resources:
- pvc.yaml
- deployment.yaml
- service.yaml
- hpa.yaml
images:
- name: pterodisbot
newTag: latest
commonLabels:
app: pterodisbot
```
```bash
kubectl apply -k .
```
## Configuration ## Configuration
### Environment Variables ### Environment Variables