Add Forgejo CI/CD worker configurations
- Add worker config map with runner settings - Add multiple worker deployment variants (simple, volume5, fixed, symlinks) - Include full toolchain: Node.js, Go, Hugo, AWS CLI, Python - Configure NFS-backed workspace and cache storage - Set up auto-registration with git.deco.sh 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
747ec85d98
commit
430fb959b8
5 changed files with 814 additions and 0 deletions
40
forgejo-worker-config.yaml
Normal file
40
forgejo-worker-config.yaml
Normal file
|
@ -0,0 +1,40 @@
|
|||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: forgejo-worker-config
|
||||
namespace: forgejo-workers
|
||||
data:
|
||||
config.yaml: |
|
||||
log:
|
||||
level: info
|
||||
|
||||
runner:
|
||||
file: .runner
|
||||
capacity: 2
|
||||
envs:
|
||||
A_TEST_ENV_NAME_1: a_test_env_value_1
|
||||
A_TEST_ENV_NAME_2: a_test_env_value_2
|
||||
env_file: .env
|
||||
timeout: 3h
|
||||
insecure: false
|
||||
fetch_timeout: 5s
|
||||
fetch_interval: 2s
|
||||
labels: []
|
||||
|
||||
cache:
|
||||
enabled: true
|
||||
dir: /data/cache
|
||||
host: ""
|
||||
port: 0
|
||||
|
||||
container:
|
||||
network: ""
|
||||
privileged: true
|
||||
options:
|
||||
workdir_parent: /data/workspace
|
||||
valid_volumes: []
|
||||
docker_host: ""
|
||||
force_pull: false
|
||||
|
||||
host:
|
||||
workdir_parent: /data/workspace
|
177
forgejo-workers-nodejs-simple.yaml
Normal file
177
forgejo-workers-nodejs-simple.yaml
Normal file
|
@ -0,0 +1,177 @@
|
|||
---
|
||||
# Hybrid storage approach: Local for runner data, NFS on Volume5 for builds
|
||||
apiVersion: apps/v1
|
||||
kind: DaemonSet
|
||||
metadata:
|
||||
name: forgejo-worker-full
|
||||
namespace: forgejo-workers
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: forgejo-worker-full
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: forgejo-worker-full
|
||||
spec:
|
||||
nodeSelector:
|
||||
kubernetes.io/arch: arm64
|
||||
hostNetwork: true
|
||||
hostPID: true
|
||||
containers:
|
||||
- name: worker
|
||||
image: node:20-alpine
|
||||
command: ["/bin/sh", "-c"]
|
||||
args:
|
||||
- |
|
||||
echo "🚀 Starting simple Node.js Forgejo worker on $(hostname)"
|
||||
echo "✅ Node.js version: $(node --version)"
|
||||
echo "✅ npm version: $(npm --version)"
|
||||
|
||||
# Install required packages
|
||||
echo "📦 Installing required packages..."
|
||||
apk add --no-cache wget git curl bash python3 py3-pip unzip jq tar gzip make gcc musl-dev go gcompat
|
||||
|
||||
# Install AWS CLI
|
||||
echo "☁️ Installing AWS CLI..."
|
||||
pip3 install awscli --break-system-packages || {
|
||||
echo "pip install failed, trying direct download..."
|
||||
curl "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip" -o "awscliv2.zip"
|
||||
unzip awscliv2.zip
|
||||
./aws/install
|
||||
rm -rf aws awscliv2.zip
|
||||
}
|
||||
|
||||
# Install Hugo Extended with glibc compatibility
|
||||
echo "📚 Installing Hugo Extended..."
|
||||
HUGO_VERSION="0.148.0"
|
||||
wget -O hugo.tar.gz "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-arm64.tar.gz"
|
||||
tar -xzf hugo.tar.gz hugo
|
||||
mv hugo /usr/local/bin/hugo
|
||||
chmod +x /usr/local/bin/hugo
|
||||
rm -f hugo.tar.gz
|
||||
|
||||
# Set up Go environment
|
||||
echo "🐹 Setting up Go environment..."
|
||||
export GOPATH=/go
|
||||
export PATH=$GOPATH/bin:/usr/local/go/bin:$PATH
|
||||
mkdir -p $GOPATH/{bin,src,pkg}
|
||||
|
||||
# Install other common CI tools
|
||||
echo "🔧 Installing additional tools..."
|
||||
if ! command -v yarn >/dev/null 2>&1; then
|
||||
npm install -g yarn || echo "yarn install failed"
|
||||
else
|
||||
echo "✅ yarn already available: $(yarn --version)"
|
||||
fi
|
||||
|
||||
# Download and install Forgejo Runner
|
||||
echo "⬇️ Downloading Forgejo Runner..."
|
||||
if wget -O /usr/local/bin/forgejo-runner https://code.forgejo.org/forgejo/runner/releases/download/v6.3.1/forgejo-runner-6.3.1-linux-arm64; then
|
||||
echo "✅ Downloaded Forgejo runner v6.3.1"
|
||||
else
|
||||
echo "❌ Failed to download runner"
|
||||
exit 1
|
||||
fi
|
||||
chmod +x /usr/local/bin/forgejo-runner
|
||||
|
||||
echo "✅ Git version: $(git --version)"
|
||||
echo "✅ AWS CLI version: $(aws --version || echo 'AWS CLI installation failed')"
|
||||
echo "✅ Go version: $(go version || echo 'Go installation failed')"
|
||||
echo "✅ Hugo version: $(hugo version || echo 'Hugo installation failed')"
|
||||
echo "✅ Python version: $(python3 --version)"
|
||||
echo "✅ Yarn version: $(yarn --version || echo 'Yarn not available')"
|
||||
echo "✅ jq version: $(jq --version || echo 'jq not available')"
|
||||
echo "✅ Forgejo runner version: $(forgejo-runner --version || echo 'Version check failed')"
|
||||
|
||||
# Configure git for HTTPS
|
||||
echo "🔧 Configuring git..."
|
||||
git config --global url."https://git.deco.sh/".insteadOf "git@git.deco.sh:"
|
||||
git config --global url."https://git.deco.sh/".insteadOf "ssh://git@git.deco.sh/"
|
||||
git config --global url."https://".insteadOf "git://"
|
||||
git config --global advice.detachedHead false
|
||||
git config --global safe.directory '*'
|
||||
git config --global user.name "Forgejo Worker"
|
||||
git config --global user.email "worker@$(hostname)"
|
||||
|
||||
# Ensure directories exist with correct permissions
|
||||
mkdir -p /data /workspace /cache
|
||||
|
||||
# Register worker if not already registered
|
||||
cd /data
|
||||
if [ ! -f /data/.runner ]; then
|
||||
echo "📝 Registering new worker: k8s-full-$(hostname)"
|
||||
forgejo-runner register \
|
||||
--no-interactive \
|
||||
--instance "${FORGEJO_INSTANCE_URL}" \
|
||||
--token "${FORGEJO_TOKEN}" \
|
||||
--name "k8s-full-$(hostname)" \
|
||||
--labels "self-hosted,linux,arm64,nodejs,aws-cli,golang,hugo"
|
||||
else
|
||||
echo "✅ Worker already registered"
|
||||
fi
|
||||
|
||||
# Verify registration
|
||||
if [ ! -f /data/.runner ]; then
|
||||
echo "❌ ERROR: Registration failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Start the worker
|
||||
echo "🏃 Starting Forgejo runner daemon..."
|
||||
exec forgejo-runner daemon --config /etc/forgejo-runner/config.yaml
|
||||
env:
|
||||
- name: FORGEJO_INSTANCE_URL
|
||||
value: "https://git.deco.sh"
|
||||
- name: FORGEJO_TOKEN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: forgejo-worker-token
|
||||
key: token
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /etc/forgejo-runner
|
||||
- name: data
|
||||
mountPath: /data
|
||||
- name: workspace
|
||||
mountPath: /workspace
|
||||
- name: cache
|
||||
mountPath: /cache
|
||||
- name: go-workspace
|
||||
mountPath: /go
|
||||
resources:
|
||||
requests:
|
||||
memory: "512Mi"
|
||||
cpu: "250m"
|
||||
limits:
|
||||
memory: "4Gi"
|
||||
cpu: "2000m"
|
||||
securityContext:
|
||||
privileged: true
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: forgejo-worker-config
|
||||
- name: data
|
||||
hostPath:
|
||||
path: /var/lib/forgejo-worker-full
|
||||
type: DirectoryOrCreate
|
||||
- name: workspace
|
||||
nfs:
|
||||
server: 192.168.12.16
|
||||
path: /Volume5/forgejo-builds # Changed to Volume5
|
||||
- name: cache
|
||||
nfs:
|
||||
server: 192.168.12.16
|
||||
path: /Volume5/forgejo-cache # Changed to Volume5
|
||||
- name: go-workspace
|
||||
hostPath:
|
||||
path: /var/lib/go-workspace
|
||||
type: DirectoryOrCreate
|
||||
tolerations:
|
||||
- key: node-role.kubernetes.io/master
|
||||
effect: NoSchedule
|
||||
operator: Exists
|
||||
- key: node-role.kubernetes.io/control-plane
|
||||
effect: NoSchedule
|
||||
operator: Exists
|
195
forgejo-workers-volume5-fixed.yaml
Normal file
195
forgejo-workers-volume5-fixed.yaml
Normal file
|
@ -0,0 +1,195 @@
|
|||
---
|
||||
apiVersion: apps/v1
|
||||
kind: DaemonSet
|
||||
metadata:
|
||||
name: forgejo-worker-full
|
||||
namespace: forgejo-workers
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: forgejo-worker-full
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: forgejo-worker-full
|
||||
spec:
|
||||
nodeSelector:
|
||||
kubernetes.io/arch: arm64
|
||||
hostNetwork: true
|
||||
hostPID: true
|
||||
containers:
|
||||
- name: worker
|
||||
image: node:20-alpine
|
||||
command: ["/bin/sh", "-c"]
|
||||
args:
|
||||
- |
|
||||
echo "🚀 Starting simple Node.js Forgejo worker on $(hostname)"
|
||||
echo "✅ Node.js version: $(node --version)"
|
||||
echo "✅ npm version: $(npm --version)"
|
||||
|
||||
# Install required packages
|
||||
echo "📦 Installing required packages..."
|
||||
apk add --no-cache wget git curl bash python3 py3-pip unzip jq tar gzip make gcc musl-dev go gcompat
|
||||
|
||||
# Install AWS CLI
|
||||
echo "☁️ Installing AWS CLI..."
|
||||
pip3 install awscli --break-system-packages || {
|
||||
echo "pip install failed, trying direct download..."
|
||||
curl "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip" -o "awscliv2.zip"
|
||||
unzip awscliv2.zip
|
||||
./aws/install
|
||||
rm -rf aws awscliv2.zip
|
||||
}
|
||||
|
||||
# Install Hugo Extended with glibc compatibility
|
||||
echo "📚 Installing Hugo Extended..."
|
||||
HUGO_VERSION="0.148.0"
|
||||
wget -O hugo.tar.gz "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-arm64.tar.gz"
|
||||
tar -xzf hugo.tar.gz hugo
|
||||
mv hugo /usr/local/bin/hugo
|
||||
chmod +x /usr/local/bin/hugo
|
||||
rm -f hugo.tar.gz
|
||||
|
||||
# Set up Go environment
|
||||
echo "🐹 Setting up Go environment..."
|
||||
export GOPATH=/go
|
||||
export PATH=$GOPATH/bin:/usr/local/go/bin:$PATH
|
||||
mkdir -p $GOPATH/{bin,src,pkg}
|
||||
|
||||
# Install other common CI tools
|
||||
echo "🔧 Installing additional tools..."
|
||||
if ! command -v yarn >/dev/null 2>&1; then
|
||||
npm install -g yarn || echo "yarn install failed"
|
||||
else
|
||||
echo "✅ yarn already available: $(yarn --version)"
|
||||
fi
|
||||
|
||||
# Download and install Forgejo Runner
|
||||
echo "⬇️ Downloading Forgejo Runner..."
|
||||
if wget -O /usr/local/bin/forgejo-runner https://code.forgejo.org/forgejo/runner/releases/download/v6.3.1/forgejo-runner-6.3.1-linux-arm64; then
|
||||
echo "✅ Downloaded Forgejo runner v6.3.1"
|
||||
else
|
||||
echo "❌ Failed to download runner"
|
||||
exit 1
|
||||
fi
|
||||
chmod +x /usr/local/bin/forgejo-runner
|
||||
|
||||
echo "✅ Git version: $(git --version)"
|
||||
echo "✅ AWS CLI version: $(aws --version || echo 'AWS CLI installation failed')"
|
||||
echo "✅ Go version: $(go version || echo 'Go installation failed')"
|
||||
echo "✅ Hugo version: $(hugo version || echo 'Hugo installation failed')"
|
||||
echo "✅ Python version: $(python3 --version)"
|
||||
echo "✅ Yarn version: $(yarn --version || echo 'Yarn not available')"
|
||||
echo "✅ jq version: $(jq --version || echo 'jq not available')"
|
||||
echo "✅ Forgejo runner version: $(forgejo-runner --version || echo 'Version check failed')"
|
||||
|
||||
# Configure git for HTTPS
|
||||
echo "🔧 Configuring git..."
|
||||
git config --global url."https://git.deco.sh/".insteadOf "git@git.deco.sh:"
|
||||
git config --global url."https://git.deco.sh/".insteadOf "ssh://git@git.deco.sh/"
|
||||
git config --global url."https://".insteadOf "git://"
|
||||
git config --global advice.detachedHead false
|
||||
git config --global safe.directory '*'
|
||||
git config --global user.name "Forgejo Worker"
|
||||
git config --global user.email "worker@$(hostname)"
|
||||
|
||||
# Set up directory structure with NFS mounts
|
||||
echo "📁 Setting up directory structure..."
|
||||
mkdir -p /data
|
||||
|
||||
# Create symlinks to NFS mounts within /data
|
||||
ln -sfn /workspace /data/workspace
|
||||
ln -sfn /cache /data/cache
|
||||
|
||||
# Verify mounts and symlinks
|
||||
echo "📊 Storage configuration:"
|
||||
df -h | grep -E "(Volume5|Filesystem)"
|
||||
echo ""
|
||||
echo "📂 Directory structure:"
|
||||
ls -la /data/
|
||||
ls -la /workspace/
|
||||
ls -la /cache/
|
||||
|
||||
# Test write access
|
||||
echo "✍️ Testing write access..."
|
||||
echo "Test write at $(date)" > /workspace/test-$(hostname).txt
|
||||
echo "Test write at $(date)" > /cache/test-$(hostname).txt
|
||||
|
||||
# Register worker if not already registered
|
||||
cd /data
|
||||
if [ ! -f /data/.runner ]; then
|
||||
echo "📝 Registering new worker: k8s-full-$(hostname)"
|
||||
forgejo-runner register \
|
||||
--no-interactive \
|
||||
--instance "${FORGEJO_INSTANCE_URL}" \
|
||||
--token "${FORGEJO_TOKEN}" \
|
||||
--name "k8s-full-$(hostname)" \
|
||||
--labels "self-hosted,linux,arm64,nodejs,aws-cli,golang,hugo"
|
||||
else
|
||||
echo "✅ Worker already registered"
|
||||
fi
|
||||
|
||||
# Verify registration
|
||||
if [ ! -f /data/.runner ]; then
|
||||
echo "❌ ERROR: Registration failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Start the worker
|
||||
echo "🏃 Starting Forgejo runner daemon..."
|
||||
exec forgejo-runner daemon --config /etc/forgejo-runner/config.yaml
|
||||
env:
|
||||
- name: FORGEJO_INSTANCE_URL
|
||||
value: "https://git.deco.sh"
|
||||
- name: FORGEJO_TOKEN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: forgejo-worker-token
|
||||
key: token
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /etc/forgejo-runner
|
||||
- name: data
|
||||
mountPath: /data
|
||||
- name: workspace
|
||||
mountPath: /workspace
|
||||
- name: cache
|
||||
mountPath: /cache
|
||||
- name: go-workspace
|
||||
mountPath: /go
|
||||
resources:
|
||||
requests:
|
||||
memory: "512Mi"
|
||||
cpu: "250m"
|
||||
limits:
|
||||
memory: "4Gi"
|
||||
cpu: "2000m"
|
||||
securityContext:
|
||||
privileged: true
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: forgejo-worker-config
|
||||
- name: data
|
||||
hostPath:
|
||||
path: /var/lib/forgejo-worker-full
|
||||
type: DirectoryOrCreate
|
||||
- name: workspace
|
||||
nfs:
|
||||
server: 192.168.12.16
|
||||
path: /Volume5/forgejo-builds
|
||||
- name: cache
|
||||
nfs:
|
||||
server: 192.168.12.16
|
||||
path: /Volume5/forgejo-cache
|
||||
- name: go-workspace
|
||||
hostPath:
|
||||
path: /var/lib/go-workspace
|
||||
type: DirectoryOrCreate
|
||||
tolerations:
|
||||
- key: node-role.kubernetes.io/master
|
||||
effect: NoSchedule
|
||||
operator: Exists
|
||||
- key: node-role.kubernetes.io/control-plane
|
||||
effect: NoSchedule
|
||||
operator: Exists
|
207
forgejo-workers-volume5-symlinks.yaml
Normal file
207
forgejo-workers-volume5-symlinks.yaml
Normal file
|
@ -0,0 +1,207 @@
|
|||
---
|
||||
apiVersion: apps/v1
|
||||
kind: DaemonSet
|
||||
metadata:
|
||||
name: forgejo-worker-full
|
||||
namespace: forgejo-workers
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: forgejo-worker-full
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: forgejo-worker-full
|
||||
spec:
|
||||
nodeSelector:
|
||||
kubernetes.io/arch: arm64
|
||||
hostNetwork: true
|
||||
hostPID: true
|
||||
containers:
|
||||
- name: worker
|
||||
image: node:20-alpine
|
||||
command: ["/bin/sh", "-c"]
|
||||
args:
|
||||
- |
|
||||
echo "🚀 Starting simple Node.js Forgejo worker on $(hostname)"
|
||||
echo "✅ Node.js version: $(node --version)"
|
||||
echo "✅ npm version: $(npm --version)"
|
||||
|
||||
# Install required packages
|
||||
echo "📦 Installing required packages..."
|
||||
apk add --no-cache wget git curl bash python3 py3-pip unzip jq tar gzip make gcc musl-dev go gcompat
|
||||
|
||||
# Install AWS CLI
|
||||
echo "☁️ Installing AWS CLI..."
|
||||
pip3 install awscli --break-system-packages || {
|
||||
echo "pip install failed, trying direct download..."
|
||||
curl "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip" -o "awscliv2.zip"
|
||||
unzip awscliv2.zip
|
||||
./aws/install
|
||||
rm -rf aws awscliv2.zip
|
||||
}
|
||||
|
||||
# Install Hugo Extended with glibc compatibility
|
||||
echo "📚 Installing Hugo Extended..."
|
||||
HUGO_VERSION="0.148.0"
|
||||
wget -O hugo.tar.gz "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-arm64.tar.gz"
|
||||
tar -xzf hugo.tar.gz hugo
|
||||
mv hugo /usr/local/bin/hugo
|
||||
chmod +x /usr/local/bin/hugo
|
||||
rm -f hugo.tar.gz
|
||||
|
||||
# Set up Go environment
|
||||
echo "🐹 Setting up Go environment..."
|
||||
export GOPATH=/go
|
||||
export PATH=$GOPATH/bin:/usr/local/go/bin:$PATH
|
||||
mkdir -p $GOPATH/{bin,src,pkg}
|
||||
|
||||
# Install other common CI tools
|
||||
echo "🔧 Installing additional tools..."
|
||||
if ! command -v yarn >/dev/null 2>&1; then
|
||||
npm install -g yarn || echo "yarn install failed"
|
||||
else
|
||||
echo "✅ yarn already available: $(yarn --version)"
|
||||
fi
|
||||
|
||||
# Download and install Forgejo Runner
|
||||
echo "⬇️ Downloading Forgejo Runner..."
|
||||
if wget -O /usr/local/bin/forgejo-runner https://code.forgejo.org/forgejo/runner/releases/download/v6.3.1/forgejo-runner-6.3.1-linux-arm64; then
|
||||
echo "✅ Downloaded Forgejo runner v6.3.1"
|
||||
else
|
||||
echo "❌ Failed to download runner"
|
||||
exit 1
|
||||
fi
|
||||
chmod +x /usr/local/bin/forgejo-runner
|
||||
|
||||
echo "✅ Git version: $(git --version)"
|
||||
echo "✅ AWS CLI version: $(aws --version || echo 'AWS CLI installation failed')"
|
||||
echo "✅ Go version: $(go version || echo 'Go installation failed')"
|
||||
echo "✅ Hugo version: $(hugo version || echo 'Hugo installation failed')"
|
||||
echo "✅ Python version: $(python3 --version)"
|
||||
echo "✅ Yarn version: $(yarn --version || echo 'Yarn not available')"
|
||||
echo "✅ jq version: $(jq --version || echo 'jq not available')"
|
||||
echo "✅ Forgejo runner version: $(forgejo-runner --version || echo 'Version check failed')"
|
||||
|
||||
# Configure git for HTTPS
|
||||
echo "🔧 Configuring git..."
|
||||
git config --global url."https://git.deco.sh/".insteadOf "git@git.deco.sh:"
|
||||
git config --global url."https://git.deco.sh/".insteadOf "ssh://git@git.deco.sh/"
|
||||
git config --global url."https://".insteadOf "git://"
|
||||
git config --global advice.detachedHead false
|
||||
git config --global safe.directory '*'
|
||||
git config --global user.name "Forgejo Worker"
|
||||
git config --global user.email "worker@$(hostname)"
|
||||
|
||||
# CRITICAL: Set up directory structure with NFS mounts
|
||||
echo "📁 Setting up directory structure..."
|
||||
mkdir -p /data
|
||||
|
||||
# Remove existing directories if they exist
|
||||
if [ -d "/data/workspace" ] && [ ! -L "/data/workspace" ]; then
|
||||
echo "🗑️ Removing existing workspace directory..."
|
||||
rm -rf /data/workspace
|
||||
fi
|
||||
if [ -d "/data/cache" ] && [ ! -L "/data/cache" ]; then
|
||||
echo "🗑️ Removing existing cache directory..."
|
||||
rm -rf /data/cache
|
||||
fi
|
||||
|
||||
# Create symlinks to NFS mounts
|
||||
ln -sfn /workspace /data/workspace
|
||||
ln -sfn /cache /data/cache
|
||||
|
||||
# Verify mounts and symlinks
|
||||
echo "📊 Storage configuration:"
|
||||
df -h | grep -E "(Volume5|Filesystem)"
|
||||
echo ""
|
||||
echo "📂 Directory structure:"
|
||||
ls -la /data/
|
||||
echo ""
|
||||
echo "🔗 Verifying symlinks:"
|
||||
ls -la /data/workspace
|
||||
ls -la /data/cache
|
||||
|
||||
# Test write access
|
||||
echo "✍️ Testing write access..."
|
||||
echo "Test write at $(date)" > /data/workspace/test-$(hostname).txt
|
||||
echo "Test write at $(date)" > /data/cache/test-$(hostname).txt
|
||||
|
||||
# Register worker if not already registered
|
||||
cd /data
|
||||
if [ ! -f /data/.runner ]; then
|
||||
echo "📝 Registering new worker: k8s-full-$(hostname)"
|
||||
forgejo-runner register \
|
||||
--no-interactive \
|
||||
--instance "${FORGEJO_INSTANCE_URL}" \
|
||||
--token "${FORGEJO_TOKEN}" \
|
||||
--name "k8s-full-$(hostname)" \
|
||||
--labels "self-hosted,linux,arm64,nodejs,aws-cli,golang,hugo"
|
||||
else
|
||||
echo "✅ Worker already registered"
|
||||
fi
|
||||
|
||||
# Verify registration
|
||||
if [ ! -f /data/.runner ]; then
|
||||
echo "❌ ERROR: Registration failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Start the worker
|
||||
echo "🏃 Starting Forgejo runner daemon..."
|
||||
exec forgejo-runner daemon --config /etc/forgejo-runner/config.yaml
|
||||
env:
|
||||
- name: FORGEJO_INSTANCE_URL
|
||||
value: "https://git.deco.sh"
|
||||
- name: FORGEJO_TOKEN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: forgejo-worker-token
|
||||
key: token
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /etc/forgejo-runner
|
||||
- name: data
|
||||
mountPath: /data
|
||||
- name: workspace
|
||||
mountPath: /workspace
|
||||
- name: cache
|
||||
mountPath: /cache
|
||||
- name: go-workspace
|
||||
mountPath: /go
|
||||
resources:
|
||||
requests:
|
||||
memory: "512Mi"
|
||||
cpu: "250m"
|
||||
limits:
|
||||
memory: "4Gi"
|
||||
cpu: "2000m"
|
||||
securityContext:
|
||||
privileged: true
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: forgejo-worker-config
|
||||
- name: data
|
||||
hostPath:
|
||||
path: /var/lib/forgejo-worker-full
|
||||
type: DirectoryOrCreate
|
||||
- name: workspace
|
||||
nfs:
|
||||
server: 192.168.12.16
|
||||
path: /Volume5/forgejo-builds
|
||||
- name: cache
|
||||
nfs:
|
||||
server: 192.168.12.16
|
||||
path: /Volume5/forgejo-cache
|
||||
- name: go-workspace
|
||||
hostPath:
|
||||
path: /var/lib/go-workspace
|
||||
type: DirectoryOrCreate
|
||||
tolerations:
|
||||
- key: node-role.kubernetes.io/master
|
||||
effect: NoSchedule
|
||||
operator: Exists
|
||||
- key: node-role.kubernetes.io/control-plane
|
||||
effect: NoSchedule
|
||||
operator: Exists
|
195
forgejo-workers-volume5.yaml
Normal file
195
forgejo-workers-volume5.yaml
Normal file
|
@ -0,0 +1,195 @@
|
|||
---
|
||||
apiVersion: apps/v1
|
||||
kind: DaemonSet
|
||||
metadata:
|
||||
name: forgejo-worker-full
|
||||
namespace: forgejo-workers
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: forgejo-worker-full
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: forgejo-worker-full
|
||||
spec:
|
||||
nodeSelector:
|
||||
kubernetes.io/arch: arm64
|
||||
hostNetwork: true
|
||||
hostPID: true
|
||||
containers:
|
||||
- name: worker
|
||||
image: node:20-alpine
|
||||
command: ["/bin/sh", "-c"]
|
||||
args:
|
||||
- |
|
||||
echo "🚀 Starting simple Node.js Forgejo worker on $(hostname)"
|
||||
echo "✅ Node.js version: $(node --version)"
|
||||
echo "✅ npm version: $(npm --version)"
|
||||
|
||||
# Install required packages
|
||||
echo "📦 Installing required packages..."
|
||||
apk add --no-cache wget git curl bash python3 py3-pip unzip jq tar gzip make gcc musl-dev go gcompat
|
||||
|
||||
# Install AWS CLI
|
||||
echo "☁️ Installing AWS CLI..."
|
||||
pip3 install awscli --break-system-packages || {
|
||||
echo "pip install failed, trying direct download..."
|
||||
curl "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip" -o "awscliv2.zip"
|
||||
unzip awscliv2.zip
|
||||
./aws/install
|
||||
rm -rf aws awscliv2.zip
|
||||
}
|
||||
|
||||
# Install Hugo Extended with glibc compatibility
|
||||
echo "📚 Installing Hugo Extended..."
|
||||
HUGO_VERSION="0.148.0"
|
||||
wget -O hugo.tar.gz "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-arm64.tar.gz"
|
||||
tar -xzf hugo.tar.gz hugo
|
||||
mv hugo /usr/local/bin/hugo
|
||||
chmod +x /usr/local/bin/hugo
|
||||
rm -f hugo.tar.gz
|
||||
|
||||
# Set up Go environment
|
||||
echo "🐹 Setting up Go environment..."
|
||||
export GOPATH=/go
|
||||
export PATH=$GOPATH/bin:/usr/local/go/bin:$PATH
|
||||
mkdir -p $GOPATH/{bin,src,pkg}
|
||||
|
||||
# Install other common CI tools
|
||||
echo "🔧 Installing additional tools..."
|
||||
if ! command -v yarn >/dev/null 2>&1; then
|
||||
npm install -g yarn || echo "yarn install failed"
|
||||
else
|
||||
echo "✅ yarn already available: $(yarn --version)"
|
||||
fi
|
||||
|
||||
# Download and install Forgejo Runner
|
||||
echo "⬇️ Downloading Forgejo Runner..."
|
||||
if wget -O /usr/local/bin/forgejo-runner https://code.forgejo.org/forgejo/runner/releases/download/v6.3.1/forgejo-runner-6.3.1-linux-arm64; then
|
||||
echo "✅ Downloaded Forgejo runner v6.3.1"
|
||||
else
|
||||
echo "❌ Failed to download runner"
|
||||
exit 1
|
||||
fi
|
||||
chmod +x /usr/local/bin/forgejo-runner
|
||||
|
||||
echo "✅ Git version: $(git --version)"
|
||||
echo "✅ AWS CLI version: $(aws --version || echo 'AWS CLI installation failed')"
|
||||
echo "✅ Go version: $(go version || echo 'Go installation failed')"
|
||||
echo "✅ Hugo version: $(hugo version || echo 'Hugo installation failed')"
|
||||
echo "✅ Python version: $(python3 --version)"
|
||||
echo "✅ Yarn version: $(yarn --version || echo 'Yarn not available')"
|
||||
echo "✅ jq version: $(jq --version || echo 'jq not available')"
|
||||
echo "✅ Forgejo runner version: $(forgejo-runner --version || echo 'Version check failed')"
|
||||
|
||||
# Configure git for HTTPS
|
||||
echo "🔧 Configuring git..."
|
||||
git config --global url."https://git.deco.sh/".insteadOf "git@git.deco.sh:"
|
||||
git config --global url."https://git.deco.sh/".insteadOf "ssh://git@git.deco.sh/"
|
||||
git config --global url."https://".insteadOf "git://"
|
||||
git config --global advice.detachedHead false
|
||||
git config --global safe.directory '*'
|
||||
git config --global user.name "Forgejo Worker"
|
||||
git config --global user.email "worker@$(hostname)"
|
||||
|
||||
# Set up directory structure with NFS mounts
|
||||
echo "📁 Setting up directory structure..."
|
||||
mkdir -p /data
|
||||
|
||||
# Create symlinks to NFS mounts within /data
|
||||
ln -sfn /workspace /data/workspace
|
||||
ln -sfn /cache /data/cache
|
||||
|
||||
# Verify mounts and symlinks
|
||||
echo "📊 Storage configuration:"
|
||||
df -h | grep -E "(Volume5|Filesystem)"
|
||||
echo ""
|
||||
echo "📂 Directory structure:"
|
||||
ls -la /data/
|
||||
ls -la /workspace/
|
||||
ls -la /cache/
|
||||
|
||||
# Test write access
|
||||
echo "✍️ Testing write access..."
|
||||
echo "Test write at $(date)" > /workspace/test-$(hostname).txt
|
||||
echo "Test write at $(date)" > /cache/test-$(hostname).txt
|
||||
|
||||
# Register worker if not already registered
|
||||
cd /data
|
||||
if [ ! -f /data/.runner ]; then
|
||||
echo "📝 Registering new worker: k8s-full-$(hostname)"
|
||||
forgejo-runner register \
|
||||
--no-interactive \
|
||||
--instance "${FORGEJO_INSTANCE_URL}" \
|
||||
--token "${FORGEJO_TOKEN}" \
|
||||
--name "k8s-full-$(hostname)" \
|
||||
--labels "self-hosted,linux,arm64,nodejs,aws-cli,golang,hugo"
|
||||
else
|
||||
echo "✅ Worker already registered"
|
||||
fi
|
||||
|
||||
# Verify registration
|
||||
if [ ! -f /data/.runner ]; then
|
||||
echo "❌ ERROR: Registration failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Start the worker
|
||||
echo "🏃 Starting Forgejo runner daemon..."
|
||||
exec forgejo-runner daemon --config /etc/forgejo-runner/config.yaml
|
||||
env:
|
||||
- name: FORGEJO_INSTANCE_URL
|
||||
value: "https://git.deco.sh"
|
||||
- name: FORGEJO_TOKEN
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: forgejo-worker-token
|
||||
key: token
|
||||
volumeMounts:
|
||||
- name: config
|
||||
mountPath: /etc/forgejo-runner
|
||||
- name: data
|
||||
mountPath: /data
|
||||
- name: workspace
|
||||
mountPath: /workspace
|
||||
- name: cache
|
||||
mountPath: /cache
|
||||
- name: go-workspace
|
||||
mountPath: /go
|
||||
resources:
|
||||
requests:
|
||||
memory: "512Mi"
|
||||
cpu: "250m"
|
||||
limits:
|
||||
memory: "4Gi"
|
||||
cpu: "2000m"
|
||||
securityContext:
|
||||
privileged: true
|
||||
volumes:
|
||||
- name: config
|
||||
configMap:
|
||||
name: forgejo-worker-config
|
||||
- name: data
|
||||
hostPath:
|
||||
path: /var/lib/forgejo-worker-full
|
||||
type: DirectoryOrCreate
|
||||
- name: workspace
|
||||
nfs:
|
||||
server: 192.168.12.16
|
||||
path: /Volume5/forgejo-builds
|
||||
- name: cache
|
||||
nfs:
|
||||
server: 192.168.12.16
|
||||
path: /Volume5/forgejo-cache
|
||||
- name: go-workspace
|
||||
hostPath:
|
||||
path: /var/lib/go-workspace
|
||||
type: DirectoryOrCreate
|
||||
tolerations:
|
||||
- key: node-role.kubernetes.io/master
|
||||
effect: NoSchedule
|
||||
operator: Exists
|
||||
- key: node-role.kubernetes.io/control-plane
|
||||
effect: NoSchedule
|
||||
operator: Exists
|
Loading…
Add table
Add a link
Reference in a new issue