Skip to content

Commit 1cb522d

Browse files
authored
Merge pull request #533 from KiptoonKipkurui/feat/kiptoonkipkurui/crd_config
Meshsync config on Meshery Operator CRD
2 parents 9828f7c + a9ca7f1 commit 1cb522d

8 files changed

+95
-7
lines changed

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the manager binary
2-
FROM golang:1.19 as builder
2+
FROM golang:1.21 as builder
33

44
WORKDIR /workspace
55
# Copy the Go Modules manifests

api/v1alpha1/meshsync_types.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package v1alpha1
1818

1919
import (
20+
corev1 "k8s.io/api/core/v1"
2021
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2122
)
2223

@@ -36,8 +37,9 @@ type MeshsyncBroker struct {
3637

3738
// MeshSyncSpec defines the desired state of MeshSync
3839
type MeshSyncSpec struct {
39-
Size int32 `json:"size,omitempty" yaml:"size,omitempty"`
40-
Broker MeshsyncBroker `json:"broker,omitempty" yaml:"broker,omitempty"`
40+
Size int32 `json:"size,omitempty" yaml:"size,omitempty"`
41+
Broker MeshsyncBroker `json:"broker,omitempty" yaml:"broker,omitempty"`
42+
WatchList corev1.ConfigMap `json:"watch-list,omitempty" yaml:"watch-list,omitempty"`
4143
}
4244

4345
// MeshSyncStatus defines the observed state of MeshSync

api/v1alpha1/meshsync_types_test.go

+33
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55

66
. "github.com/onsi/ginkgo/v2"
77
. "github.com/onsi/gomega"
8+
corev1 "k8s.io/api/core/v1"
89
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
910
"k8s.io/apimachinery/pkg/types"
1011
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -51,6 +52,20 @@ var _ = Describe("The test case for the meshsync CRDs", func() {
5152
Name: "default",
5253
},
5354
},
55+
WatchList: corev1.ConfigMap{
56+
TypeMeta: metav1.TypeMeta{
57+
APIVersion: "v1apha1",
58+
Kind: "ConfigMap",
59+
},
60+
ObjectMeta: metav1.ObjectMeta{
61+
Name: "watch-list",
62+
Namespace: "default",
63+
},
64+
Data: map[string]string{
65+
"blacklist": "",
66+
"whitelist": "[{\"Resource\":\"namespaces.v1.\",\"Events\":[\"ADDED\",\"DELETE\"]},{\"Resource\":\"replicasets.v1.apps\",\"Events\":[\"ADDED\",\"DELETE\"]},{\"Resource\":\"pods.v1.\",\"Events\":[\"MODIFIED\"]}]",
67+
},
68+
},
5469
},
5570
}
5671

@@ -77,6 +92,24 @@ var _ = Describe("The test case for the meshsync CRDs", func() {
7792
url := mesheSyncGet.Spec.Broker.Custom.URL
7893
Expect(url == URL).Should(BeTrue())
7994

95+
By("Confirm the config matches the expected listener and pipeline configs")
96+
configMap := mesheSyncGet.Spec.WatchList
97+
Expect(configMap).ShouldNot(BeNil())
98+
expectedConfigMap := corev1.ConfigMap{
99+
TypeMeta: metav1.TypeMeta{
100+
APIVersion: "v1apha1",
101+
Kind: "ConfigMap",
102+
},
103+
ObjectMeta: metav1.ObjectMeta{
104+
Name: "watch-list",
105+
Namespace: "default",
106+
},
107+
Data: map[string]string{
108+
"blacklist": "",
109+
"whitelist": "[{\"Resource\":\"namespaces.v1.\",\"Events\":[\"ADDED\",\"DELETE\"]},{\"Resource\":\"replicasets.v1.apps\",\"Events\":[\"ADDED\",\"DELETE\"]},{\"Resource\":\"pods.v1.\",\"Events\":[\"MODIFIED\"]}]",
110+
},
111+
}
112+
Expect(configMap).To(Equal(expectedConfigMap))
80113
})
81114

82115
It("The meshsync CRDs update the spec of the resources", func() {

api/v1alpha1/zz_generated.deepcopy.go

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/meshery.layer5.io_meshsyncs.yaml

+45
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,51 @@ spec:
5353
size:
5454
format: int32
5555
type: integer
56+
watch-list:
57+
description: ConfigMap holds configuration data for pods to consume.
58+
properties:
59+
apiVersion:
60+
description: 'APIVersion defines the versioned schema of this
61+
representation of an object. Servers should convert recognized
62+
schemas to the latest internal value, and may reject unrecognized
63+
values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
64+
type: string
65+
binaryData:
66+
additionalProperties:
67+
format: byte
68+
type: string
69+
description: BinaryData contains the binary data. Each key must
70+
consist of alphanumeric characters, '-', '_' or '.'. BinaryData
71+
can contain byte sequences that are not in the UTF-8 range.
72+
The keys stored in BinaryData must not overlap with the ones
73+
in the Data field, this is enforced during validation process.
74+
Using this field will require 1.10+ apiserver and kubelet.
75+
type: object
76+
data:
77+
additionalProperties:
78+
type: string
79+
description: Data contains the configuration data. Each key must
80+
consist of alphanumeric characters, '-', '_' or '.'. Values
81+
with non-UTF-8 byte sequences must use the BinaryData field.
82+
The keys stored in Data must not overlap with the keys in the
83+
BinaryData field, this is enforced during validation process.
84+
type: object
85+
immutable:
86+
description: Immutable, if set to true, ensures that data stored
87+
in the ConfigMap cannot be updated (only object metadata can
88+
be modified). If not set to true, the field can be modified
89+
at any time. Defaulted to nil.
90+
type: boolean
91+
kind:
92+
description: 'Kind is a string value representing the REST resource
93+
this object represents. Servers may infer this from the endpoint
94+
the client submits requests to. Cannot be updated. In CamelCase.
95+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
96+
type: string
97+
metadata:
98+
description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata'
99+
type: object
100+
type: object
56101
type: object
57102
status:
58103
description: MeshSyncStatus defines the observed state of MeshSync

config/samples/meshery_v1alpha1_meshsync.yaml

+7-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,10 @@ spec:
1414
broker:
1515
native:
1616
name: meshery-broker
17-
namespace: meshery
17+
namespace: meshery
18+
watch-list:
19+
apiVersion: v1
20+
data:
21+
# Use either the blacklist or the whitelist for the moment
22+
# 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\"]"
23+
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\"]}]"

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ require (
6161
github.com/rogpeppe/go-internal v1.11.0 // indirect
6262
github.com/spf13/pflag v1.0.5 // indirect
6363
go.uber.org/atomic v1.10.0 // indirect
64-
go.uber.org/multierr v1.6.0 // indirect
64+
go.uber.org/multierr v1.8.0 // indirect
6565
go.uber.org/zap v1.24.0 // indirect
6666
golang.org/x/net v0.17.0 // indirect
6767
golang.org/x/oauth2 v0.5.0 // indirect

go.sum

+2-1
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,9 @@ go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0
158158
go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A=
159159
go.uber.org/goleak v1.1.12 h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA=
160160
go.uber.org/goleak v1.1.12/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
161-
go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4=
162161
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
162+
go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8=
163+
go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak=
163164
go.uber.org/zap v1.19.0/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI=
164165
go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60=
165166
go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg=

0 commit comments

Comments
 (0)