GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add func-operator integration to deploy command by creydr · Pull Request #3657 · knative/func

Conversation

@creydr

@creydr creydr commented May 5, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Changes

  • 🎁 Create a Function CR on func deploy when func-operator is installed
  • 🎁 Add option to skip Function CR creation via func deploy --management-disabled
  • 🔧 Bump Go to 1.26 (required by controller-runtime dependency)

/kind enhancement

Release Note

Create Function CR on `func deploy`

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@knative-prow knative-prow Bot added do-not-merge/work-in-progress 🤖 PR should not merge because it is a work in progress. kind/enhancement Feature additions or improvements to existing labels May 5, 2026
@knative-prow
knative-prow Bot requested review from dsimansk and jrangelramos May 5, 2026 12:21
@knative-prow knative-prow Bot added the size/XXL 🤖 PR changes 1000+ lines, ignoring generated files. label May 5, 2026
@codecov

codecov Bot commented May 5, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 46.04905% with 198 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.84%. Comparing base (5f2cbd8) to head (8a8ed72).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/deployer/testing/integration_test_helper.go 0.00% 131 Missing ⚠️
pkg/operator/sync.go 68.93% 22 Missing and 10 partials ⚠️
pkg/git/resolver.go 70.76% 13 Missing and 6 partials ⚠️
pkg/operator/syncer.go 74.50% 10 Missing and 3 partials ⚠️
pkg/functions/client.go 62.50% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3657      +/-   ##
==========================================
- Coverage   57.04%   56.84%   -0.21%     
==========================================
  Files         182      185       +3     
  Lines       21376    21739     +363     
==========================================
+ Hits        12195    12358     +163     
- Misses       7951     8130     +179     
- Partials     1230     1251      +21     
Flag Coverage Δ
e2e 35.78% <35.16%> (-0.03%) ⬇️
e2e go 31.48% <38.42%> (+0.06%) ⬆️
e2e node 27.37% <38.42%> (+0.11%) ⬆️
e2e python 31.84% <38.42%> (+0.06%) ⬆️
e2e quarkus 27.48% <38.42%> (+0.11%) ⬆️
e2e rust 26.91% <38.42%> (+0.20%) ⬆️
e2e springboot 25.45% <38.42%> (+0.14%) ⬆️
e2e typescript 27.46% <38.42%> (+0.10%) ⬆️
e2e-config-ci 28.34% <44.21%> (+0.17%) ⬆️
integration 16.91% <0.00%> (-0.29%) ⬇️
unit macos-14 44.89% <34.12%> (-0.21%) ⬇️
unit macos-latest 44.89% <34.12%> (-0.21%) ⬇️
unit ubuntu-24.04-arm 45.10% <32.15%> (-0.24%) ⬇️
unit ubuntu-latest 45.82% <34.12%> (-0.22%) ⬇️
unit windows-latest 44.93% <34.12%> (-0.21%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@knative-prow-robot knative-prow-robot added the needs-rebase Cannot be merged due to conflicts with HEAD. label May 5, 2026
@creydr
creydr force-pushed the create-func-crd-on-deploy-2 branch from 6bd73c4 to ba2e1c9 Compare May 5, 2026 13:21
@knative-prow-robot knative-prow-robot added needs-rebase Cannot be merged due to conflicts with HEAD. and removed needs-rebase Cannot be merged due to conflicts with HEAD. labels May 5, 2026
lkingland
lkingland reviewed May 8, 2026
View reviewed changes

@lkingland lkingland left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! My only substantive suggestion is that this be integrated more deeply into core instead of an ad-hoc post-deploy hook 👍🏻

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread go.mod
module knative.dev/func

go 1.25.9
go 1.26

@lkingland lkingland May 8, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I presume this was necessary due to controller-runtime dependency? Maybe just add to the commit description this PR also bumps to Go 1.26

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@creydr creydr May 11, 2026

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, required by controller-runtime. Added a note to the PR description.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pkg/operator/sync.go Outdated
}

if cfg.RepoURL == "" {
fmt.Fprintln(os.Stderr, "Function CR not created: no git remote found. Set --git-url to enable operator management.")

@lkingland lkingland May 8, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This warning will fire on every deploy without a configured git remote, given --manage=true is the default. I think that there are actually two preconditions for a Function to be "managed": The operator is installed AND they're using git.

The base case: A user just initializes a function and deployes it directly to a vanilla cluster, shouldn't really even print a warning (it's an expected base case).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@creydr creydr May 11, 2026

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Changed to skip silently when no git remote is configured — the two preconditions are now operator CRD installed AND git URL available.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pkg/operator/sync.go
}

if existing != nil {
existing.Spec = desiredSpec

@lkingland lkingland May 8, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just double-checking: without using a merge, this will always overwrite the spec, even if changed in some different way. I think that's what we want (again encouraging declarative config), but just want to flag this to be sure.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@creydr creydr May 11, 2026

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, this is intentional. The spec is always overwritten with the local state to encourage declarative config.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pkg/operator/sync.go Outdated
func hasFunctionCRD(disc discovery.DiscoveryInterface) (bool, error) {
resources, err := disc.ServerResourcesForGroupVersion("functions.dev/v1alpha1")
if err != nil {
return false, nil

@lkingland lkingland May 8, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This swallows any error from ServerResourcesForGroupVersion and treats it identically to "CRD not present." If there's a legitimate reason, we probably want to raise an error. Perhaps something like:

resources, err := disc.ServerResourcesForGroupVersion("functions.dev/v1alpha1")
if err != nil {
    if apierrors.IsNotFound(err) || meta.IsNoMatchError(err) {
        return false, nil
    }
    return false, fmt.Errorf("checking for Function CRD: %w", err)
}

(I haven't fully traced the call path here; just an example)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@creydr creydr May 11, 2026

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Now only IsNotFound errors are treated as CRD absence; other errors are propagated.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pkg/operator/sync.go Outdated
Comment on lines +161 to +167
if list.Items[i].Status.Name == funcName {
return &list.Items[i], nil
}
}

for i := range list.Items {
if list.Items[i].Name == funcName {

@lkingland lkingland May 8, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nit: these two loops over list.Items made me double-check to see if it was an error. maybe just put both if statements in one for-loop for clarity that this was intended.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@creydr creydr May 11, 2026

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Combined into a single loop. Status name match still takes priority (returns immediately); metadata name match is remembered as fallback.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread cmd/deploy.go Outdated
Comment on lines +824 to +831
if c.Manage {
o = append(o, fn.WithPostDeploy(func(ctx context.Context, f fn.Function) error {
if err := syncFunctionCR(ctx, f, c, creds); err != nil {
fmt.Fprintf(os.Stderr, "Warning: failed to sync Function CR: %v\n", err)
}
return nil
}))
}

@lkingland lkingland May 8, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be part of core rather than in the CLI. Adding a boolean to the Function structh which states this is a "managed" Function, and a CR should be created (if the operator is installed).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@creydr creydr May 11, 2026

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Moved into core Client.Deploy() via a FunctionSyncer interface, with ManagementDisabled field on DeploySpec (managed by default).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread pkg/functions/client.go Outdated
pipelinesProvider PipelinesProvider // CI/CD pipelines management
mcpServer MCPServer // MCP Server
startTimeout time.Duration // default start timeout for all runs
postDeploy func(context.Context, Function) error

@lkingland lkingland May 8, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for a post-deploy hook if we just extend the core's "deploy" logic to do the CR work if the given function is a "managed" function.

To make it even simpler, the flag could be "ManagementDisabled", such that the deafult will always be to create the CR if the system detects the operator is installed.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@creydr creydr May 11, 2026

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Replaced postDeploy hook with FunctionSyncer interface. --manage flag replaced by --management-disabled.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@creydr
creydr force-pushed the create-func-crd-on-deploy-2 branch from ba2e1c9 to 38650ee Compare May 11, 2026 09:13
@knative-prow-robot knative-prow-robot removed the needs-rebase Cannot be merged due to conflicts with HEAD. label May 11, 2026
@creydr

creydr commented May 11, 2026

Copy link
Copy Markdown
Member Author

rebased and resolved merge conflicts

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@creydr creydr changed the title [WIP] Add func-operator integration to deploy command Add func-operator integration to deploy command May 11, 2026
@knative-prow knative-prow Bot removed the do-not-merge/work-in-progress 🤖 PR should not merge because it is a work in progress. label May 11, 2026
@creydr
creydr requested a review from lkingland May 11, 2026 11:29
@creydr

creydr commented May 11, 2026

Copy link
Copy Markdown
Member Author

Thanks for the review @lkingland
I addressed your review (hopefully :D )

Only maybe one thing we could also address in this PR: WDYT about removing the CR when --management-disabled is set?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@knative-prow-robot knative-prow-robot added the needs-rebase Cannot be merged due to conflicts with HEAD. label May 12, 2026
@creydr
creydr force-pushed the create-func-crd-on-deploy-2 branch from 470d603 to bc2b28d Compare May 12, 2026 08:33
@knative-prow-robot knative-prow-robot removed the needs-rebase Cannot be merged due to conflicts with HEAD. label May 12, 2026
@creydr

creydr commented May 12, 2026

Copy link
Copy Markdown
Member Author

rebased

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@creydr

creydr commented May 12, 2026

Copy link
Copy Markdown
Member Author

@lkingland can you recheck?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@creydr
creydr force-pushed the create-func-crd-on-deploy-2 branch from bc2b28d to 206e6c1 Compare May 13, 2026 07:50
@creydr

creydr commented May 13, 2026

Copy link
Copy Markdown
Member Author

rebased

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lkingland

lkingland commented May 16, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Looks good @creydr! Let's rebase and then land this one

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@knative-prow-robot knative-prow-robot added the needs-rebase Cannot be merged due to conflicts with HEAD. label May 16, 2026
This was referenced May 16, 2026
refactor: route in-cluster service addresses through k8s.ClusterDomain() #3682
Merged
Clusterdomain is not configurable in Keda deployer #3403
Open
@creydr
Add func-operator integration to deploy command
cbf5dcd
When deploying a function, automatically create or update a Function CR
(functions.dev/v1alpha1) if the func-operator CRD is installed on the
cluster. On first deploy, the CR is created with the git repository URL,
branch, and path. On subsequent deploys, only the
functions.knative.dev/last-deployed annotation is updated.

- Add pkg/git/ with go-git based resolution of remote URL and branch
- Add pkg/operator/ with Function CR sync logic and k8s client setup
- Add WithPostDeploy client option to run post-deploy hooks
- Add --manage flag (default true) to opt out with --manage=false
- Wire operator sync via WithPostDeploy in deploy command
- Git URL cascade: --git-url > tracking remote > origin
- Branch cascade: --git-branch > current branch > "main"
- Silently skip if CRD not installed; warn if no git remote found
creydr added 12 commits May 18, 2026 09:16
@creydr
Add integration test for operator sync across all deployers
1dad146
Add TestInt_OperatorSync to the shared deployer integration test helper.
The test deploys a function with WithPostDeploy wired to
operator.SyncFunctionCR, verifies the Function CR is created with the
correct spec on first deploy, and confirms only the last-deployed
annotation is updated on subsequent deploys. CR verification is skipped
gracefully when the Function CRD is not installed.
@creydr
Install func-operator in test cluster setup
a36bcf9
Add func-operator v0.2.1 to the cluster setup script so the Function CRD
is available for integration tests. The operator is installed in parallel
with other components during cluster allocation.
@creydr
Strip credentials from git remote URLs in Function CR
7f610a2
ResolveRemoteURL now removes userinfo (username and password) from
HTTP/HTTPS remote URLs before returning them, preventing credentials
from being stored in the Function CR spec.
@creydr
Add registry credential support to Function CR sync
f18d18f
When deploying to a private registry, resolve credentials via
the existing CredentialsProvider, create a docker-registry K8s
Secret, and set .spec.registry.authSecretRef on the Function CR
so the func-operator can authenticate with the registry.
@creydr
Fix CI failures in linter and unit tests
d341016
- Check return value of AddToScheme (errcheck lint)
- Make registry secret creation injectable for unit tests
- Add git commit author in resolver tests for CI
- Add FuncOperator to component-versions test expectations
@creydr
Move operator CR sync into core Client.Deploy()
5bf9116
Replace the CLI-level postDeploy hook with a FunctionSyncer interface
in pkg/functions, implemented by pkg/operator.Syncer. This makes
operator management available to all library users, not just the CLI.

- Add FunctionSyncer interface and WithSyncer option to Client
- Add ManagementDisabled field to DeploySpec (managed by default)
- Create pkg/operator/syncer.go encapsulating git/registry resolution
- Wire operator.NewSyncer in cmd/client.go NewClient()
- Replace --manage flag with --management-disabled
- Remove postDeploy hook, syncFunctionCR from cmd/deploy.go
- Update integration test to use WithSyncer
@creydr
Skip Function CR sync silently when no git remote is configured
8e10097
A user deploying without a git remote is an expected base case, not a
warning-worthy condition. The operator sync now requires both the CRD
to be installed and a git URL to be available before attempting to
create or update a Function CR.
@creydr
Distinguish CRD-not-found from real errors in hasFunctionCRD
44fd298
Previously all errors from ServerResourcesForGroupVersion were
swallowed and treated as "CRD not present". Now only NotFound
errors are treated as CRD absence; other errors are propagated
so legitimate failures are not silently ignored.
@creydr
Combine two loops in findExistingCR into one
9f822e0
Merge the separate status-name and metadata-name lookups into a
single pass over the list. Status name match still takes priority
and returns immediately; metadata name match is remembered as a
fallback.
@creydr
Use func-operator GroupVersion constant instead of hardcoded string
c48dc08
Replace the hardcoded "functions.dev/v1alpha1" string with
v1alpha1.GroupVersion.String() in hasFunctionCRD, unit tests,
and integration test helper.
@creydr
Regenerate deploy command reference docs
9826f5c
Update generated docs to reflect --manage being replaced by
--management-disabled.
@creydr
Regenerate func.yaml JSON schema
8a8ed72
Add ManagementDisabled field to the generated schema.
@creydr
creydr force-pushed the create-func-crd-on-deploy-2 branch from 206e6c1 to 8a8ed72 Compare May 18, 2026 07:19
@knative-prow-robot knative-prow-robot removed the needs-rebase Cannot be merged due to conflicts with HEAD. label May 18, 2026
@creydr

creydr commented May 18, 2026

Copy link
Copy Markdown
Member Author

@lkingland rebased :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

lkingland
lkingland approved these changes May 18, 2026
View reviewed changes
@knative-prow knative-prow Bot assigned lkingland May 18, 2026
@knative-prow knative-prow Bot added the lgtm 🤖 PR is ready to be merged. label May 18, 2026
@knative-prow

knative-prow Bot commented May 18, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: creydr, lkingland

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [lkingland]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@knative-prow knative-prow Bot added the approved 🤖 PR has been approved by an approver from all required OWNERS files. label May 18, 2026
@knative-prow
knative-prow Bot merged commit b1635be into knative:main May 18, 2026
41 checks passed

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@lkingland lkingland lkingland approved these changes
@dsimansk dsimansk Awaiting requested review from dsimansk
@jrangelramos jrangelramos Awaiting requested review from jrangelramos

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@lkingland lkingland

Labels

approved 🤖 PR has been approved by an approver from all required OWNERS files. kind/enhancement Feature additions or improvements to existing lgtm 🤖 PR is ready to be merged. size/XXL 🤖 PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@creydr @lkingland @knative-prow-robot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.