Skip to content

Commit e03c9f4

Browse files
tombanksmearyan9600
authored andcommitted
feat: add knative integration
Signed-off-by: Sanskar Jaiswal <jaiswalsanskar078@gmail.com> Co-authored-by: Thomas Banks
1 parent 8276bfa commit e03c9f4

35 files changed

+1351
-109
lines changed

.github/workflows/e2e.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
- gatewayapi
3636
- keda
3737
- apisix
38+
- knative
3839
steps:
3940
- name: Checkout
4041
uses: actions/checkout@v4

artifacts/flagger/crd.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ spec:
8080
type: object
8181
required:
8282
- targetRef
83-
- service
8483
- analysis
8584
properties:
8685
provider:

charts/flagger/crds/crd.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ spec:
8080
type: object
8181
required:
8282
- targetRef
83-
- service
8483
- analysis
8584
properties:
8685
provider:

charts/flagger/templates/rbac.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,19 @@ rules:
276276
- /version
277277
verbs:
278278
- get
279+
- apiGroups:
280+
- serving.knative.dev
281+
resources:
282+
- services
283+
verbs:
284+
- get
285+
- update
286+
- apiGroups:
287+
- serving.knative.dev
288+
resources:
289+
- revisions
290+
verbs:
291+
- get
279292
---
280293
apiVersion: rbac.authorization.k8s.io/v1
281294
kind: ClusterRoleBinding

cmd/flagger/main.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ import (
5151
"github.com/fluxcd/flagger/pkg/server"
5252
"github.com/fluxcd/flagger/pkg/signals"
5353
"github.com/fluxcd/flagger/pkg/version"
54+
55+
knative "knative.dev/serving/pkg/client/clientset/versioned"
5456
)
5557

5658
var (
@@ -110,7 +112,7 @@ func init() {
110112
flag.BoolVar(&zapReplaceGlobals, "zap-replace-globals", false, "Whether to change the logging level of the global zap logger.")
111113
flag.StringVar(&zapEncoding, "zap-encoding", "json", "Zap logger encoding.")
112114
flag.StringVar(&namespace, "namespace", "", "Namespace that flagger would watch canary object.")
113-
flag.StringVar(&meshProvider, "mesh-provider", "istio", "Service mesh provider, can be istio, linkerd, appmesh, contour, gloo, nginx, skipper, traefik, apisix, osm or kuma.")
115+
flag.StringVar(&meshProvider, "mesh-provider", "istio", "Service mesh provider, can be istio, linkerd, appmesh, contour, knative, gloo, nginx, skipper, traefik, apisix, osm or kuma.")
114116
flag.StringVar(&selectorLabels, "selector-labels", "app,name,app.kubernetes.io/name", "List of pod labels that Flagger uses to create pod selectors.")
115117
flag.StringVar(&ingressAnnotationsPrefix, "ingress-annotations-prefix", "nginx.ingress.kubernetes.io", "Annotations prefix for NGINX ingresses.")
116118
flag.StringVar(&ingressClass, "ingress-class", "", "Ingress class used for annotating HTTPProxy objects.")
@@ -166,6 +168,11 @@ func main() {
166168
logger.Fatalf("Error building flagger clientset: %s", err.Error())
167169
}
168170

171+
knativeClient, err := knative.NewForConfig(cfg)
172+
if err != nil {
173+
logger.Fatalf("Error building knative clientset: %s", err.Error())
174+
}
175+
169176
// use a remote cluster for routing if a service mesh kubeconfig is specified
170177
if kubeconfigServiceMesh == "" {
171178
kubeconfigServiceMesh = kubeconfig
@@ -221,7 +228,7 @@ func main() {
221228
setOwnerRefs = false
222229
}
223230

224-
routerFactory := router.NewFactory(cfg, kubeClient, flaggerClient, ingressAnnotationsPrefix, ingressClass, logger, meshClient, setOwnerRefs)
231+
routerFactory := router.NewFactory(cfg, kubeClient, flaggerClient, knativeClient, ingressAnnotationsPrefix, ingressClass, logger, meshClient, setOwnerRefs)
225232

226233
var configTracker canary.Tracker
227234
if enableConfigTracking {
@@ -236,10 +243,11 @@ func main() {
236243

237244
includeLabelPrefixArray := strings.Split(includeLabelPrefix, ",")
238245

239-
canaryFactory := canary.NewFactory(kubeClient, flaggerClient, configTracker, labels, includeLabelPrefixArray, logger)
246+
canaryFactory := canary.NewFactory(kubeClient, flaggerClient, knativeClient, configTracker, labels, includeLabelPrefixArray, logger)
240247

241248
c := controller.NewController(
242249
kubeClient,
250+
knativeClient,
243251
flaggerClient,
244252
infos,
245253
controlLoopInterval,

go.mod

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@ require (
2121
golang.org/x/sync v0.10.0
2222
google.golang.org/api v0.211.0
2323
google.golang.org/genproto v0.0.0-20241021214115-324edc3d5d38
24-
google.golang.org/grpc v1.67.1
25-
google.golang.org/protobuf v1.35.2
24+
google.golang.org/grpc v1.69.2
25+
google.golang.org/protobuf v1.36.2
2626
gopkg.in/h2non/gock.v1 v1.1.2
27-
k8s.io/api v0.31.3
28-
k8s.io/apimachinery v0.31.3
29-
k8s.io/client-go v0.31.3
30-
k8s.io/code-generator v0.31.3
27+
k8s.io/api v0.31.4
28+
k8s.io/apimachinery v0.31.4
29+
k8s.io/client-go v0.31.4
30+
k8s.io/code-generator v0.31.4
3131
k8s.io/klog/v2 v2.130.1
32+
knative.dev/serving v0.44.0
3233
)
3334

3435
require (
@@ -37,27 +38,30 @@ require (
3738
cloud.google.com/go/compute/metadata v0.5.2 // indirect
3839
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
3940
github.com/beorn7/perks v1.0.1 // indirect
41+
github.com/blendle/zapdriver v1.3.1 // indirect
4042
github.com/cespare/xxhash/v2 v2.3.0 // indirect
41-
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
43+
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
44+
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
4245
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
4346
github.com/go-logr/logr v1.4.2 // indirect
4447
github.com/go-logr/stdr v1.2.2 // indirect
45-
github.com/go-openapi/jsonpointer v0.19.6 // indirect
46-
github.com/go-openapi/jsonreference v0.20.2 // indirect
47-
github.com/go-openapi/swag v0.22.4 // indirect
48+
github.com/go-openapi/jsonpointer v0.21.0 // indirect
49+
github.com/go-openapi/jsonreference v0.21.0 // indirect
50+
github.com/go-openapi/swag v0.23.0 // indirect
4851
github.com/gogo/protobuf v1.3.2 // indirect
4952
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
5053
github.com/golang/protobuf v1.5.4 // indirect
5154
github.com/google/gnostic-models v0.6.8 // indirect
55+
github.com/google/go-containerregistry v0.13.0 // indirect
5256
github.com/google/gofuzz v1.2.0 // indirect
5357
github.com/google/s2a-go v0.1.8 // indirect
5458
github.com/googleapis/enterprise-certificate-proxy v0.3.4 // indirect
55-
github.com/gorilla/websocket v1.5.1 // indirect
59+
github.com/gorilla/websocket v1.5.3 // indirect
5660
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 // indirect
5761
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
58-
github.com/imdario/mergo v0.3.15 // indirect
62+
github.com/imdario/mergo v0.3.16 // indirect
5963
github.com/influxdata/line-protocol v0.0.0-20210922203350-b1ad95c89adf // indirect
60-
github.com/jmespath/go-jmespath v0.4.0 // indirect
64+
github.com/jmespath/go-jmespath v0.4.1-0.20220621161143-b0104c826a24 // indirect
6165
github.com/josharian/intern v1.0.0 // indirect
6266
github.com/json-iterator/go v1.1.12 // indirect
6367
github.com/klauspost/compress v1.17.9 // indirect
@@ -66,6 +70,7 @@ require (
6670
github.com/modern-go/reflect2 v1.0.2 // indirect
6771
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
6872
github.com/oapi-codegen/runtime v1.0.0 // indirect
73+
github.com/opencontainers/go-digest v1.0.0 // indirect
6974
github.com/pkg/errors v0.9.1 // indirect
7075
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
7176
github.com/prometheus/client_model v0.6.1 // indirect
@@ -74,28 +79,31 @@ require (
7479
github.com/spf13/pflag v1.0.5 // indirect
7580
github.com/x448/float16 v0.8.4 // indirect
7681
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.54.0 // indirect
77-
go.opentelemetry.io/otel v1.29.0 // indirect
78-
go.opentelemetry.io/otel/metric v1.29.0 // indirect
79-
go.opentelemetry.io/otel/trace v1.29.0 // indirect
82+
go.opentelemetry.io/otel v1.31.0 // indirect
83+
go.opentelemetry.io/otel/metric v1.31.0 // indirect
84+
go.opentelemetry.io/otel/trace v1.31.0 // indirect
8085
go.uber.org/multierr v1.11.0 // indirect
81-
golang.org/x/crypto v0.31.0 // indirect
86+
golang.org/x/crypto v0.32.0 // indirect
8287
golang.org/x/mod v0.22.0 // indirect
83-
golang.org/x/net v0.33.0 // indirect
88+
golang.org/x/net v0.34.0 // indirect
8489
golang.org/x/oauth2 v0.24.0 // indirect
85-
golang.org/x/sys v0.28.0 // indirect
86-
golang.org/x/term v0.27.0 // indirect
90+
golang.org/x/sys v0.29.0 // indirect
91+
golang.org/x/term v0.28.0 // indirect
8792
golang.org/x/text v0.21.0 // indirect
8893
golang.org/x/time v0.8.0 // indirect
89-
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
94+
golang.org/x/tools v0.29.0 // indirect
95+
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
9096
google.golang.org/genproto/googleapis/api v0.0.0-20241118233622-e639e219e697 // indirect
9197
google.golang.org/genproto/googleapis/rpc v0.0.0-20241206012308-a4fef0638583 // indirect
9298
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
9399
gopkg.in/inf.v0 v0.9.1 // indirect
94100
gopkg.in/yaml.v2 v2.4.0 // indirect
95101
gopkg.in/yaml.v3 v3.0.1 // indirect
96-
k8s.io/gengo/v2 v2.0.0-20240228010128-51d4e06bde70 // indirect
97-
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
98-
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect
102+
k8s.io/gengo/v2 v2.0.0-20240826214909-a7b603a56eb7 // indirect
103+
k8s.io/kube-openapi v0.0.0-20240903163716-9e1beecbcb38 // indirect
104+
k8s.io/utils v0.0.0-20240921022957-49e7df575cb6 // indirect
105+
knative.dev/networking v0.0.0-20250117155906-67d1c274ba6a // indirect
106+
knative.dev/pkg v0.0.0-20250117084104-c43477f0052b // indirect
99107
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
100108
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
101109
sigs.k8s.io/yaml v1.4.0 // indirect

0 commit comments

Comments
 (0)