No description
Find a file
2025-10-16 14:34:10 -04:00
action.yaml feat: initial commit 2025-10-16 14:34:10 -04:00
kind-config.yaml feat: initial commit 2025-10-16 14:34:10 -04:00
README.md feat: initial commit 2025-10-16 14:34:10 -04:00

Set up Kubernetes Action

A composite Forgejo Action that sets up a Kubernetes cluster using Kind (Kubernetes in Docker) with Helm support and creates a namespace with registry secret for CleverThis applications.

Features

  • 🚀 Sets up a Kind cluster with customizable configuration
  • 🎯 Installs and configures Helm
  • 🔐 Creates CleverThis namespace and Docker registry secret
  • ⚙️ Configurable cluster name and Kind configuration
  • 📦 Includes default Kind configuration with ingress support

Usage

Basic Usage

- name: Set up Kubernetes
  uses: https://git.cleverthis.com/actions/kubernetes@master
  with:
    registry-url: ${{ secrets.REGISTRY_URL }}
    registry-user: ${{ secrets.REGISTRY_USER }}
    registry-password: ${{ secrets.REGISTRY_PASSWORD }}

Advanced Usage

- name: Set up Kubernetes
  uses: https://git.cleverthis.com/actions/kubernetes@master
  with:
    cluster-name: my-cluster
    kind-config-path: .github/configs/custom-kind.yaml
    registry-url: ${{ secrets.REGISTRY_URL }}
    registry-user: ${{ secrets.REGISTRY_USER }}
    registry-password: ${{ secrets.REGISTRY_PASSWORD }}

Inputs

Input Description Required Default
cluster-name Name of the Kubernetes cluster No default
kind-config-path Path to Kind configuration file No kind-config.yaml
registry-url Docker registry URL Yes -
registry-user Docker registry username Yes -
registry-password Docker registry password Yes -

What This Action Does

  1. Sets up Kind: Creates a Kubernetes cluster using the specified configuration
  2. Installs Helm: Sets up Helm package manager for Kubernetes
  3. Exports kubeconfig: Makes the cluster accessible via kubectl
  4. Creates namespace: Creates the cleverthis namespace
  5. Creates registry secret: Sets up Docker registry credentials in the namespace

Default Kind Configuration

The action includes a default kind-config.yaml that:

  • Creates a single control-plane node
  • Enables ingress by exposing ports 80 and 443
  • Uses custom network CIDRs to avoid conflicts with AWS:
    • Pod subnet: 10.242.0.0/16
    • Service subnet: 10.246.0.0/16

Custom Kind Configuration

You can provide your own Kind configuration by specifying the kind-config-path input:

# custom-kind.yaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
  - role: control-plane
  - role: worker
  - role: worker

Registry Secret

The action creates a Docker registry secret named cleverthis-registry in the cleverthis namespace with the provided credentials. This secret can be used in your Kubernetes deployments:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app
  namespace: cleverthis
spec:
  template:
    spec:
      imagePullSecrets:
        - name: cleverthis-registry
      containers:
        - name: my-app
          image: your-registry.com/my-app:latest

Example Workflow

name: Deploy to Kubernetes
on:
  push:
    branches: [develop]

jobs:
  deploy:
    runs-on: docker
    container:
      image: ghcr.io/catthehacker/ubuntu:runner-latest
    steps:
      - uses: actions/checkout@v4

      - name: Set up Kubernetes
        uses: https://git.cleverthis.com/actions/kubernetes@master
        with:
          cluster-name: test-cluster
          registry-url: ${{ secrets.REGISTRY_URL }}
          registry-user: ${{ secrets.REGISTRY_USER }}
          registry-password: ${{ secrets.REGISTRY_PASSWORD }}

      - name: Deploy application
        run: |
          kubectl apply -f k8s/ -n cleverthis
          kubectl rollout status deployment/my-app -n cleverthis

Requirements

  • Forgejo runner
  • Docker (pre-installed on Forgejo runners)
  • Network access to pull Kind and Kubernetes images

Troubleshooting

Cluster Creation Fails

  • Ensure your runner has sufficient resources
  • Check that Docker is running and accessible
  • Verify your Kind configuration is valid

Registry Secret Issues

  • Verify registry credentials are correct
  • Ensure registry URL includes protocol if required
  • Check that the registry is accessible from the runner

kubectl Context Issues

  • The action automatically sets up the kubectl context as kind-{cluster-name}
  • Use kubectl config get-contexts to verify the context is available