diff --git a/Dockerfile b/Dockerfile index f18ad484..97b8c939 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Build the manager binary -FROM golang:1.19 as builder +FROM golang:1.21 as builder WORKDIR /workspace # Copy the Go Modules manifests diff --git a/api/v1alpha1/meshsync_types.go b/api/v1alpha1/meshsync_types.go index 8a15e817..111856fa 100644 --- a/api/v1alpha1/meshsync_types.go +++ b/api/v1alpha1/meshsync_types.go @@ -17,6 +17,7 @@ limitations under the License. package v1alpha1 import ( + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -36,8 +37,9 @@ type MeshsyncBroker struct { // MeshSyncSpec defines the desired state of MeshSync type MeshSyncSpec struct { - Size int32 `json:"size,omitempty" yaml:"size,omitempty"` - Broker MeshsyncBroker `json:"broker,omitempty" yaml:"broker,omitempty"` + Size int32 `json:"size,omitempty" yaml:"size,omitempty"` + Broker MeshsyncBroker `json:"broker,omitempty" yaml:"broker,omitempty"` + WatchList corev1.ConfigMap `json:"watch-list,omitempty" yaml:"watch-list,omitempty"` } // MeshSyncStatus defines the observed state of MeshSync diff --git a/api/v1alpha1/meshsync_types_test.go b/api/v1alpha1/meshsync_types_test.go index 868beca5..57a613f2 100644 --- a/api/v1alpha1/meshsync_types_test.go +++ b/api/v1alpha1/meshsync_types_test.go @@ -5,6 +5,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" @@ -51,6 +52,20 @@ var _ = Describe("The test case for the meshsync CRDs", func() { Name: "default", }, }, + WatchList: corev1.ConfigMap{ + TypeMeta: metav1.TypeMeta{ + APIVersion: "v1apha1", + Kind: "ConfigMap", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "watch-list", + Namespace: "default", + }, + Data: map[string]string{ + "blacklist": "", + "whitelist": "[{\"Resource\":\"namespaces.v1.\",\"Events\":[\"ADDED\",\"DELETE\"]},{\"Resource\":\"replicasets.v1.apps\",\"Events\":[\"ADDED\",\"DELETE\"]},{\"Resource\":\"pods.v1.\",\"Events\":[\"MODIFIED\"]}]", + }, + }, }, } @@ -77,6 +92,24 @@ var _ = Describe("The test case for the meshsync CRDs", func() { url := mesheSyncGet.Spec.Broker.Custom.URL Expect(url == URL).Should(BeTrue()) + By("Confirm the config matches the expected listener and pipeline configs") + configMap := mesheSyncGet.Spec.WatchList + Expect(configMap).ShouldNot(BeNil()) + expectedConfigMap := corev1.ConfigMap{ + TypeMeta: metav1.TypeMeta{ + APIVersion: "v1apha1", + Kind: "ConfigMap", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "watch-list", + Namespace: "default", + }, + Data: map[string]string{ + "blacklist": "", + "whitelist": "[{\"Resource\":\"namespaces.v1.\",\"Events\":[\"ADDED\",\"DELETE\"]},{\"Resource\":\"replicasets.v1.apps\",\"Events\":[\"ADDED\",\"DELETE\"]},{\"Resource\":\"pods.v1.\",\"Events\":[\"MODIFIED\"]}]", + }, + } + Expect(configMap).To(Equal(expectedConfigMap)) }) It("The meshsync CRDs update the spec of the resources", func() { diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 545ab7bb..071e494e 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -174,7 +174,7 @@ func (in *MeshSync) DeepCopyInto(out *MeshSync) { *out = *in out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Spec = in.Spec + in.Spec.DeepCopyInto(&out.Spec) in.Status.DeepCopyInto(&out.Status) } @@ -232,6 +232,7 @@ func (in *MeshSyncList) DeepCopyObject() runtime.Object { func (in *MeshSyncSpec) DeepCopyInto(out *MeshSyncSpec) { *out = *in out.Broker = in.Broker + in.WatchList.DeepCopyInto(&out.WatchList) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MeshSyncSpec. diff --git a/config/crd/bases/meshery.layer5.io_meshsyncs.yaml b/config/crd/bases/meshery.layer5.io_meshsyncs.yaml index 6e371e31..0cab1d62 100644 --- a/config/crd/bases/meshery.layer5.io_meshsyncs.yaml +++ b/config/crd/bases/meshery.layer5.io_meshsyncs.yaml @@ -53,6 +53,51 @@ spec: size: format: int32 type: integer + watch-list: + description: ConfigMap holds configuration data for pods to consume. + 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 + binaryData: + additionalProperties: + format: byte + type: string + description: BinaryData contains the binary data. Each key must + consist of alphanumeric characters, '-', '_' or '.'. BinaryData + can contain byte sequences that are not in the UTF-8 range. + The keys stored in BinaryData must not overlap with the ones + in the Data field, this is enforced during validation process. + Using this field will require 1.10+ apiserver and kubelet. + type: object + data: + additionalProperties: + type: string + description: Data contains the configuration data. Each key must + consist of alphanumeric characters, '-', '_' or '.'. Values + with non-UTF-8 byte sequences must use the BinaryData field. + The keys stored in Data must not overlap with the keys in the + BinaryData field, this is enforced during validation process. + type: object + immutable: + description: Immutable, if set to true, ensures that data stored + in the ConfigMap cannot be updated (only object metadata can + be modified). If not set to true, the field can be modified + at any time. Defaulted to nil. + type: boolean + 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: + description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata' + type: object + type: object type: object status: description: MeshSyncStatus defines the observed state of MeshSync diff --git a/config/samples/meshery_v1alpha1_meshsync.yaml b/config/samples/meshery_v1alpha1_meshsync.yaml index 243c8df8..13cf3406 100644 --- a/config/samples/meshery_v1alpha1_meshsync.yaml +++ b/config/samples/meshery_v1alpha1_meshsync.yaml @@ -14,4 +14,10 @@ spec: broker: native: name: meshery-broker - namespace: meshery \ No newline at end of file + namespace: meshery + watch-list: + apiVersion: v1 + data: + # Use either the blacklist or the whitelist for the moment + # blacklist: "[\"namespaces.v1.\",\"configmaps.v1.\",\"nodes.v1.\",\"secrets.v1.\",\"persistentvolumes.v1.\",\"persistentvolumeclaims.v1.\",\"replicasets.v1.apps\",\"pods.v1.\",\"services.v1.\",\"deployments.v1.apps\",\"statefulsets.v1.apps\",\"daemonsets.v1.apps\",\"ingresses.v1.networking.k8s.io\",\"endpoints.v1.\",\"endpointslices.v1.discovery.k8s.io\",\"cronjobs.v1.batch\",\"replicationcontrollers.v1.\",\"storageclasses.v1.storage.k8s.io\",\"clusterroles.v1.rbac.authorization.k8s.io\",\"volumeattachments.v1.storage.k8s.io\",\"apiservices.v1.apiregistration.k8s.io\"]" + whitelist: "[{\"Resource\":\"namespaces.v1.\",\"Events\":[\"ADDED\",\"MODIFIED\",\"DELETED\"]},{\"Resource\":\"configmaps.v1.\",\"Events\":[\"ADDED\",\"MODIFIED\",\"DELETED\"]},{\"Resource\":\"nodes.v1.\",\"Events\":[\"ADDED\",\"MODIFIED\",\"DELETED\"]},{\"Resource\":\"secrets.v1.\",\"Events\":[\"ADDED\",\"MODIFIED\",\"DELETED\"]},{\"Resource\":\"persistentvolumes.v1.\",\"Events\":[\"ADDED\",\"MODIFIED\",\"DELETED\"]},{\"Resource\":\"persistentvolumeclaims.v1.\",\"Events\":[\"ADDED\",\"MODIFIED\",\"DELETED\"]},{\"Resource\":\"replicasets.v1.apps\",\"Events\":[\"ADDED\",\"MODIFIED\",\"DELETED\"]},{\"Resource\":\"pods.v1.\",\"Events\":[\"ADDED\",\"MODIFIED\",\"DELETED\"]},{\"Resource\":\"services.v1.\",\"Events\":[\"ADDED\",\"MODIFIED\",\"DELETED\"]},{\"Resource\":\"deployments.v1.apps\",\"Events\":[\"ADDED\",\"MODIFIED\",\"DELETED\"]},{\"Resource\":\"statefulsets.v1.apps\",\"Events\":[\"ADDED\",\"MODIFIED\",\"DELETED\"]},{\"Resource\":\"daemonsets.v1.apps\",\"Events\":[\"ADDED\",\"MODIFIED\",\"DELETED\"]},{\"Resource\":\"ingresses.v1.networking.k8s.io\",\"Events\":[\"ADDED\",\"MODIFIED\",\"DELETED\"]},{\"Resource\":\"endpoints.v1.\",\"Events\":[\"ADDED\",\"MODIFIED\",\"DELETED\"]},{\"Resource\":\"endpointslices.v1.discovery.k8s.io\",\"Events\":[\"ADDED\",\"MODIFIED\",\"DELETED\"]},{\"Resource\":\"cronjobs.v1.batch\",\"Events\":[\"ADDED\",\"MODIFIED\",\"DELETED\"]},{\"Resource\":\"replicationcontrollers.v1.\",\"Events\":[\"ADDED\",\"MODIFIED\",\"DELETED\"]},{\"Resource\":\"storageclasses.v1.storage.k8s.io\",\"Events\":[\"ADDED\",\"MODIFIED\",\"DELETED\"]},{\"Resource\":\"clusterroles.v1.rbac.authorization.k8s.io\",\"Events\":[\"ADDED\",\"MODIFIED\",\"DELETED\"]},{\"Resource\":\"volumeattachments.v1.storage.k8s.io\",\"Events\":[\"ADDED\",\"MODIFIED\",\"DELETED\"]},{\"Resource\":\"apiservices.v1.apiregistration.k8s.io\",\"Events\":[\"ADDED\",\"MODIFIED\",\"DELETED\"]}]" diff --git a/go.mod b/go.mod index 86876592..aac54368 100644 --- a/go.mod +++ b/go.mod @@ -61,7 +61,7 @@ require ( github.com/rogpeppe/go-internal v1.11.0 // indirect github.com/spf13/pflag v1.0.5 // indirect go.uber.org/atomic v1.10.0 // indirect - go.uber.org/multierr v1.6.0 // indirect + go.uber.org/multierr v1.8.0 // indirect go.uber.org/zap v1.24.0 // indirect golang.org/x/net v0.17.0 // indirect golang.org/x/oauth2 v0.5.0 // indirect diff --git a/go.sum b/go.sum index dbbfb6cb..28975c2c 100644 --- a/go.sum +++ b/go.sum @@ -158,8 +158,9 @@ go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0 go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= go.uber.org/goleak v1.1.12 h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA= go.uber.org/goleak v1.1.12/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= -go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= +go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8= +go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= go.uber.org/zap v1.19.0/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg=