Skip to content

Commit

Permalink
Merge pull request #533 from KiptoonKipkurui/feat/kiptoonkipkurui/crd…
Browse files Browse the repository at this point in the history
…_config

Meshsync config on Meshery Operator CRD
  • Loading branch information
leecalcote authored Nov 20, 2023
2 parents 9828f7c + a9ca7f1 commit 1cb522d
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 4 additions & 2 deletions api/v1alpha1/meshsync_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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
Expand Down
33 changes: 33 additions & 0 deletions api/v1alpha1/meshsync_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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\"]}]",
},
},
},
}

Expand All @@ -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() {
Expand Down
3 changes: 2 additions & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions config/crd/bases/meshery.layer5.io_meshsyncs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion config/samples/meshery_v1alpha1_meshsync.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,10 @@ spec:
broker:
native:
name: meshery-broker
namespace: meshery
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\"]}]"
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down

0 comments on commit 1cb522d

Please sign in to comment.