Skip to content

Conversation

@shameemshah
Copy link

Description

This PR adds support for Knative Services in Reloader, addressing Issue #493.

Problem

Previously, Reloader did not support Knative Services. When users tried to use Reloader with Knative Services, the pods would be created but then immediately terminated, leaving the old pod running. This is because directly modifying the underlying Deployment causes Knative's controller to reconcile and revert changes (see Knative Serving Issue #14705).

Solution

This implementation correctly updates the Knative Service resource itself by modifying spec.template, which triggers Knative to create a new revision. This is the proper way to update Knative Services and avoids conflicts with Knative's reconciliation loop.

Changes

  • ✅ Added dynamic client support for Knative Services (CRDs)
  • ✅ Implemented Knative Service callbacks (Get, List, Update, Patch)
  • ✅ Integrated Knative Service into rolling upgrade flow
  • ✅ Updated Service spec.template to trigger new revisions (not Deployment)
  • ✅ Added comprehensive documentation in README
  • ✅ Supports both annotation and env-vars reload strategies

Implementation Details

  • Uses Kubernetes dynamic client (already available in client-go, no new dependencies)
  • Follows the same patterns as other resource types (Deployments, StatefulSets, etc.)
  • Updates spec.template.metadata.annotations for annotations strategy
  • Updates spec.template.spec.containers for env-vars strategy
  • Properly handles unstructured objects for Knative CRDs

Testing

  • ✅ Code compiles successfully
  • ✅ Follows existing code patterns
  • ✅ No breaking changes to existing functionality

Usage

Knative Services work the same way as other resources. Simply add Reloader annotations:

apiVersion: serving.knative.dev/v1
kind: Service
metadata:
  name: my-app
  annotations:
    reloader.stakater.com/auto: "true"
spec:
  template:
    metadata:
      annotations:
        reloader.stakater.com/auto: "true"
    spec:
      containers:
        - name: user-container
          image: your-image
          envFrom:
            - configMapRef:
                name: my-config
            - secretRef:
                name: my-secret

Related Issues

Checklist

  • Code compiles successfully
  • Follows existing code patterns
  • Documentation updated
  • No breaking changes
  • Ready for review

- Add dynamic client support for Knative Services (CRDs)
- Implement Knative Service callbacks (Get, List, Update, Patch)
- Integrate Knative Service into rolling upgrade flow
- Update Service spec.template to trigger new revisions (not Deployment)
- Add comprehensive documentation in README

Fixes stakater#493

This implementation correctly updates the Knative Service resource
itself (spec.template), which triggers Knative to create a new revision.
This avoids the issue where directly modifying the underlying Deployment
causes Knative's controller to reconcile and revert changes, terminating
new pods (see: knative/serving#14705).

The implementation follows the same patterns as other resource types
(Deployments, StatefulSets, etc.) and supports both annotation and
env-vars reload strategies.
- Add Knative Service permissions to ClusterRole and Role templates
- Add isKnative flag to values.yaml (defaults to false)
- Update Helm chart README with isKnative parameter documentation
- Update vanilla manifests to include Knative Service permissions

This ensures Reloader has the necessary permissions to:
- list, get, update, and patch Knative Services
- Required for the Knative Service support feature
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reloader is not working with Knative Service

1 participant