Skip to content

Commit de81da9

Browse files
Review api (#21)
Signed-off-by: Tamal Saha <[email protected]> Signed-off-by: souravbiswassanto <[email protected]> Co-authored-by: souravbiswassanto <[email protected]>
1 parent 517c491 commit de81da9

File tree

90 files changed

+12212
-1104
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+12212
-1104
lines changed

apis/apps/v1/placementpolicy_types.go

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,36 @@ type PlacementPolicySpec struct {
6464
// +optional
6565
Affinity *Affinity `json:"affinity,omitempty"`
6666

67-
// OCM provides spec for distributed pod placements using open cluster management
67+
// ClusterSpreadConstraint provides spec for distributed pod placements
6868
// +optional
69-
OCM *OCMSpec `json:"ocm,omitempty"`
69+
ClusterSpreadConstraint *ClusterSpreadConstraint `json:"clusterSpreadConstraint,omitempty"`
7070
}
7171

72-
type OCMSpec struct {
73-
DistributionRules []DistributionRule `json:"distributionRules,omitempty"`
74-
SliceName string `json:"sliceName,omitempty"`
72+
// https://kubeslice.io/documentation/open-source/1.4.0/install-kubeslice/yaml/yaml-controller-install#create-project-namespace
73+
// https://kubeslice.io/documentation/open-source/1.4.0/install-kubeslice/yaml/slice-operations/slice-operations-slice-creation#serviceexport-dns
74+
75+
/*
76+
A cluster cannot be registered to multiple projects.
77+
The KubeSlice worker controller must be deployed in the kubeslice-system namespace.
78+
When a SliceConfig resource is created, KubeSlice generates a Slice resource in the kubeslice-system namespace across all clusters specified in the SliceConfig resource.
79+
When a sliceName is specified in a ServiceExport, the KubeSlice worker controller retrieves the Slice resource from the kubeslice-system namespace and verifies whether the namespace associated with the ServiceExport is onboarded.
80+
81+
So, the project field is not required in the placementPolicy API . But if want to validate whether the clusters specified in the placementPolicy are included in the SliceConfig's cluster list then we need to include the project name as well.
82+
*/
83+
type ClusterSpreadConstraint struct {
84+
DistributionRules []DistributionRule `json:"distributionRules"`
85+
Slice KubeSliceConfig `json:"slice"`
7586
}
7687

7788
type DistributionRule struct {
78-
ClusterName string `json:"clusterName,omitempty"`
79-
Replicas []int32 `json:"replicas,omitempty"`
89+
ClusterName string `json:"clusterName"`
90+
ReplicaIndices []int32 `json:"replicaIndices"`
91+
StorageClassName string `json:"storageClassName,omitempty"`
92+
}
93+
94+
type KubeSliceConfig struct {
95+
ProjectNamespace string `json:"projectNamespace"`
96+
SliceName string `json:"sliceName"`
8097
}
8198

8299
type ZoneSpreadConstraint struct {

apis/apps/v1/zz_generated.deepcopy.go

Lines changed: 45 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crds/apps.k8s.appscode.com_placementpolicies.yaml

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -87,37 +87,53 @@ spec:
8787
type: object
8888
type: array
8989
type: object
90-
nodeSpreadConstraint:
91-
properties:
92-
maxSkew:
93-
default: 1
94-
format: int32
95-
type: integer
96-
whenUnsatisfiable:
97-
default: DoNotSchedule
98-
type: string
99-
required:
100-
- maxSkew
101-
- whenUnsatisfiable
102-
type: object
103-
ocm:
104-
description: OCM provides spec for distributed pod placements using
105-
open cluster management
90+
clusterSpreadConstraint:
91+
description: ClusterSpreadConstraint provides spec for distributed
92+
pod placements
10693
properties:
10794
distributionRules:
10895
items:
10996
properties:
11097
clusterName:
11198
type: string
112-
replicas:
99+
replicaIndices:
113100
items:
114101
format: int32
115102
type: integer
116103
type: array
104+
storageClassName:
105+
type: string
106+
required:
107+
- clusterName
108+
- replicaIndices
117109
type: object
118110
type: array
119-
sliceName:
111+
slice:
112+
properties:
113+
projectNamespace:
114+
type: string
115+
sliceName:
116+
type: string
117+
required:
118+
- projectNamespace
119+
- sliceName
120+
type: object
121+
required:
122+
- distributionRules
123+
- slice
124+
type: object
125+
nodeSpreadConstraint:
126+
properties:
127+
maxSkew:
128+
default: 1
129+
format: int32
130+
type: integer
131+
whenUnsatisfiable:
132+
default: DoNotSchedule
120133
type: string
134+
required:
135+
- maxSkew
136+
- whenUnsatisfiable
121137
type: object
122138
zoneSpreadConstraint:
123139
properties:

go.mod

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
module kubeops.dev/petset
22

3-
go 1.23.6
4-
5-
toolchain go1.24.0
3+
go 1.24.0
64

75
require (
86
github.com/google/cel-go v0.22.0
97
github.com/google/go-cmp v0.7.0
108
github.com/google/gofuzz v1.2.0
9+
github.com/kubeslice/kubeslice-controller v1.8.2
1110
github.com/pkg/errors v0.9.1
1211
github.com/spf13/cobra v1.9.1
1312
github.com/spf13/pflag v1.0.6
@@ -28,13 +27,13 @@ require (
2827
kmodules.xyz/client-go v0.32.1
2928
kmodules.xyz/go-containerregistry v0.0.14
3029
open-cluster-management.io/api v1.0.0
31-
sigs.k8s.io/controller-runtime v0.20.3
30+
sigs.k8s.io/controller-runtime v0.20.4
3231
sigs.k8s.io/yaml v1.4.0
3332
)
3433

3534
require (
3635
cel.dev/expr v0.18.0 // indirect
37-
cloud.google.com/go v0.46.3 // indirect
36+
cloud.google.com/go/compute/metadata v0.6.0 // indirect
3837
github.com/Azure/azure-sdk-for-go v68.0.0+incompatible // indirect
3938
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
4039
github.com/Azure/go-autorest/autorest v0.11.29 // indirect
@@ -86,11 +85,13 @@ require (
8685
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
8786
github.com/go-logr/logr v1.4.2 // indirect
8887
github.com/go-logr/stdr v1.2.2 // indirect
88+
github.com/go-logr/zapr v1.3.0 // indirect
8989
github.com/go-openapi/jsonpointer v0.21.0 // indirect
9090
github.com/go-openapi/jsonreference v0.21.0 // indirect
9191
github.com/go-openapi/swag v0.23.0 // indirect
9292
github.com/gogo/protobuf v1.3.2 // indirect
9393
github.com/golang-jwt/jwt/v4 v4.5.1 // indirect
94+
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
9495
github.com/golang/protobuf v1.5.4 // indirect
9596
github.com/google/btree v1.1.3 // indirect
9697
github.com/google/gnostic-models v0.6.9 // indirect
@@ -100,11 +101,14 @@ require (
100101
github.com/google/uuid v1.6.0 // indirect
101102
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
102103
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
104+
github.com/imdario/mergo v0.3.16 // indirect
103105
github.com/inconshreveable/mousetrap v1.1.0 // indirect
104106
github.com/josharian/intern v1.0.0 // indirect
105107
github.com/json-iterator/go v1.1.12 // indirect
106108
github.com/klauspost/compress v1.17.11 // indirect
107-
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
109+
github.com/klauspost/cpuid/v2 v2.2.5 // indirect
110+
github.com/kubeslice/apis v0.3.0 // indirect
111+
github.com/kubeslice/kubeslice-monitoring v0.2.2 // indirect
108112
github.com/kylelemons/godebug v1.1.0 // indirect
109113
github.com/mailru/easyjson v0.9.0 // indirect
110114
github.com/mitchellh/go-homedir v1.1.0 // indirect
@@ -143,14 +147,14 @@ require (
143147
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
144148
go.uber.org/multierr v1.11.0 // indirect
145149
go.uber.org/zap v1.27.0 // indirect
146-
golang.org/x/crypto v0.35.0 // indirect
150+
golang.org/x/crypto v0.36.0 // indirect
147151
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
148-
golang.org/x/net v0.36.0 // indirect
152+
golang.org/x/net v0.38.0 // indirect
149153
golang.org/x/oauth2 v0.27.0 // indirect
150-
golang.org/x/sync v0.11.0 // indirect
151-
golang.org/x/sys v0.30.0 // indirect
152-
golang.org/x/term v0.29.0 // indirect
153-
golang.org/x/text v0.22.0 // indirect
154+
golang.org/x/sync v0.12.0 // indirect
155+
golang.org/x/sys v0.31.0 // indirect
156+
golang.org/x/term v0.30.0 // indirect
157+
golang.org/x/text v0.23.0 // indirect
154158
golang.org/x/time v0.10.0 // indirect
155159
golang.org/x/tools v0.30.0 // indirect
156160
gomodules.xyz/clock v0.0.0-20200817085942-06523dba733f // indirect
@@ -166,6 +170,7 @@ require (
166170
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
167171
gopkg.in/inf.v0 v0.9.1 // indirect
168172
gopkg.in/yaml.v3 v3.0.1 // indirect
173+
gotest.tools/v3 v3.5.1 // indirect
169174
k8s.io/cloud-provider v0.32.2 // indirect
170175
k8s.io/component-helpers v0.32.2 // indirect
171176
k8s.io/controller-manager v0.32.2 // indirect
@@ -182,3 +187,5 @@ replace sigs.k8s.io/controller-runtime => github.com/kmodules/controller-runtime
182187
replace github.com/imdario/mergo => github.com/imdario/mergo v0.3.6
183188

184189
replace k8s.io/apiserver => github.com/kmodules/apiserver v0.32.3-0.20250221062720-35dc674c7dd6
190+
191+
replace github.com/kubeslice/kubeslice-controller => github.com/kube-slice/kubeslice-controller v1.8.3-0.20250707180130-733b0dc20fe2

0 commit comments

Comments
 (0)