Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
c75dd14
Add kubernetes deployment deployer
creydr Oct 10, 2025
fbe9a08
Run update-codegen.sh
creydr Oct 10, 2025
aefa402
Remove unneeded function
creydr Oct 10, 2025
b2cb5ec
Address build issues
creydr Oct 10, 2025
07e763b
Run make schema-generate
creydr Oct 10, 2025
c45a57b
Get logs by selector in integration_test
creydr Oct 10, 2025
7b5e8de
Add implementations for Lister, Describer and Remover for raw deploym…
creydr Oct 10, 2025
d665b09
Use correct deploytype in integration test
creydr Oct 10, 2025
00aae0c
tmp: Use http scheme for url in describer
creydr Oct 10, 2025
96f7742
Fix receiving pod logs correctly in test
creydr Oct 20, 2025
c0e19d4
Fix deployer integration test
creydr Oct 20, 2025
d42c01a
Wait for pods of deployment to be ready too
creydr Oct 21, 2025
c106b21
Move Deployer, Describer, Lister and Remover int tests to correct pac…
creydr Oct 21, 2025
31f51c5
Log receiver also check existing pods
creydr Oct 21, 2025
0065567
Revert "Log receiver also check existing pods"
creydr Oct 21, 2025
71e275b
tmp: disable cleanup to get pod logs / status and add more logs
creydr Oct 21, 2025
62ee5e0
Revert "tmp: disable cleanup to get pod logs / status and add more logs"
creydr Oct 21, 2025
c97cef4
Give a bit more time to collect logs
creydr Oct 21, 2025
8c6b301
Add multi deployer, -lister, -remover
creydr Oct 21, 2025
60057a3
Move deployer, lister, describer and removers in separate packages
creydr Oct 22, 2025
72e5b64
Use integration tests in k8s packages too
creydr Oct 22, 2025
b7585ac
Fix import cycle issue
creydr Oct 22, 2025
5becb00
Fix integration tests
creydr Oct 23, 2025
2a005d7
Remove unneeded test
creydr Oct 23, 2025
bae127e
Run all deployer integration tests on both deployer implementations
creydr Oct 23, 2025
3c31e03
Add small delay in test
creydr Oct 23, 2025
0abe428
Revert "Add small delay in test"
creydr Oct 23, 2025
148030e
Wait for deployments to be up
creydr Oct 23, 2025
a116687
wait for ready pods instead of checking only if containers are running
creydr Oct 23, 2025
a35d7a1
tmp: collect pod status and logs
creydr Oct 23, 2025
fc98822
Revert "tmp: collect pod status and logs"
creydr Oct 24, 2025
4e8c50a
Add deploy-type information in description
creydr Oct 24, 2025
2dba689
Poll for pod logs instead of time.sleep
creydr Oct 24, 2025
d3c7585
Switch to PollUntilContextTimeout in wait functions
creydr Oct 24, 2025
163b15e
Make sure no pods of old replicas of the deployment are running anymo…
creydr Oct 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 28 additions & 9 deletions cmd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,23 @@ import (
"knative.dev/func/pkg/builders/buildpacks"
"knative.dev/func/pkg/config"
"knative.dev/func/pkg/creds"
k8sdeployer "knative.dev/func/pkg/deployer/k8s"
knativedeployer "knative.dev/func/pkg/deployer/knative"
"knative.dev/func/pkg/describer"
k8sdescriber "knative.dev/func/pkg/describer/k8s"
knativedescriber "knative.dev/func/pkg/describer/knative"
"knative.dev/func/pkg/docker"
fn "knative.dev/func/pkg/functions"
fnhttp "knative.dev/func/pkg/http"
"knative.dev/func/pkg/k8s"
"knative.dev/func/pkg/knative"
"knative.dev/func/pkg/lister"
k8slister "knative.dev/func/pkg/lister/k8s"
knativelister "knative.dev/func/pkg/lister/knative"
"knative.dev/func/pkg/oci"
"knative.dev/func/pkg/pipelines/tekton"
"knative.dev/func/pkg/remover"
k8sremover "knative.dev/func/pkg/remover/k8s"
knativeremover "knative.dev/func/pkg/remover/knative"
)

// ClientConfig settings for use with NewClient
Expand Down Expand Up @@ -58,16 +68,16 @@ func NewClient(cfg ClientConfig, options ...fn.Option) (*fn.Client, func()) {
var (
t = newTransport(cfg.InsecureSkipVerify) // may provide a custom impl which proxies
c = newCredentialsProvider(config.Dir(), t) // for accessing registries
d = newKnativeDeployer(cfg.Verbose)
d = newKnativeDeployer(cfg.Verbose) // default deployer (can be overridden via options)
pp = newTektonPipelinesProvider(c, cfg.Verbose)
o = []fn.Option{ // standard (shared) options for all commands
fn.WithVerbose(cfg.Verbose),
fn.WithTransport(t),
fn.WithRepositoriesPath(config.RepositoriesPath()),
fn.WithBuilder(buildpacks.NewBuilder(buildpacks.WithVerbose(cfg.Verbose))),
fn.WithRemover(knative.NewRemover(cfg.Verbose)),
fn.WithDescriber(knative.NewDescriber(cfg.Verbose)),
fn.WithLister(knative.NewLister(cfg.Verbose)),
fn.WithRemover(remover.NewMultiRemover(cfg.Verbose, knativeremover.NewRemover(cfg.Verbose), k8sremover.NewRemover(cfg.Verbose))),
fn.WithDescriber(describer.NewMultiDescriber(cfg.Verbose, knativedescriber.NewDescriber(cfg.Verbose), k8sdescriber.NewDescriber(cfg.Verbose))),
fn.WithLister(lister.NewLister(cfg.Verbose, knativelister.NewGetter(cfg.Verbose), k8slister.NewGetter(cfg.Verbose))),
fn.WithDeployer(d),
fn.WithPipelinesProvider(pp),
fn.WithPusher(docker.NewPusher(
Expand Down Expand Up @@ -127,12 +137,21 @@ func newTektonPipelinesProvider(creds oci.CredentialsProvider, verbose bool) *te
}

func newKnativeDeployer(verbose bool) fn.Deployer {
options := []knative.DeployerOpt{
knative.WithDeployerVerbose(verbose),
knative.WithDeployerDecorator(deployDecorator{}),
options := []knativedeployer.DeployerOpt{
knativedeployer.WithDeployerVerbose(verbose),
knativedeployer.WithDeployerDecorator(deployDecorator{}),
}

return knative.NewDeployer(options...)
return knativedeployer.NewDeployer(options...)
}

func newK8sDeployer(verbose bool) fn.Deployer {
options := []k8sdeployer.DeployerOpt{
k8sdeployer.WithDeployerVerbose(verbose),
k8sdeployer.WithDeployerDecorator(deployDecorator{}),
}

return k8sdeployer.NewDeployer(options...)
}

type deployDecorator struct {
Expand Down
6 changes: 4 additions & 2 deletions cmd/completion_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ import (
"strings"

"github.com/spf13/cobra"
"knative.dev/func/pkg/lister"
k8slister "knative.dev/func/pkg/lister/k8s"
knativelister "knative.dev/func/pkg/lister/knative"

fn "knative.dev/func/pkg/functions"
"knative.dev/func/pkg/knative"
)

func CompleteFunctionList(cmd *cobra.Command, args []string, toComplete string) (strings []string, directive cobra.ShellCompDirective) {
lister := knative.NewLister(false)
lister := lister.NewLister(false, knativelister.NewGetter(false), k8slister.NewGetter(false))

list, err := lister.List(cmd.Context(), "")
if err != nil {
Expand Down
37 changes: 35 additions & 2 deletions cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import (
"github.com/spf13/cobra"
"k8s.io/apimachinery/pkg/api/resource"
"knative.dev/client/pkg/util"

"knative.dev/func/pkg/builders"
"knative.dev/func/pkg/config"
"knative.dev/func/pkg/deployer"
fn "knative.dev/func/pkg/functions"
"knative.dev/func/pkg/k8s"
)
Expand Down Expand Up @@ -131,7 +131,7 @@ EXAMPLES
PreRunE: bindEnv("build", "build-timestamp", "builder", "builder-image",
"base-image", "confirm", "domain", "env", "git-branch", "git-dir",
"git-url", "image", "namespace", "path", "platform", "push", "pvc-size",
"service-account", "registry", "registry-insecure", "remote",
"service-account", "deploy-type", "registry", "registry-insecure", "remote",
"username", "password", "token", "verbose", "remote-storage-class"),
RunE: func(cmd *cobra.Command, args []string) error {
return runDeploy(cmd, newClient)
Expand Down Expand Up @@ -192,6 +192,8 @@ EXAMPLES
"When triggering a remote deployment, set a custom volume size to allocate for the build operation ($FUNC_PVC_SIZE)")
cmd.Flags().String("service-account", f.Deploy.ServiceAccountName,
"Service account to be used in the deployed function ($FUNC_SERVICE_ACCOUNT)")
cmd.Flags().String("deploy-type", f.Deploy.DeployType,
fmt.Sprintf("Type of deployment to use: '%s' for Knative Service (default) or '%s' for Kubernetes Deployment ($FUNC_DEPLOY_TYPE)", deployer.KnativeDeployerName, deployer.KubernetesDeployerName))
// Static Flags:
// Options which have static defaults only (not globally configurable nor
// persisted with the function)
Expand Down Expand Up @@ -565,6 +567,9 @@ type deployConfig struct {
//Service account to be used in deployed function
ServiceAccountName string

// DeployType specifies the type of deployment: "knative" or "deployment"
DeployType string

// Remote indicates the deployment (and possibly build) process are to
// be triggered in a remote environment rather than run locally.
Remote bool
Expand Down Expand Up @@ -598,6 +603,7 @@ func newDeployConfig(cmd *cobra.Command) deployConfig {
PVCSize: viper.GetString("pvc-size"),
Timestamp: viper.GetBool("build-timestamp"),
ServiceAccountName: viper.GetString("service-account"),
DeployType: viper.GetString("deploy-type"),
}
// NOTE: .Env should be viper.GetStringSlice, but this returns unparsed
// results and appears to be an open issue since 2017:
Expand Down Expand Up @@ -632,6 +638,7 @@ func (c deployConfig) Configure(f fn.Function) (fn.Function, error) {
f.Build.Git.Revision = c.GitBranch // TODO: should match; perhaps "refSpec"
f.Build.RemoteStorageClass = c.RemoteStorageClass
f.Deploy.ServiceAccountName = c.ServiceAccountName
f.Deploy.DeployType = c.DeployType
f.Local.Remote = c.Remote

// PVCSize
Expand Down Expand Up @@ -789,6 +796,32 @@ func (c deployConfig) Validate(cmd *cobra.Command) (err error) {
return
}

// clientOptions returns client options specific to deploy, including the appropriate deployer
func (c deployConfig) clientOptions() ([]fn.Option, error) {
// Start with build config options
o, err := c.buildConfig.clientOptions()
if err != nil {
return o, err
}

// Add the appropriate deployer based on deploy type
deployType := c.DeployType
if deployType == "" {
deployType = deployer.KnativeDeployerName // default to knative for backwards compatibility
}

switch deployType {
case deployer.KnativeDeployerName:
o = append(o, fn.WithDeployer(newKnativeDeployer(c.Verbose)))
case deployer.KubernetesDeployerName:
o = append(o, fn.WithDeployer(newK8sDeployer(c.Verbose)))
default:
return o, fmt.Errorf("unsupported deploy type: %s (supported: %s, %s)", deployType, deployer.KnativeDeployerName, deployer.KubernetesDeployerName)
}

return o, nil
}

// printDeployMessages to the output. Non-error deployment messages.
func printDeployMessages(out io.Writer, f fn.Function) {
digest, err := isDigested(f.Image)
Expand Down
5 changes: 5 additions & 0 deletions cmd/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ func (i info) Human(w io.Writer) error {
fmt.Fprintf(w, " %v\n", route)
}

fmt.Fprintln(w, "Deploy-Type:")
fmt.Fprintf(w, " %v\n", i.DeployType)

if len(i.Subscriptions) > 0 {
fmt.Fprintln(w, "Subscriptions (Source, Type, Broker):")
for _, s := range i.Subscriptions {
Expand All @@ -178,6 +181,8 @@ func (i info) Plain(w io.Writer) error {
fmt.Fprintf(w, "Route %v\n", route)
}

fmt.Fprintf(w, "Deploy-Type %v\n", i.DeployType)

if len(i.Subscriptions) > 0 {
for _, s := range i.Subscriptions {
fmt.Fprintf(w, "Subscription %v %v %v\n", s.Source, s.Type, s.Broker)
Expand Down
2 changes: 1 addition & 1 deletion cmd/func-util/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import (
"k8s.io/klog/v2"

"knative.dev/func/pkg/builders/s2i"
"knative.dev/func/pkg/deployer/knative"
fn "knative.dev/func/pkg/functions"
"knative.dev/func/pkg/k8s"
"knative.dev/func/pkg/knative"
"knative.dev/func/pkg/scaffolding"
"knative.dev/func/pkg/tar"
)
Expand Down
4 changes: 2 additions & 2 deletions cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@ func (items listItems) Plain(w io.Writer) error {
tabWriter := tabwriter.NewWriter(w, 0, 8, 2, ' ', 0)
defer tabWriter.Flush()

fmt.Fprintf(tabWriter, "%s\t%s\t%s\t%s\t%s\n", "NAME", "NAMESPACE", "RUNTIME", "URL", "READY")
fmt.Fprintf(tabWriter, "%s\t%s\t%s\t%s\t%s\t%s\n", "NAME", "NAMESPACE", "RUNTIME", "DEPLOY-TYPE", "URL", "READY")
for _, item := range items {
fmt.Fprintf(tabWriter, "%s\t%s\t%s\t%s\t%s\n", item.Name, item.Namespace, item.Runtime, item.URL, item.Ready)
fmt.Fprintf(tabWriter, "%s\t%s\t%s\t%s\t%s\t%s\n", item.Name, item.Namespace, item.Runtime, item.DeployType, item.URL, item.Ready)
}
return nil
}
Expand Down
1 change: 1 addition & 0 deletions docs/reference/func_deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ func deploy
-b, --builder string Builder to use when creating the function's container. Currently supported builders are "host", "pack" and "s2i". (default "pack")
--builder-image string Specify a custom builder image for use by the builder other than its default. ($FUNC_BUILDER_IMAGE)
-c, --confirm Prompt to confirm options interactively ($FUNC_CONFIRM)
--deploy-type string Type of deployment to use: 'knative' for Knative Service (default) or 'raw' for Kubernetes Deployment ($FUNC_DEPLOY_TYPE)
--domain string Domain to use for the function's route. Cluster must be configured with domain matching for the given domain (ignored if unrecognized) ($FUNC_DOMAIN)
-e, --env stringArray Environment variable to set in the form NAME=VALUE. You may provide this flag multiple times for setting multiple environment variables. To unset, specify the environment variable name followed by a "-" (e.g., NAME-).
-t, --git-branch string Git revision (branch) to be used when deploying via the Git repository ($FUNC_GIT_BRANCH)
Expand Down
Loading
Loading