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

[WIP] remove sensitive data from MR and resolve references just before use to not leak secrets data in to MR after resolved. #252

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
f681940
feat(in-cluster): update example to use native crossplane way
haarchri Feb 2, 2024
2cb7d75
feat(in-cluster): update example to use native crossplane way
haarchri Feb 2, 2024
7e79c25
Update version in incluster example
turkenh Feb 8, 2024
db6d951
Bump dependencies
turkenh Feb 8, 2024
8592e33
enable opt-in to redact Secret data from Object status
Feb 7, 2024
d29c762
address review comments: use fieldPath library to set redacted data
Feb 9, 2024
292c7b5
update CI go version to go-1.21
Feb 9, 2024
c596239
Add jitter to poll interval
ravilr Feb 13, 2024
90c5b60
make poll jitter percentage configurable through flag option
ravilr Feb 16, 2024
a68bf67
Use better defaults for poll interval and max reconcile rate
turkenh Feb 19, 2024
fddaba8
Do not wait for poll interval if not ready
turkenh Feb 20, 2024
382c96b
fix missing ToConnectionSecretKey in conversion
ravilr Feb 24, 2024
6448624
Add `ObservedObjectCollection` API type (#217)
pedjak Apr 8, 2024
4cbf040
Update README with correct installation instructions
scubbo May 8, 2024
91d8438
Update README.md
scubbo May 8, 2024
ba12c53
Bump build submodule and dependencies to latest
turkenh Apr 30, 2024
d1539b6
Implement watching referenced resources
turkenh Apr 30, 2024
ac7ee5d
Watch managed resources as well
turkenh May 2, 2024
8fb68a4
Do not start multiple caches against the same host
turkenh May 2, 2024
a3fa10e
Do not attempt resolving references if object is being deleted
turkenh May 2, 2024
c1c9425
Put resource watching behind feature flag
turkenh May 2, 2024
a604c64
Fix unit tests and code comments
turkenh May 2, 2024
5f12a80
Start an informer per provider config & gvk pair
turkenh May 2, 2024
1e56b1d
Start watching even if it does not exist (yet)
turkenh May 2, 2024
1398190
Catch add or delete events as well
turkenh May 3, 2024
9714e9e
Stop watching on Object deletion
turkenh May 3, 2024
d1ccd44
Only watch the resource if desired
turkenh May 3, 2024
bd6d7ee
Better naming for index functions
turkenh May 4, 2024
4b863a7
Do not use pointer for optional bool watch
turkenh May 9, 2024
cbeeeff
Double check if cache is started already
turkenh May 9, 2024
2f543db
Refactor clients package
turkenh May 10, 2024
5723426
Rely on garbage collect and override default DefaultWatchErrorHandler
turkenh May 10, 2024
d1842e4
Add e2e for watching object
turkenh May 10, 2024
683fa86
Always pass update event to reconciler
turkenh May 10, 2024
cdf816f
Introduce MR metrics
ezgidemirel Apr 16, 2024
61b5cbc
change resolve logic to exclude secret when initial resolve runs in
May 23, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

env:
# Common versions
GO_VERSION: '1.20.12'
GO_VERSION: '1.21.7'
GOLANGCI_VERSION: 'v1.55.2'
DOCKER_BUILDX_VERSION: 'v0.8.2'

Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ GOLANGCILINT_VERSION = 1.55.2

# ====================================================================================
# Setup Kubernetes tools
KIND_VERSION = v0.18.0
UP_VERSION = v0.21.0
KIND_VERSION = v0.22.0
UP_VERSION = v0.28.0
UPTEST_VERSION = v0.9.0
UP_CHANNEL = stable
USE_HELM3 = true
Expand Down Expand Up @@ -89,7 +89,7 @@ CROSSPLANE_NAMESPACE = crossplane-system
-include build/makelib/local.xpkg.mk
-include build/makelib/controlplane.mk

UPTEST_EXAMPLE_LIST ?= "examples/object/object.yaml"
UPTEST_EXAMPLE_LIST ?= "examples/object/object.yaml,examples/object/object-watching.yaml"
uptest: $(UPTEST) $(KUBECTL) $(KUTTL)
@$(INFO) running automated tests
@KUBECTL=$(KUBECTL) KUTTL=$(KUTTL) CROSSPLANE_NAMESPACE=${CROSSPLANE_NAMESPACE} $(UPTEST) e2e "$(UPTEST_EXAMPLE_LIST)" --setup-script=cluster/test/setup.sh || $(FAIL)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ so using the Crossplane CLI in a Kubernetes cluster where Crossplane is
installed:

```console
kubectl crossplane install provider crossplanecontrib/provider-kubernetes:main
crossplane xpkg install provider xpkg.upbound.io/crossplane-contrib/provider-kubernetes:v0.13.0
```

You may also manually install `provider-kubernetes` by creating a `Provider` directly:
Expand All @@ -25,7 +25,7 @@ kind: Provider
metadata:
name: provider-kubernetes
spec:
package: "crossplanecontrib/provider-kubernetes:main"
package: xpkg.upbound.io/crossplane-contrib/provider-kubernetes:v0.13.0
```

## Developing locally
Expand Down
2 changes: 2 additions & 0 deletions apis/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

objectv1alpha1 "github.com/crossplane-contrib/provider-kubernetes/apis/object/v1alpha1"
objectv1alhpa2 "github.com/crossplane-contrib/provider-kubernetes/apis/object/v1alpha2"
observedobjectcollectionv1alpha1 "github.com/crossplane-contrib/provider-kubernetes/apis/observedobjectcollection/v1alpha1"
templatev1alpha1 "github.com/crossplane-contrib/provider-kubernetes/apis/v1alpha1"
)

Expand All @@ -31,6 +32,7 @@ func init() {
templatev1alpha1.SchemeBuilder.AddToScheme,
objectv1alpha1.SchemeBuilder.AddToScheme,
objectv1alhpa2.SchemeBuilder.AddToScheme,
observedobjectcollectionv1alpha1.SchemeBuilder.AddToScheme,
)
}

Expand Down
6 changes: 4 additions & 2 deletions apis/object/v1alpha1/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ func (src *Object) ConvertTo(dstRaw conversion.Hub) error { // nolint:golint //
connectionDetails := []v1alpha2.ConnectionDetail{}
for _, cd := range src.Spec.ConnectionDetails {
connectionDetails = append(connectionDetails, v1alpha2.ConnectionDetail{
ObjectReference: cd.ObjectReference,
ObjectReference: cd.ObjectReference,
ToConnectionSecretKey: cd.ToConnectionSecretKey,
})
}

Expand Down Expand Up @@ -123,7 +124,8 @@ func (dst *Object) ConvertFrom(srcRaw conversion.Hub) error { // nolint:golint,
connectionDetails := []ConnectionDetail{}
for _, cd := range src.Spec.ConnectionDetails {
connectionDetails = append(connectionDetails, ConnectionDetail{
ObjectReference: cd.ObjectReference,
ObjectReference: cd.ObjectReference,
ToConnectionSecretKey: cd.ToConnectionSecretKey,
})
}

Expand Down
34 changes: 25 additions & 9 deletions apis/object/v1alpha1/conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"

v1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
"github.com/crossplane/crossplane-runtime/pkg/test"
Expand Down Expand Up @@ -64,7 +64,9 @@ func TestConvertTo(t *testing.T) {
APIVersion: "v1",
Kind: "Secret",
Name: "topsecret",
FieldPath: "data.token",
},
ToConnectionSecretKey: "token",
},
},
ForProvider: v1alpha1.ObjectParameters{
Expand All @@ -86,9 +88,9 @@ func TestConvertTo(t *testing.T) {
Name: "topsecret",
Namespace: "coolns",
},
FieldPath: pointer.String("data.password"),
FieldPath: ptr.To("data.password"),
},
ToFieldPath: pointer.String("data"),
ToFieldPath: ptr.To("data"),
},
},
Readiness: v1alpha1.Readiness{Policy: v1alpha1.ReadinessPolicySuccessfulCreate},
Expand All @@ -111,7 +113,9 @@ func TestConvertTo(t *testing.T) {
APIVersion: "v1",
Kind: "Secret",
Name: "topsecret",
FieldPath: "data.token",
},
ToConnectionSecretKey: "token",
},
},
ForProvider: v1alpha2.ObjectParameters{
Expand All @@ -132,9 +136,9 @@ func TestConvertTo(t *testing.T) {
Name: "topsecret",
Namespace: "coolns",
},
FieldPath: pointer.String("data.password"),
FieldPath: ptr.To("data.password"),
},
ToFieldPath: pointer.String("data"),
ToFieldPath: ptr.To("data"),
},
},
Readiness: v1alpha2.Readiness{Policy: v1alpha2.ReadinessPolicySuccessfulCreate},
Expand Down Expand Up @@ -196,7 +200,9 @@ func TestConvertTo(t *testing.T) {
APIVersion: "v1",
Kind: "Secret",
Name: "topsecret",
FieldPath: "data.token",
},
ToConnectionSecretKey: "token",
},
},
ForProvider: v1alpha1.ObjectParameters{
Expand Down Expand Up @@ -229,7 +235,9 @@ func TestConvertTo(t *testing.T) {
APIVersion: "v1",
Kind: "Secret",
Name: "topsecret",
FieldPath: "data.token",
},
ToConnectionSecretKey: "token",
},
},
ForProvider: v1alpha2.ObjectParameters{
Expand Down Expand Up @@ -312,7 +320,9 @@ func TestConvertFrom(t *testing.T) {
APIVersion: "v1",
Kind: "Secret",
Name: "topsecret",
FieldPath: "data.token",
},
ToConnectionSecretKey: "token",
},
},
ForProvider: v1alpha2.ObjectParameters{
Expand All @@ -333,9 +343,9 @@ func TestConvertFrom(t *testing.T) {
Name: "topsecret",
Namespace: "coolns",
},
FieldPath: pointer.String("data.password"),
FieldPath: ptr.To("data.password"),
},
ToFieldPath: pointer.String("data"),
ToFieldPath: ptr.To("data"),
},
},
Readiness: v1alpha2.Readiness{Policy: v1alpha2.ReadinessPolicySuccessfulCreate},
Expand All @@ -357,7 +367,9 @@ func TestConvertFrom(t *testing.T) {
APIVersion: "v1",
Kind: "Secret",
Name: "topsecret",
FieldPath: "data.token",
},
ToConnectionSecretKey: "token",
},
},
ForProvider: v1alpha1.ObjectParameters{
Expand All @@ -379,9 +391,9 @@ func TestConvertFrom(t *testing.T) {
Name: "topsecret",
Namespace: "coolns",
},
FieldPath: pointer.String("data.password"),
FieldPath: ptr.To("data.password"),
},
ToFieldPath: pointer.String("data"),
ToFieldPath: ptr.To("data"),
},
},
Readiness: v1alpha1.Readiness{Policy: v1alpha1.ReadinessPolicySuccessfulCreate},
Expand All @@ -407,7 +419,9 @@ func TestConvertFrom(t *testing.T) {
APIVersion: "v1",
Kind: "Secret",
Name: "topsecret",
FieldPath: "data.token",
},
ToConnectionSecretKey: "token",
},
},
ForProvider: v1alpha2.ObjectParameters{
Expand Down Expand Up @@ -438,7 +452,9 @@ func TestConvertFrom(t *testing.T) {
APIVersion: "v1",
Kind: "Secret",
Name: "topsecret",
FieldPath: "data.token",
},
ToConnectionSecretKey: "token",
},
},
ForProvider: v1alpha1.ObjectParameters{
Expand Down
8 changes: 8 additions & 0 deletions apis/object/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ type ObjectSpec struct {
ManagementPolicy `json:"managementPolicy,omitempty"`
References []Reference `json:"references,omitempty"`
Readiness Readiness `json:"readiness,omitempty"`
// Watch enables watching the referenced or managed kubernetes resources.
//
// THIS IS AN ALPHA FIELD. Do not use it in production. It is not honored
// unless "watches" feature gate is enabled, and may be changed or removed
// without notice.
// +optional
// +kubebuilder:default=false
Watch bool `json:"watch,omitempty"`
}

// ReadinessPolicy defines how the Object's readiness condition should be computed.
Expand Down
8 changes: 8 additions & 0 deletions apis/object/v1alpha2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ type ObjectSpec struct {
ForProvider ObjectParameters `json:"forProvider"`
References []Reference `json:"references,omitempty"`
Readiness Readiness `json:"readiness,omitempty"`
// Watch enables watching the referenced or managed kubernetes resources.
//
// THIS IS AN ALPHA FIELD. Do not use it in production. It is not honored
// unless "watches" feature gate is enabled, and may be changed or removed
// without notice.
// +optional
// +kubebuilder:default=false
Watch bool `json:"watch,omitempty"`
}

// ReadinessPolicy defines how the Object's readiness condition should be computed.
Expand Down
22 changes: 22 additions & 0 deletions apis/observedobjectcollection/v1alpha1/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
Copyright 2024 The Crossplane Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Package v1alpha1 contains the v1alpha1 group ObservedObjectCollection resources of the Kubernetes provider.
// +kubebuilder:ac:generate=true
// +kubebuilder:object:generate=true
// +groupName=kubernetes.crossplane.io
// +versionName=v1alpha1
package v1alpha1
50 changes: 50 additions & 0 deletions apis/observedobjectcollection/v1alpha1/register.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
Copyright 2024 The Crossplane Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import (
"reflect"

"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

// Package type metadata.
const (
Group = "kubernetes.crossplane.io"
Version = "v1alpha1"
)

var (
// SchemeGroupVersion is group version used to register these objects
SchemeGroupVersion = schema.GroupVersion{Group: Group, Version: Version}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion}
)

// ProviderConfig type metadata.
var (
ObservedObjectCollectionKind = reflect.TypeOf(ObservedObjectCollection{}).Name()
ObservedObjectCollectionGroupKind = schema.GroupKind{Group: Group, Kind: ObservedObjectCollectionKind}.String()
ObservedObjectCollectionAPIVersion = ObservedObjectCollectionKind + "." + SchemeGroupVersion.String()
ObservedObjectCollectionGroupVersionKind = SchemeGroupVersion.WithKind(ObservedObjectCollectionKind)
)

func init() {
SchemeBuilder.Register(&ObservedObjectCollection{}, &ObservedObjectCollectionList{})
}
Loading