Skip to content

Commit 64db68f

Browse files
authored
Support configuring the operatiom image in the vineyardd CR and update relevant doc (#1165)
* Support configuring the operation image in the vineyardd CR. * Update the relevant doc. * Generate the corresponding vineyard operator chart. Signed-off-by: Ye Cao <[email protected]>
1 parent 53b40e4 commit 64db68f

File tree

14 files changed

+204
-66
lines changed

14 files changed

+204
-66
lines changed

charts/vineyard-operator/templates/vineyardd-crd.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,30 @@ spec:
7070
default: IfNotPresent
7171
type: string
7272
type: object
73+
pluginConfig:
74+
default:
75+
backupImage: ghcr.io/v6d-io/v6d/backup-job
76+
daskRepartitionImage: ghcr.io/v6d-io/v6d/dask-repartition
77+
distributedAssemblyImage: ghcr.io/v6d-io/v6d/distributed-assembly
78+
localAssemblyImage: ghcr.io/v6d-io/v6d/local-assembly
79+
recoverImage: ghcr.io/v6d-io/v6d/recover-job
80+
properties:
81+
backupImage:
82+
default: ghcr.io/v6d-io/v6d/backup-job
83+
type: string
84+
daskRepartitionImage:
85+
default: ghcr.io/v6d-io/v6d/dask-repartition
86+
type: string
87+
distributedAssemblyImage:
88+
default: ghcr.io/v6d-io/v6d/distributed-assembly
89+
type: string
90+
localAssemblyImage:
91+
default: ghcr.io/v6d-io/v6d/local-assembly
92+
type: string
93+
recoverImage:
94+
default: ghcr.io/v6d-io/v6d/recover-job
95+
type: string
96+
type: object
7397
replicas:
7498
default: 3
7599
type: integer

docs/notes/vineyard-operator.rst

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -308,11 +308,41 @@ The detailed configuration entries for creating a vineyard cluster are listed as
308308
- The environment of vineyardd.
309309
- nil
310310

311-
* - | metricConfig.
312-
| enable
313-
- bool
314-
- Enable the metrics in vineyardd.
315-
- false
311+
* - | vineyardConfig.
312+
| env
313+
- []corev1.EnvVar
314+
- The environment of vineyardd.
315+
- nil
316+
317+
* - | pluginConfig.
318+
| backupImage
319+
- string
320+
- The image of backup operation
321+
- "ghcr.io/v6d-io/v6d/backup-job"
322+
323+
* - | pluginConfig.
324+
| recoverImage
325+
- string
326+
- The image of recover operation
327+
- "ghcr.io/v6d-io/v6d/recover-job"
328+
329+
* - | pluginConfig.
330+
| daskRepartitionImage
331+
- string
332+
- The image of dask repartition operation
333+
- "ghcr.io/v6d-io/v6d/dask-repartition"
334+
335+
* - | pluginConfig.
336+
| localAssemblyImage
337+
- string
338+
- The image of local assembly operation
339+
- "ghcr.io/v6d-io/v6d/local-assembly"
340+
341+
* - | pluginConfig.
342+
| distributedAssemblyImage
343+
- string
344+
- The image of distributed assembly operation
345+
- "ghcr.io/v6d-io/v6d/distributed-assembly"
316346

317347
* - | metricConfig.
318348
| image

k8s/apis/k8s/v1alpha1/vineyardd_types.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,35 @@ type VineyardContainerConfig struct {
167167
Env []corev1.EnvVar `json:"env,omitempty"`
168168
}
169169

170+
// PluginImageConfig holds all image configuration about pluggable drivers(backup, recover,
171+
// local assembly, distributed assembly, repartition)
172+
type PluginImageConfig struct {
173+
// the image of backup operation
174+
// +kubebuilder:validation:Optional
175+
// +kubebuilder:default:="ghcr.io/v6d-io/v6d/backup-job"
176+
BackupImage string `json:"backupImage,omitempty"`
177+
178+
// the image of recover operation
179+
// +kubebuilder:validation:Optional
180+
// +kubebuilder:default:="ghcr.io/v6d-io/v6d/recover-job"
181+
RecoverImage string `json:"recoverImage,omitempty"`
182+
183+
// the image of dask repartition operation
184+
// +kubebuilder:validation:Optional
185+
// +kubebuilder:default:="ghcr.io/v6d-io/v6d/dask-repartition"
186+
DaskRepartitionImage string `json:"daskRepartitionImage,omitempty"`
187+
188+
// the image of local assembly operation
189+
// +kubebuilder:validation:Optional
190+
// +kubebuilder:default:="ghcr.io/v6d-io/v6d/local-assembly"
191+
LocalAssemblyImage string `json:"localAssemblyImage,omitempty"`
192+
193+
// the image of distributed assembly operation
194+
// +kubebuilder:validation:Optional
195+
// +kubebuilder:default:="ghcr.io/v6d-io/v6d/distributed-assembly"
196+
DistributedAssemblyImage string `json:"distributedAssemblyImage,omitempty"`
197+
}
198+
170199
// VineyarddSpec holds all configuration about vineyardd
171200
type VineyarddSpec struct {
172201
// the replicas of vineyardd
@@ -190,6 +219,12 @@ type VineyarddSpec struct {
190219
// +kubebuilder:default:={image: "vineyardcloudnative/vineyardd:latest", imagePullPolicy: "IfNotPresent", syncCRDs: true, socket: "/var/run/vineyard-kubernetes/{{.Namespace}}/{{.Name}}", size: "256Mi", streamThreshold: 80, etcdEndpoint: "http://etcd-for-vineyard:2379", etcdPrefix: "/vineyard"}
191220
VineyardConfig VineyardContainerConfig `json:"vineyardConfig,omitempty"`
192221

222+
// operation container configuration
223+
// +kubebuilder:validation:Optional
224+
//nolint: lll
225+
// +kubebuilder:default={backupImage: "ghcr.io/v6d-io/v6d/backup-job", recoverImage: "ghcr.io/v6d-io/v6d/recover-job", daskRepartitionImage: "ghcr.io/v6d-io/v6d/dask-repartition", localAssemblyImage: "ghcr.io/v6d-io/v6d/local-assembly", distributedAssemblyImage: "ghcr.io/v6d-io/v6d/distributed-assembly"}
226+
PluginConfig PluginImageConfig `json:"pluginConfig,omitempty"`
227+
193228
// metric container configuration
194229
// +kubebuilder:validation:Optional
195230
// +kubebuilder:default:={enable: false, image: "vineyardcloudnative/vineyard-grok-exporter:latest", imagePullPolicy: "IfNotPresent"}

k8s/config/crd/bases/k8s.v6d.io_vineyardds.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,30 @@ spec:
5858
default: IfNotPresent
5959
type: string
6060
type: object
61+
pluginConfig:
62+
default:
63+
backupImage: ghcr.io/v6d-io/v6d/backup-job
64+
daskRepartitionImage: ghcr.io/v6d-io/v6d/dask-repartition
65+
distributedAssemblyImage: ghcr.io/v6d-io/v6d/distributed-assembly
66+
localAssemblyImage: ghcr.io/v6d-io/v6d/local-assembly
67+
recoverImage: ghcr.io/v6d-io/v6d/recover-job
68+
properties:
69+
backupImage:
70+
default: ghcr.io/v6d-io/v6d/backup-job
71+
type: string
72+
daskRepartitionImage:
73+
default: ghcr.io/v6d-io/v6d/dask-repartition
74+
type: string
75+
distributedAssemblyImage:
76+
default: ghcr.io/v6d-io/v6d/distributed-assembly
77+
type: string
78+
localAssemblyImage:
79+
default: ghcr.io/v6d-io/v6d/local-assembly
80+
type: string
81+
recoverImage:
82+
default: ghcr.io/v6d-io/v6d/recover-job
83+
type: string
84+
type: object
6185
replicas:
6286
default: 3
6387
type: integer

k8s/config/manager/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1
44
kind: Kustomization
55
images:
66
- name: controller
7-
newName: localhost:5001/vineyard-operator
7+
newName: vineyardcloudnative/vineyard-operator
88
newTag: latest

k8s/controllers/k8s/operation_controller.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ type OperationReconciler struct {
5555
// +kubebuilder:rbac:groups="",resources=pods/status,verbs=get;list;watch;create;update;patch
5656
// +kubebuilder:rbac:groups="",resources=pods/log,verbs=get
5757
// +kubebuilder:rbac:groups="",resources=configmaps,verbs=get;list;watch;create;update;patch;delete
58+
// +kubebuilder:rbac:groups=k8s.v6d.io,resources=vineyardds,verbs=get;list;watch;create;update;patch;delete
5859

5960
// Reconcile reconciles the operation
6061
func (r *OperationReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
@@ -64,7 +65,7 @@ func (r *OperationReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
6465
if err := r.Client.Get(ctx, req.NamespacedName, &op); err != nil {
6566
return ctrl.Result{}, client.IgnoreNotFound(err)
6667
}
67-
logger.Info("Reconciling Operation", "vineyardd", op)
68+
logger.Info("Reconciling Operation", "operation", op)
6869

6970
app := kubernetes.Application{
7071
Client: r.Client,

k8s/pkg/operation/assembly.go

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,25 +52,27 @@ type AssemblyOperation struct {
5252

5353
// LocalAssemblyConfig is the config for the local assembly job
5454
type LocalAssemblyConfig struct {
55-
Name string
56-
Namespace string
57-
StreamID string
58-
JobName string
59-
NodeName string
60-
TimeoutSeconds int64
61-
VineyardSockPath string
55+
Name string
56+
Namespace string
57+
StreamID string
58+
JobName string
59+
NodeName string
60+
TimeoutSeconds int64
61+
VineyardSockPath string
62+
LocalAssemblyImage string
6263
}
6364

6465
// DistributedAssemblyConfig is the config for the distributed assembly job
6566
type DistributedAssemblyConfig struct {
66-
Name string
67-
Namespace string
68-
StreamID string
69-
JobName string
70-
GlobalObjectID string
71-
OldObjectToNewObject string
72-
TimeoutSeconds int64
73-
VineyardSockPath string
67+
Name string
68+
Namespace string
69+
StreamID string
70+
JobName string
71+
GlobalObjectID string
72+
OldObjectToNewObject string
73+
TimeoutSeconds int64
74+
VineyardSockPath string
75+
DistributedAssemblyImage string
7476
}
7577

7678
// LocalAssemblyConfigTemplate is the template config for the assembly job
@@ -146,6 +148,18 @@ func (ao *AssemblyOperation) findNeedAssemblyPodByLocalObject(ctx context.Contex
146148
// buildLocalAssemblyJob build all configuration for the local assembly job
147149
func (ao *AssemblyOperation) buildLocalAssemblyJob(ctx context.Context, localObject *v1alpha1.LocalObject, pod *corev1.Pod, timeout int64) error {
148150
podLabels := pod.Labels
151+
152+
vineyarddName := podLabels[labels.VineyarddName]
153+
vineyarddNamespace := podLabels[labels.VineyarddNamespace]
154+
// get vineyardd cluster info
155+
vineyardd := &v1alpha1.Vineyardd{}
156+
if err := ao.Client.Get(ctx, client.ObjectKey{
157+
Name: vineyarddName,
158+
Namespace: vineyarddNamespace,
159+
}, vineyardd); err != nil {
160+
return fmt.Errorf("failed to get the vineyardd: %v", err)
161+
}
162+
149163
// When the pod which generated the stream is annotated, the assembly job will be created in the same pod
150164
if _, ok := podLabels[NeedInjectedAssemblyKey]; ok {
151165
if strings.Contains(strings.ToLower(localObject.Spec.Typename), "stream") {
@@ -155,6 +169,7 @@ func (ao *AssemblyOperation) buildLocalAssemblyJob(ctx context.Context, localObj
155169
LocalAssemblyConfigTemplate.NodeName = localObject.Spec.Hostname
156170
LocalAssemblyConfigTemplate.JobName = podLabels[labels.VineyardJobName]
157171
LocalAssemblyConfigTemplate.TimeoutSeconds = timeout
172+
LocalAssemblyConfigTemplate.LocalAssemblyImage = vineyardd.Spec.PluginConfig.LocalAssemblyImage
158173
if socket, err := ao.ResolveRequiredVineyarddSocket(
159174
ctx,
160175
podLabels[labels.VineyarddName],
@@ -286,6 +301,17 @@ func (ao *AssemblyOperation) buildDistributedAssemblyJob(
286301
}
287302
}
288303

304+
vineyarddName := podLabels[labels.VineyarddName]
305+
vineyarddNamespace := podLabels[labels.VineyarddNamespace]
306+
// get vineyardd cluster info
307+
vineyardd := &v1alpha1.Vineyardd{}
308+
if err := ao.Client.Get(ctx, client.ObjectKey{
309+
Name: vineyarddName,
310+
Namespace: vineyarddNamespace,
311+
}, vineyardd); err != nil {
312+
return false, fmt.Errorf("failed to get the vineyardd: %v", err)
313+
}
314+
289315
// build the distributed assembly job
290316
if len(sigToID) == len(oldObjectToNewObject) {
291317
str := `'{`
@@ -299,6 +325,7 @@ func (ao *AssemblyOperation) buildDistributedAssemblyJob(
299325
DistributedAssemblyConfigTemplate.OldObjectToNewObject = str
300326
DistributedAssemblyConfigTemplate.JobName = podLabels[labels.VineyardJobName]
301327
DistributedAssemblyConfigTemplate.TimeoutSeconds = timeout
328+
DistributedAssemblyConfigTemplate.DistributedAssemblyImage = vineyardd.Spec.PluginConfig.DistributedAssemblyImage
302329
if socket, err := ao.ResolveRequiredVineyarddSocket(
303330
ctx,
304331
podLabels[labels.VineyarddName],

k8s/pkg/operation/repartition.go

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,16 @@ type RepartitionOperation struct {
5555

5656
// DaskRepartitionConfig is the config for the dask repartition job
5757
type DaskRepartitionConfig struct {
58-
Name string
59-
Namespace string
60-
GlobalObjectID string
61-
Replicas string
62-
InstanceToWorker string
63-
DaskScheduler string
64-
JobName string
65-
TimeoutSeconds int64
66-
VineyardSockPath string
58+
Name string
59+
Namespace string
60+
GlobalObjectID string
61+
Replicas string
62+
InstanceToWorker string
63+
DaskScheduler string
64+
JobName string
65+
TimeoutSeconds int64
66+
VineyardSockPath string
67+
DaskRepartitionImage string
6768
}
6869

6970
// DaskRepartitionConfigTemplate is the template config for the dask repartition job
@@ -173,6 +174,17 @@ func (ro *RepartitionOperation) buildDaskRepartitionJob(ctx context.Context, glo
173174
return fmt.Errorf("failed to get replicas from target jobs")
174175
}
175176

177+
vineyarddName := pod.Labels[labels.VineyarddName]
178+
vineyarddNamespace := pod.Labels[labels.VineyarddNamespace]
179+
// get vineyardd cluster info
180+
vineyardd := &v1alpha1.Vineyardd{}
181+
if err := ro.Client.Get(ctx, client.ObjectKey{
182+
Name: vineyarddName,
183+
Namespace: vineyarddNamespace,
184+
}, vineyardd); err != nil {
185+
return fmt.Errorf("failed to get the vineyardd: %v", err)
186+
}
187+
176188
DaskRepartitionConfigTemplate.Replicas = "'" + replicas + "'"
177189
DaskRepartitionConfigTemplate.Name = RepartitionPrefix + globalObject.Name
178190
DaskRepartitionConfigTemplate.Namespace = pod.Namespace
@@ -181,6 +193,7 @@ func (ro *RepartitionOperation) buildDaskRepartitionJob(ctx context.Context, glo
181193
DaskRepartitionConfigTemplate.JobName = pod.Labels[labels.VineyardJobName]
182194
DaskRepartitionConfigTemplate.InstanceToWorker = instanceToWorker
183195
DaskRepartitionConfigTemplate.TimeoutSeconds = o.Spec.TimeoutSeconds
196+
DaskRepartitionConfigTemplate.DaskRepartitionImage = vineyardd.Spec.PluginConfig.DaskRepartitionImage
184197
if socket, err := ro.ResolveRequiredVineyarddSocket(
185198
ctx,
186199
pod.Labels[labels.VineyarddName],

k8s/pkg/templates/operation/dask-repartition.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ spec:
2525
spec:
2626
containers:
2727
- name: dask-repartition-operation
28-
image: ghcr.io/v6d-io/v6d/dask-repartition
28+
image: {{ $config.DaskRepartitionImage }}
2929
imagePullPolicy: IfNotPresent
3030
env:
3131
- name: GLOBALOBJECT_ID

k8s/pkg/templates/operation/distributed-assembly-job.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ spec:
2525
spec:
2626
containers:
2727
- name: assembly-operation
28-
image: ghcr.io/v6d-io/v6d/distributed-assembly
28+
image: {{ $config.DistributedAssemblyImage}}
2929
imagePullPolicy: IfNotPresent
3030
env:
3131
- name: GLOBALOBJECT_ID

0 commit comments

Comments
 (0)