Skip to content

Commit

Permalink
support custom dummy image for 2 deploy mode init (#209)
Browse files Browse the repository at this point in the history
Signed-off-by: haorenfsa <[email protected]>
  • Loading branch information
haorenfsa authored Nov 19, 2024
1 parent 2daba53 commit f307f4b
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 12 deletions.
5 changes: 5 additions & 0 deletions apis/milvus.io/v1beta1/components_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ type MilvusComponents struct {
// +kubebuilder:validation:Optional
ToolImage string `json:"toolImage,omitempty"`

// DummyImage specify dummy image to use when creating an alternative deploy for rolling update
// when rollingMode is v2 or v3
// +kubebuilder:validation:Optional
DummyImage string `json:"dummyImage,omitempty"`

// UpdateToolImage when milvus-operator upgraded, whether milvus should restart to update the tool image, too
// otherwise, the tool image will be updated when milvus deploy's podTemplate changed
// +kubebuilder:validation:Optional
Expand Down
4 changes: 4 additions & 0 deletions charts/milvus-operator/templates/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1529,6 +1529,8 @@ spec:
type: boolean
dnsPolicy:
type: string
dummyImage:
type: string
enableManualMode:
type: boolean
enableRollingUpdate:
Expand Down Expand Up @@ -9156,6 +9158,8 @@ spec:
type: boolean
dnsPolicy:
type: string
dummyImage:
type: string
enableManualMode:
type: boolean
enableRollingUpdate:
Expand Down
2 changes: 2 additions & 0 deletions config/crd/bases/milvus.io_milvusclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1527,6 +1527,8 @@ spec:
type: boolean
dnsPolicy:
type: string
dummyImage:
type: string
enableManualMode:
type: boolean
enableRollingUpdate:
Expand Down
2 changes: 2 additions & 0 deletions config/crd/bases/milvus.io_milvuses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2505,6 +2505,8 @@ spec:
type: boolean
dnsPolicy:
type: string
dummyImage:
type: string
enableManualMode:
type: boolean
enableRollingUpdate:
Expand Down
4 changes: 4 additions & 0 deletions deploy/manifests/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1560,6 +1560,8 @@ spec:
type: boolean
dnsPolicy:
type: string
dummyImage:
type: string
enableManualMode:
type: boolean
enableRollingUpdate:
Expand Down Expand Up @@ -9188,6 +9190,8 @@ spec:
type: boolean
dnsPolicy:
type: string
dummyImage:
type: string
enableManualMode:
type: boolean
enableRollingUpdate:
Expand Down
9 changes: 6 additions & 3 deletions pkg/controllers/deploy_ctrl_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,12 @@ func formatComponentDeployName(mc v1beta1.Milvus, component MilvusComponent, gro
func (c *DeployControllerBizUtilImpl) CreateDeploy(ctx context.Context, mc v1beta1.Milvus, podTemplate *corev1.PodTemplateSpec, groupId int) error {
if podTemplate == nil {
podTemplate = c.RenderPodTemplateWithoutGroupID(mc, nil, c.component)
if groupId != 0 {
// is not the first deploy, set image to dummy to avoid rolling back and forth
podTemplate.Spec.Containers[0].Image = "dummy"
}
if groupId != 0 {
// is not the first deploy, set image to dummy to avoid rolling back and forth
podTemplate.Spec.Containers[0].Image = "dummy"
if mc.Spec.Com.DummyImage != "" {
podTemplate.Spec.Containers[0].Image = mc.Spec.Com.DummyImage
}
}

Expand Down
13 changes: 13 additions & 0 deletions pkg/controllers/deploy_ctrl_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,19 @@ func TestDeployControllerBizUtilImpl_CreateDeploy(t *testing.T) {
err := bizUtil.CreateDeploy(ctx, mc, nil, 1)
assert.NoError(t, err)
})

t.Run("groupId=1, image set to spec.componenents.dummyImage", func(t *testing.T) {
mc.Spec.Com.DummyImage = "my-registry/my-dummy-image"
mockcli.EXPECT().Scheme().Return(scheme).Times(3)
mockcli.EXPECT().Create(ctx, gomock.AssignableToTypeOf(new(appsv1.Deployment))).
DoAndReturn(func(ctx context.Context, obj client.Object, opt ...client.Options) error {
deploy := obj.(*appsv1.Deployment)
assert.Equal(t, mc.Spec.Com.DummyImage, deploy.Spec.Template.Spec.Containers[0].Image)
return nil
})
err := bizUtil.CreateDeploy(ctx, mc, nil, 1)
assert.NoError(t, err)
})
}

func TestDeployControllerBizUtilImpl_ShouldRollback(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions test/min-mc-feature.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ spec:
rollingMode: 3
runWithSubProcess: true
runAsNonRoot: true
dummyImage: 'my-registry/my-dummy-image'
proxy:
ingress:
hosts: ['mc-sit.milvus.io']
Expand Down
19 changes: 10 additions & 9 deletions test/min-milvus-feature.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ metadata:
labels:
app: milvus
spec:
mode: "standalone"
mode: 'standalone'
components:
rollingMode: 3
runWithSubProcess: true
dummyImage: 'my-registry/my-dummy-image'
standalone:
ingress:
hosts: ["mc-sit.milvus.io"]
hosts: ['mc-sit.milvus.io']
volumes:
- name: pulsar-token
secret:
Expand Down Expand Up @@ -91,18 +92,18 @@ spec:
auth:
authentication:
enabled: true
provider: "jwt"
provider: 'jwt'
jwt:
usingSecretKey: true
authorization:
enabled: true
superUsers:
# broker to broker communication
broker: "milvus"
broker: 'milvus'
# proxy to broker communication
proxy: "pulsar-proxy"
proxy: 'pulsar-proxy'
# pulsar-admin client to broker/proxy communication
client: ""
client: ''
volumes:
persistence: false
components:
Expand Down Expand Up @@ -153,9 +154,9 @@ spec:
configData:
PULSAR_MEM: >
-Xms64m -Xmx4096m -XX:MaxDirectMemorySize=8192m
managedLedgerDefaultEnsembleSize: "1"
managedLedgerDefaultWriteQuorum: "1"
managedLedgerDefaultAckQuorum: "1"
managedLedgerDefaultEnsembleSize: '1'
managedLedgerDefaultWriteQuorum: '1'
managedLedgerDefaultAckQuorum: '1'
proxy:
replicaCount: 1
autoscaling:
Expand Down

0 comments on commit f307f4b

Please sign in to comment.