Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Targetconfig crd #716

Draft
wants to merge 24 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e407f8c
feat: create targetconfig clientset and crd struct
aerosouund Jan 23, 2025
d73cd55
modify destination package
aerosouund Jan 23, 2025
bfcb8e1
wip target config
aerosouund Jan 24, 2025
0e854e8
create target config client and set it as a dependency for the resolver
aerosouund Jan 24, 2025
ffa0339
some fixes
aerosouund Jan 25, 2025
4387ff7
delete unused client package and cleanup makefile
aerosouund Jan 26, 2025
d387055
Merge branch 'main' into targetconfig-crd
aerosouund Jan 26, 2025
d58f87c
change targetconfig to a config generic
aerosouund Jan 28, 2025
135da16
initialize map
aerosouund Jan 28, 2025
e53777e
add other config types
aerosouund Jan 28, 2025
1053683
use a channel to communicate target changes
aerosouund Jan 29, 2025
a9f2583
use cache in target
aerosouund Feb 1, 2025
56da453
change test signatures to match codebase changes
aerosouund Feb 3, 2025
239435a
change webook field calles webhook to host
aerosouund Feb 3, 2025
e4987cb
change webook field calles webhook to host
aerosouund Feb 3, 2025
34997d0
tc event and restart in run.go
aerosouund Feb 3, 2025
afde70e
remove comment
aerosouund Feb 3, 2025
b4b51b3
update makefile comment
aerosouund Feb 3, 2025
befa65c
gofumpy
aerosouund Feb 3, 2025
edba4fa
gofumpt
aerosouund Feb 3, 2025
99fe42c
only restart the policy report informer once all tcs has synced
aerosouund Feb 4, 2025
547f845
remove todo
aerosouund Feb 4, 2025
89abe77
list using a clientset
aerosouund Feb 4, 2025
9f9a2c1
crd modifications
aerosouund Feb 4, 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
637 changes: 467 additions & 170 deletions Makefile

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"flag"
"time"

"github.com/spf13/cobra"
"go.uber.org/zap"
Expand All @@ -15,6 +16,8 @@ import (
v1 "github.com/kyverno/policy-reporter/pkg/api/v1"
v2 "github.com/kyverno/policy-reporter/pkg/api/v2"
"github.com/kyverno/policy-reporter/pkg/config"
tcv1alpha1 "github.com/kyverno/policy-reporter/pkg/crd/client/targetconfig/clientset/versioned"
tcinformer "github.com/kyverno/policy-reporter/pkg/crd/client/targetconfig/informers/externalversions"
"github.com/kyverno/policy-reporter/pkg/database"
"github.com/kyverno/policy-reporter/pkg/listener"
)
Expand Down Expand Up @@ -62,6 +65,14 @@ func newRunCMD(version string) *cobra.Command {
return err
}

tcClient, err := tcv1alpha1.NewForConfig(k8sConfig)
if err != nil {
return err
}

tcInformer := tcinformer.NewSharedInformerFactory(tcClient, time.Second)
inf := tcInformer.Wgpolicyk8s().V1alpha1().TargetConfigs().Informer()

g := &errgroup.Group{}

var store *database.Store
Expand Down
221 changes: 221 additions & 0 deletions config/crds/wgpolicyk8s.io_targetconfigs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: (devel)
name: targetconfigs.wgpolicyk8s.io
spec:
group: wgpolicyk8s.io
names:
kind: TargetConfig
listKind: TargetConfigList
plural: targetconfigs
shortNames:
- tcfg
singular: targetconfig
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: TargetConfig is the Schema for the targetconfigs API.
properties:
apiVersion:
description: |-
APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
type: string
kind:
description: |-
Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
metadata:
type: object
spec:
description: TargetConfigSpec defines the desired state of TargetConfig.
properties:
customFields:
additionalProperties:
type: string
type: object
filter:
properties:
namespaces:
properties:
exclude:
items:
type: string
type: array
include:
items:
type: string
type: array
selector: {}
required:
- exclude
- include
- selector
type: object
policies:
properties:
exclude:
items:
type: string
type: array
include:
items:
type: string
type: array
selector: {}
required:
- exclude
- include
- selector
type: object
reportLabels:
properties:
exclude:
items:
type: string
type: array
include:
items:
type: string
type: array
selector: {}
required:
- exclude
- include
- selector
type: object
severities:
properties:
exclude:
items:
type: string
type: array
include:
items:
type: string
type: array
selector: {}
required:
- exclude
- include
- selector
type: object
sources:
properties:
exclude:
items:
type: string
type: array
include:
items:
type: string
type: array
selector: {}
required:
- exclude
- include
- selector
type: object
status:
properties:
exclude:
items:
type: string
type: array
include:
items:
type: string
type: array
selector: {}
required:
- exclude
- include
- selector
type: object
required:
- namespaces
- policies
- reportLabels
- severities
- sources
- status
type: object
minimumSeverity:
type: string
mountedSecret:
type: string
name:
type: string
s3:
properties:
accessKeyId:
type: string
bucket:
type: string
bucketKeyEnabled:
type: boolean
endpoint:
type: string
kmsKeyId:
type: string
pathStyle:
type: boolean
prefix:
type: string
region:
type: string
secretAccessKey:
type: string
serverSideEncryption:
type: string
required:
- accessKeyId
- bucket
- bucketKeyEnabled
- endpoint
- kmsKeyId
- pathStyle
- prefix
- region
- secretAccessKey
- serverSideEncryption
type: object
secretRef:
type: string
skipExistingOnStartup:
type: boolean
sources:
items:
type: string
type: array
targetType:
type: string
required:
- customFields
- filter
- minimumSeverity
- mountedSecret
- name
- secretRef
- skipExistingOnStartup
- sources
type: object
status:
description: TargetConfigStatus defines the observed state of TargetConfig.
type: object
type: object
served: true
storage: true
subresources:
status: {}
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ require (
golang.org/x/sync v0.10.0
golang.org/x/text v0.21.0
google.golang.org/api v0.215.0
k8s.io/apiextensions-apiserver v0.32.1
k8s.io/apimachinery v0.32.1
k8s.io/client-go v0.32.1
k8s.io/kube-aggregator v0.32.1
)

require (
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -511,12 +511,16 @@ honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWh
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
k8s.io/api v0.32.1 h1:f562zw9cy+GvXzXf0CKlVQ7yHJVYzLfL6JAS4kOAaOc=
k8s.io/api v0.32.1/go.mod h1:/Yi/BqkuueW1BgpoePYBRdDYfjPF5sgTr5+YqDZra5k=
k8s.io/apiextensions-apiserver v0.32.1 h1:hjkALhRUeCariC8DiVmb5jj0VjIc1N0DREP32+6UXZw=
k8s.io/apiextensions-apiserver v0.32.1/go.mod h1:sxWIGuGiYov7Io1fAS2X06NjMIk5CbRHc2StSmbaQto=
k8s.io/apimachinery v0.32.1 h1:683ENpaCBjma4CYqsmZyhEzrGz6cjn1MY/X2jB2hkZs=
k8s.io/apimachinery v0.32.1/go.mod h1:GpHVgxoKlTxClKcteaeuF1Ul/lDVb74KpZcxcmLDElE=
k8s.io/client-go v0.32.1 h1:otM0AxdhdBIaQh7l1Q0jQpmo7WOFIk5FFa4bg6YMdUU=
k8s.io/client-go v0.32.1/go.mod h1:aTTKZY7MdxUaJ/KiUs8D+GssR9zJZi77ZqtzcGXIiDg=
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
k8s.io/kube-aggregator v0.32.1 h1:cztPyIHbo6tgrhYHDqmdmvxUufJKuxgAC/vog7yeWek=
k8s.io/kube-aggregator v0.32.1/go.mod h1:sXjL5T8FO/rlBzTbBhahw9V5Nnr1UtzZHKTj9WxQCOU=
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f h1:GA7//TjRY9yWGy1poLzYYJJ4JRdzg3+O6e8I+e+8T5Y=
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f/go.mod h1:R/HEjbvWI0qdfb8viZUeVZm0X6IZnxAydC7YU42CMw4=
k8s.io/utils v0.0.0-20241104163129-6fe5fd82f078 h1:jGnCPejIetjiy2gqaJ5V0NLwTpF4wbQ6cZIItJCSHno=
Expand Down
37 changes: 37 additions & 0 deletions hack/controller-gen/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module github.com/kyverno/kyverno/hack/controller-gen

go 1.22.4

require (
github.com/spf13/cobra v1.8.1
k8s.io/apiextensions-apiserver v0.31.4
sigs.k8s.io/controller-tools v0.16.5
)

require (
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/gobuffalo/flect v1.0.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/x448/float16 v0.8.4 // indirect
golang.org/x/mod v0.22.0 // indirect
golang.org/x/net v0.34.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/tools v0.29.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/apimachinery v0.31.4 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/utils v0.0.0-20240821151609-f90d01438635 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
)
Loading
Loading