Repository: fluid-cloudnative/fluid
Pull request #3981 (2024-04-26 05:57:29)

Support to configure the networkMode and podMetadata of vineyard components.
### Ⅰ. Describe what this PR does

Part of https://github.com/fluid-cloudnative/fluid/pull/3749

fluid-e2e-bot[bot]: [APPROVALNOTIFIER] This PR is **NOT APPROVED**

This pull-request has been approved by:
**Once this PR has been reviewed and has the lgtm label**, please assign cheyang for approval by writing `/assign @cheyang` in a comment. For more information see:[The Kubernetes Code Review Process](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process).

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=fluid-cloudnative%2Ffluid).

<details open>
Needs approval from an approver in each of these files:

- **[OWNERS](https://github.com/fluid-cloudnative/fluid/blob/master/OWNERS)**

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":["cheyang"]} -->
fluid-e2e-bot[bot]: Hi @dashanji. Thanks for your PR.

I'm waiting for a [fluid-cloudnative](https://github.com/orgs/fluid-cloudnative/people) member to verify that this patch is reasonable to test. If it is, they should reply with `/ok-to-test` on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should [join the org](https://github.com/orgs/fluid-cloudnative/people) to skip this step.

Once the patch is verified, the new status will be reflected by the `ok-to-test` label.

I understand the commands that are listed [here](https://go.k8s.io/bot-commands?repo=fluid-cloudnative%2Ffluid).

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
</details>

sonarcloud[bot]: ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=fluid-cloudnative_fluid&pullRequest=3981) **Quality Gate passed**  
Issues  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [8 New issues](https://sonarcloud.io/project/issues?id=fluid-cloudnative_fluid&pullRequest=3981&resolved=false&inNewCodePeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/component_measures?id=fluid-cloudnative_fluid&pullRequest=3981&metric=new_accepted_issues&view=list)

Measures  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=fluid-cloudnative_fluid&pullRequest=3981&resolved=false&inNewCodePeriod=true)  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/no-data-16px.png '') No data about Coverage  
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [20.2% Duplication on New Code](https://sonarcloud.io/component_measures?id=fluid-cloudnative_fluid&pullRequest=3981&metric=new_duplicated_lines_density&view=list)  
  
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=fluid-cloudnative_fluid&pullRequest=3981)


fluid-e2e-bot[bot]: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/fluid-cloudnative/fluid/pull/3981#pullrequestreview-2026483897" title="Approved">cheyang</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=fluid-cloudnative%2Ffluid).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/fluid-cloudnative/fluid/blob/master/OWNERS)~~ [cheyang]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->

Patch:
diff --git a/api/v1alpha1/openapi_generated.go b/api/v1alpha1/openapi_generated.go
index 4e3d0c43..0917d91f 100644
--- a/api/v1alpha1/openapi_generated.go
+++ b/api/v1alpha1/openapi_generated.go
@@ -4598,6 +4598,20 @@ func schema_fluid_cloudnative_fluid_api_v1alpha1_MasterSpec(ref common.Reference
 							},
 						},
 					},
+					"podMetadata": {
+						SchemaProps: spec.SchemaProps{
+							Description: "PodMetadata defines labels and annotations that will be propagated to Vineyard's pods including Master and Worker. Default is not set.",
+							Default:     map[string]interface{}{},
+							Ref:         ref("github.com/fluid-cloudnative/fluid/api/v1alpha1.PodMetadata"),
+						},
+					},
+					"networkMode": {
+						SchemaProps: spec.SchemaProps{
+							Description: "Whether to use hostnetwork or not Default is HostNetwork",
+							Type:        []string{"string"},
+							Format:      "",
+						},
+					},
 					"endpoint": {
 						SchemaProps: spec.SchemaProps{
 							Description: "ExternalEndpoint defines the configurations for external etcd cluster Default is not set If set, the Vineyard Master component will not be deployed, which means the Vineyard Worker component will use an external Etcd cluster. E,g.\n  endpoint:\n    uri: \"etcd-svc.etcd-namespace.svc.cluster.local:2379\"\n    encryptOptions:\n      - name: access-key\n\t\t   valueFrom:\n          secretKeyRef:\n            name: etcd-secret\n\t\t\t   key: accesskey",
@@ -4609,7 +4623,7 @@ func schema_fluid_cloudnative_fluid_api_v1alpha1_MasterSpec(ref common.Reference
 			},
 		},
 		Dependencies: []string{
-			"github.com/fluid-cloudnative/fluid/api/v1alpha1.ExternalEndpointSpec", "k8s.io/api/core/v1.ResourceRequirements", "k8s.io/api/core/v1.VolumeMount"},
+			"github.com/fluid-cloudnative/fluid/api/v1alpha1.ExternalEndpointSpec", "github.com/fluid-cloudnative/fluid/api/v1alpha1.PodMetadata", "k8s.io/api/core/v1.ResourceRequirements", "k8s.io/api/core/v1.VolumeMount"},
 	}
 }
 
@@ -6510,11 +6524,25 @@ func schema_fluid_cloudnative_fluid_api_v1alpha1_VineyardCompTemplateSpec(ref co
 							},
 						},
 					},
+					"podMetadata": {
+						SchemaProps: spec.SchemaProps{
+							Description: "PodMetadata defines labels and annotations that will be propagated to Vineyard's pods including Master and Worker. Default is not set.",
+							Default:     map[string]interface{}{},
+							Ref:         ref("github.com/fluid-cloudnative/fluid/api/v1alpha1.PodMetadata"),
+						},
+					},
+					"networkMode": {
+						SchemaProps: spec.SchemaProps{
+							Description: "Whether to use hostnetwork or not Default is HostNetwork",
+							Type:        []string{"string"},
+							Format:      "",
+						},
+					},
 				},
 			},
 		},
 		Dependencies: []string{
-			"k8s.io/api/core/v1.ResourceRequirements", "k8s.io/api/core/v1.VolumeMount"},
+			"github.com/fluid-cloudnative/fluid/api/v1alpha1.PodMetadata", "k8s.io/api/core/v1.ResourceRequirements", "k8s.io/api/core/v1.VolumeMount"},
 	}
 }
 
@@ -6663,6 +6691,13 @@ func schema_fluid_cloudnative_fluid_api_v1alpha1_VineyardRuntimeSpec(ref common.
 							Format:      "",
 						},
 					},
+					"podMetadata": {
+						SchemaProps: spec.SchemaProps{
+							Description: "PodMetadata defines labels and annotations that will be propagated to Vineyard's pods.",
+							Default:     map[string]interface{}{},
+							Ref:         ref("github.com/fluid-cloudnative/fluid/api/v1alpha1.PodMetadata"),
+						},
+					},
 					"volumes": {
 						SchemaProps: spec.SchemaProps{
 							Description: "Volumes is the list of Kubernetes volumes that can be mounted by the vineyard components (Master and Worker). Default is null.",
@@ -6681,7 +6716,7 @@ func schema_fluid_cloudnative_fluid_api_v1alpha1_VineyardRuntimeSpec(ref common.
 			},
 		},
 		Dependencies: []string{
-			"github.com/fluid-cloudnative/fluid/api/v1alpha1.MasterSpec", "github.com/fluid-cloudnative/fluid/api/v1alpha1.TieredStore", "github.com/fluid-cloudnative/fluid/api/v1alpha1.VineyardCompTemplateSpec", "github.com/fluid-cloudnative/fluid/api/v1alpha1.VineyardSockSpec", "k8s.io/api/core/v1.Volume"},
+			"github.com/fluid-cloudnative/fluid/api/v1alpha1.MasterSpec", "github.com/fluid-cloudnative/fluid/api/v1alpha1.PodMetadata", "github.com/fluid-cloudnative/fluid/api/v1alpha1.TieredStore", "github.com/fluid-cloudnative/fluid/api/v1alpha1.VineyardCompTemplateSpec", "github.com/fluid-cloudnative/fluid/api/v1alpha1.VineyardSockSpec", "k8s.io/api/core/v1.Volume"},
 	}
 }
 
@@ -6743,11 +6778,25 @@ func schema_fluid_cloudnative_fluid_api_v1alpha1_VineyardSockSpec(ref common.Ref
 							Ref:         ref("k8s.io/api/core/v1.ResourceRequirements"),
 						},
 					},
+					"networkMode": {
+						SchemaProps: spec.SchemaProps{
+							Description: "Whether to use hostnetwork or not Default is HostNetwork",
+							Type:        []string{"string"},
+							Format:      "",
+						},
+					},
+					"podMetadata": {
+						SchemaProps: spec.SchemaProps{
+							Description: "PodMetadata defines labels and annotations that will be propagated to Vineyard's pods.",
+							Default:     map[string]interface{}{},
+							Ref:         ref("github.com/fluid-cloudnative/fluid/api/v1alpha1.PodMetadata"),
+						},
+					},
 				},
 			},
 		},
 		Dependencies: []string{
-			"k8s.io/api/core/v1.ResourceRequirements"},
+			"github.com/fluid-cloudnative/fluid/api/v1alpha1.PodMetadata", "k8s.io/api/core/v1.ResourceRequirements"},
 	}
 }
 
diff --git a/api/v1alpha1/swagger.json b/api/v1alpha1/swagger.json
index 92dcbb4d..e159aa0d 100644
--- a/api/v1alpha1/swagger.json
+++ b/api/v1alpha1/swagger.json
@@ -2499,7 +2499,11 @@
           "type": "string"
         },
         "imageTag": {
-          "description": "The image tag of Vineyard component. For Master, the default image tag is `3.5.10`. For Worker, the default image tag is `latest`.",
+          "description": "The image tag of Vineyard component. For Master, the default image tag is `3.5.10`. For Worker, the default image tag is `v0.21.5`.",
+          "type": "string"
+        },
+        "networkMode": {
+          "description": "Whether to use hostnetwork or not Default is HostNetwork",
           "type": "string"
         },
         "nodeSelector": {
@@ -2518,6 +2522,11 @@
             "default": ""
           }
         },
+        "podMetadata": {
+          "description": "PodMetadata defines labels and annotations that will be propagated to Vineyard's pods including Master and Worker. Default is not set.",
+          "default": {},
+          "$ref": "#/definitions/.PodMetadata"
+        },
         "ports": {
           "description": "Ports used by Vineyard component. For Master, the default client port is 2379 and peer port is 2380. For Worker, the default rpc port is 9600 and the default exporter port is 9144.",
           "type": "object",
@@ -3616,7 +3625,11 @@
           "type": "string"
         },
         "imageTag": {
-          "description": "The image tag of Vineyard component. For Master, the default image tag is `3.5.10`. For Worker, the default image tag is `latest`.",
+          "description": "The image tag of Vineyard component. For Master, the default image tag is `3.5.10`. For Worker, the default image tag is `v0.21.5`.",
+          "type": "string"
+        },
+        "networkMode": {
+          "description": "Whether to use hostnetwork or not Default is HostNetwork",
           "type": "string"
         },
         "nodeSelector": {
@@ -3635,6 +3648,11 @@
             "default": ""
           }
         },
+        "podMetadata": {
+          "description": "PodMetadata defines labels and annotations that will be propagated to Vineyard's pods including Master and Worker. Default is not set.",
+          "default": {},
+          "$ref": "#/definitions/.PodMetadata"
+        },
         "ports": {
           "description": "Ports used by Vineyard component. For Master, the default client port is 2379 and peer port is 2380. For Worker, the default rpc port is 9600 and the default exporter port is 9144.",
           "type": "object",
@@ -3736,6 +3754,11 @@
           "default": {},
           "$ref": "#/definitions/.MasterSpec"
         },
+        "podMetadata": {
+          "description": "PodMetadata defines labels and annotations that will be propagated to Vineyard's pods.",
+          "default": {},
+          "$ref": "#/definitions/.PodMetadata"
+        },
         "replicas": {
           "description": "The replicas of the worker, need to be specified If worker.replicas and the field are both specified, the field will be respected",
           "type": "integer",
@@ -3786,9 +3809,18 @@
           "type": "string"
         },
         "imageTag": {
-          "description": "Image Tag for Vineyard Fuse Default is `latest`",
+          "description": "Image Tag for Vineyard Fuse Default is `v0.21.5`",
+          "type": "string"
+        },
+        "networkMode": {
+          "description": "Whether to use hostnetwork or not Default is HostNetwork",
           "type": "string"
         },
+        "podMetadata": {
+          "description": "PodMetadata defines labels and annotations that will be propagated to Vineyard's pods.",
+          "default": {},
+          "$ref": "#/definitions/.PodMetadata"
+        },
         "resources": {
           "description": "Resources contains the resource requirements and limits for the Vineyard Fuse. Default is not set.",
           "default": {},
diff --git a/api/v1alpha1/vineyardruntime_types.go b/api/v1alpha1/vineyardruntime_types.go
index 659fbb81..2c9b30f8 100644
--- a/api/v1alpha1/vineyardruntime_types.go
+++ b/api/v1alpha1/vineyardruntime_types.go
@@ -95,6 +95,17 @@ type VineyardCompTemplateSpec struct {
 	// Default is not set.
 	// +optional
 	VolumeMounts []corev1.VolumeMount `json:"volumeMounts,omitempty"`
+
+	// PodMetadata defines labels and annotations that will be propagated to Vineyard's pods including Master and Worker.
+	// Default is not set.
+	// +optional
+	PodMetadata PodMetadata `json:"podMetadata,omitempty"`
+
+	// Whether to use hostnetwork or not
+	// Default is HostNetwork
+	// +kubebuilder:validation:Enum=HostNetwork;"";ContainerNetwork
+	// +optional
+	NetworkMode NetworkMode `json:"networkMode,omitempty"`
 }
 
 // ExternalEndpointSpec defines the configurations for external etcd cluster
@@ -174,6 +185,16 @@ type VineyardSockSpec struct {
 	// Default is not set.
 	// +optional
 	Resources corev1.ResourceRequirements `json:"resources,omitempty"`
+
+	// Whether to use hostnetwork or not
+	// Default is HostNetwork
+	// +kubebuilder:validation:Enum=HostNetwork;"";ContainerNetwork
+	// +optional
+	NetworkMode NetworkMode `json:"networkMode,omitempty"`
+
+	// PodMetadata defines labels and annotations that will be propagated to Vineyard's pods.
+	// +optional
+	PodMetadata PodMetadata `json:"podMetadata,omitempty"`
 }
 
 // VineyardRuntimeSpec defines the desired state of VineyardRuntime
@@ -232,6 +253,10 @@ type VineyardRuntimeSpec struct {
 	// +optional
 	DisablePrometheus bool `json:"disablePrometheus,omitempty"`
 
+	// PodMetadata defines labels and annotations that will be propagated to Vineyard's pods.
+	// +optional
+	PodMetadata PodMetadata `json:"podMetadata,omitempty"`
+
 	// Volumes is the list of Kubernetes volumes that can be mounted by the vineyard components (Master and Worker).
 	// Default is null.
 	// +optional
diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go
index fccd1842..115d31b8 100644
--- a/api/v1alpha1/zz_generated.deepcopy.go
+++ b/api/v1alpha1/zz_generated.deepcopy.go
@@ -2808,6 +2808,7 @@ func (in *VineyardCompTemplateSpec) DeepCopyInto(out *VineyardCompTemplateSpec)
 			(*in)[i].DeepCopyInto(&(*out)[i])
 		}
 	}
+	in.PodMetadata.DeepCopyInto(&out.PodMetadata)
 }
 
 // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VineyardCompTemplateSpec.
@@ -2886,6 +2887,7 @@ func (in *VineyardRuntimeSpec) DeepCopyInto(out *VineyardRuntimeSpec) {
 	in.Worker.DeepCopyInto(&out.Worker)
 	in.Fuse.DeepCopyInto(&out.Fuse)
 	in.TieredStore.DeepCopyInto(&out.TieredStore)
+	in.PodMetadata.DeepCopyInto(&out.PodMetadata)
 	if in.Volumes != nil {
 		in, out := &in.Volumes, &out.Volumes
 		*out = make([]v1.Volume, len(*in))
@@ -2916,6 +2918,7 @@ func (in *VineyardSockSpec) DeepCopyInto(out *VineyardSockSpec) {
 		}
 	}
 	in.Resources.DeepCopyInto(&out.Resources)
+	in.PodMetadata.DeepCopyInto(&out.PodMetadata)
 }
 
 // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VineyardSockSpec.
diff --git a/charts/fluid/fluid/crds/data.fluid.io_vineyardruntimes.yaml b/charts/fluid/fluid/crds/data.fluid.io_vineyardruntimes.yaml
index 1ecd7d60..b745e0aa 100644
--- a/charts/fluid/fluid/crds/data.fluid.io_vineyardruntimes.yaml
+++ b/charts/fluid/fluid/crds/data.fluid.io_vineyardruntimes.yaml
@@ -116,6 +116,28 @@ spec:
                   imageTag:
                     description: Image Tag for Vineyard Fuse Default is `v0.21.5`
                     type: string
+                  networkMode:
+                    description: Whether to use hostnetwork or not Default is HostNetwork
+                    enum:
+                    - HostNetwork
+                    - ""
+                    - ContainerNetwork
+                    type: string
+                  podMetadata:
+                    description: PodMetadata defines labels and annotations that will
+                      be propagated to Vineyard's pods.
+                    properties:
+                      annotations:
+                        additionalProperties:
+                          type: string
+                        description: Annotations are annotations of pod specification
+                        type: object
+                      labels:
+                        additionalProperties:
+                          type: string
+                        description: Labels are labels of pod specification
+                        type: object
+                    type: object
                   resources:
                     description: Resources contains the resource requirements and
                       limits for the Vineyard Fuse. Default is not set.
@@ -219,6 +241,13 @@ spec:
                       the default image tag is `3.5.10`. For Worker, the default image
                       tag is `v0.21.5`.
                     type: string
+                  networkMode:
+                    description: Whether to use hostnetwork or not Default is HostNetwork
+                    enum:
+                    - HostNetwork
+                    - ""
+                    - ContainerNetwork
+                    type: string
                   nodeSelector:
                     additionalProperties:
                       type: string
@@ -239,6 +268,22 @@ spec:
                       \n vineyardd.reserve.memory: \"true\" etcd.prefix: \"/vineyard\"
                       wait.etcd.timeout: \"120\""
                     type: object
+                  podMetadata:
+                    description: PodMetadata defines labels and annotations that will
+                      be propagated to Vineyard's pods including Master and Worker.
+                      Default is not set.
+                    properties:
+                      annotations:
+                        additionalProperties:
+                          type: string
+                        description: Annotations are annotations of pod specification
+                        type: object
+                      labels:
+                        additionalProperties:
+                          type: string
+                        description: Labels are labels of pod specification
+                        type: object
+                    type: object
                   ports:
                     additionalProperties:
                       type: integer
@@ -328,6 +373,21 @@ spec:
                       type: object
                     type: array
                 type: object
+              podMetadata:
+                description: PodMetadata defines labels and annotations that will
+                  be propagated to Vineyard's pods.
+                properties:
+                  annotations:
+                    additionalProperties:
+                      type: string
+                    description: Annotations are annotations of pod specification
+                    type: object
+                  labels:
+                    additionalProperties:
+                      type: string
+                    description: Labels are labels of pod specification
+                    type: object
+                type: object
               replicas:
                 description: The replicas of the worker, need to be specified If worker.replicas
                   and the field are both specified, the field will be respected
@@ -3507,6 +3567,13 @@ spec:
                       the default image tag is `3.5.10`. For Worker, the default image
                       tag is `v0.21.5`.
                     type: string
+                  networkMode:
+                    description: Whether to use hostnetwork or not Default is HostNetwork
+                    enum:
+                    - HostNetwork
+                    - ""
+                    - ContainerNetwork
+                    type: string
                   nodeSelector:
                     additionalProperties:
                       type: string
@@ -3527,6 +3594,22 @@ spec:
                       \n vineyardd.reserve.memory: \"true\" etcd.prefix: \"/vineyard\"
                       wait.etcd.timeout: \"120\""
                     type: object
+                  podMetadata:
+                    description: PodMetadata defines labels and annotations that will
+                      be propagated to Vineyard's pods including Master and Worker.
+                      Default is not set.
+                    properties:
+                      annotations:
+                        additionalProperties:
+                          type: string
+                        description: Annotations are annotations of pod specification
+                        type: object
+                      labels:
+                        additionalProperties:
+                          type: string
+                        description: Labels are labels of pod specification
+                        type: object
+                    type: object
                   ports:
                     additionalProperties:
                       type: integer
diff --git a/charts/fluid/fluid/templates/controller/vineyardruntime_controller.yaml b/charts/fluid/fluid/templates/controller/vineyardruntime_controller.yaml
index 55b26d52..a815f7da 100644
--- a/charts/fluid/fluid/templates/controller/vineyardruntime_controller.yaml
+++ b/charts/fluid/fluid/templates/controller/vineyardruntime_controller.yaml
@@ -48,6 +48,7 @@ spec:
         command: ["vineyardruntime-controller", "start"]
         args:
           - --development=false
+          - --runtime-node-port-range={{ .Values.runtime.vineyard.portRange }}
           - --pprof-addr=:6060
           - --enable-leader-election
           - --leader-election-namespace={{ include "fluid.namespace" . }}
diff --git a/charts/fluid/fluid/values.yaml b/charts/fluid/fluid/values.yaml
index 5e9830b4..9acfd503 100644
--- a/charts/fluid/fluid/values.yaml
+++ b/charts/fluid/fluid/values.yaml
@@ -143,6 +143,7 @@ runtime:
       image: registry.cn-zhangjiakou.aliyuncs.com/nascache/efc-fuse:v1.2.2-19dcee9
   vineyard:
     replicas: 1
+    portRange: 32000-34000
     tolerations:
       - operator: Exists
     enabled: false
diff --git a/charts/vineyard/templates/fuse/daemonset.yaml b/charts/vineyard/templates/fuse/daemonset.yaml
index 3e99bda1..e6c9b5a0 100644
--- a/charts/vineyard/templates/fuse/daemonset.yaml
+++ b/charts/vineyard/templates/fuse/daemonset.yaml
@@ -47,11 +47,21 @@ spec:
     metadata:
       annotations:
         sidecar.istio.io/inject: "false"
+      {{- if .Values.fuse.annotations }}
+      {{- range $key, $val := .Values.fuse.annotations }}
+        {{ $key | quote }}: {{ $val | quote }}
+      {{- end }}
+      {{- end }}
       labels:
         app: {{ $name }}
         chart: {{ $chart }}
         release: {{ .Release.Name }}
         role: vineyard-fuse
+        {{- if .Values.fuse.labels }}
+        {{- range $key, $val := .Values.fuse.labels }}
+        {{ $key | quote }}: {{ $val | quote }}
+        {{- end }}
+        {{- end }}
     spec:
       tolerations:
       - operator: Exists
@@ -60,6 +70,10 @@ spec:
 {{ toYaml .Values.fuse.nodeSelector | trim | indent 8  }}
       {{- end }}
       enableServiceLinks: false
+      {{- if .Values.fuse.hostNetwork }}
+      hostNetwork: {{ .Values.fuse.hostNetwork }}
+      dnsPolicy: ClusterFirstWithHostNet
+      {{- end }}
       terminationGracePeriodSeconds: 60
       containers:
         - name: vineyard-fuse
diff --git a/charts/vineyard/templates/master/statefulset.yaml b/charts/vineyard/templates/master/statefulset.yaml
index 6115d591..9e24bf99 100644
--- a/charts/vineyard/templates/master/statefulset.yaml
+++ b/charts/vineyard/templates/master/statefulset.yaml
@@ -55,18 +55,32 @@ spec:
     metadata:
       annotations:
         sidecar.istio.io/inject: "false"
+      {{- if .Values.master.annotations }}
+      {{- range $key, $val := .Values.master.annotations }}
+        {{ $key | quote }}: {{ $val | quote }}
+      {{- end }}
+      {{- end }}
       labels:
         app: {{ $name }}
         chart: {{ $chart }}
         release: {{ .Release.Name }}
         heritage: {{ .Release.Service }}
         role: vineyard-master
+        {{- if .Values.master.labels }}
+        {{- range $key, $val := .Values.master.labels }}
+        {{ $key | quote }}: {{ $val | quote }}
+        {{- end }}
+        {{- end }}
     spec:
       {{- if .Values.master.nodeSelector }}
       nodeSelector:
 {{ toYaml .Values.master.nodeSelector | trim | indent 8  }}
       {{- end }}
       enableServiceLinks: false
+      {{- if .Values.master.hostNetwork }}
+      hostNetwork: {{ .Values.master.hostNetwork }}
+      dnsPolicy: ClusterFirstWithHostNet
+      {{- end }}
       containers:
         - name: vineyard-master
           image: {{ .Values.master.image }}:{{ .Values.master.imageTag }}
diff --git a/charts/vineyard/templates/worker/statefulset.yaml b/charts/vineyard/templates/worker/statefulset.yaml
index 94bf3a3a..ff85855d 100644
--- a/charts/vineyard/templates/worker/statefulset.yaml
+++ b/charts/vineyard/templates/worker/statefulset.yaml
@@ -51,6 +51,11 @@ spec:
     metadata:
       annotations:
         sidecar.istio.io/inject: "false"
+      {{- if .Values.worker.annotations }}
+      {{- range $key, $val := .Values.worker.annotations }}
+        {{ $key | quote }}: {{ $val | quote }}
+      {{- end }}
+      {{- end }}
       labels:
         app: {{ $name }}
         chart: {{ $chart }}
@@ -59,12 +64,21 @@ spec:
         role: vineyard-worker
         fluid.io/dataset: {{ .Release.Namespace }}-{{ .Release.Name }}
         app.kubernetes.io/instance: {{ .Release.Namespace }}-{{ $fullName }}-worker
+        {{- if .Values.worker.labels }}
+        {{- range $key, $val := .Values.worker.labels }}
+        {{ $key | quote }}: {{ $val | quote }}
+        {{- end }}
+        {{- end }}
     spec:
       {{- if .Values.worker.nodeSelector }}
       nodeSelector:
 {{ toYaml .Values.worker.nodeSelector | trim | indent 8  }}
       {{- end }}
       enableServiceLinks: false
+      {{- if .Values.worker.hostNetwork }}
+      hostNetwork: {{ .Values.worker.hostNetwork }}
+      dnsPolicy: ClusterFirstWithHostNet
+      {{- end }}
       containers:
         - name: vineyard-worker
           image: {{ .Values.worker.image }}:{{ .Values.worker.imageTag }}
diff --git a/charts/vineyard/values.yaml b/charts/vineyard/values.yaml
index 83956daf..4ff5a773 100644
--- a/charts/vineyard/values.yaml
+++ b/charts/vineyard/values.yaml
@@ -3,6 +3,15 @@
 fullnameOverride: vineyard
 
 master:
+  # Metadata for Vineyard Master
+  labels:
+  # label1: value1
+  # label2: value2
+
+  annotations:
+  # annotation1: value1
+  # annotation2: value2
+
   # the external endpoint of master
   # if set, the Vineyard Master component will not be deployed, which means the Vineyard Worker component will use an external Etcd cluster.
   externalEndpoint:
@@ -19,7 +28,8 @@ master:
   imageTag: 3.5.10
   imagePullPolicy: IfNotPresent
   nodeSelector: {}
-  # Example:
+  hostNetwork: false
+  # Exmaple:
   #   "disktype": "ssd"
   ports:
     client: 2379
@@ -44,12 +54,22 @@ master:
   #   mountPath: /data/configmap/myConfigMapVolume/
 
 worker:
+  # Metadata for Vineyard Workers
+  labels:
+  # label1: value1
+  # label2: value2
+
+  annotations:
+  # annotation1: value1
+  # annotation2: value2
+
   replicas: 1
   image: vineyardcloudnative/vineyardd
   imageTag: v0.21.5
   imagePullPolicy: IfNotPresent
   nodeSelector: {}
-  # Example:
+  hostNetwork: false
+  # Exmaple:
   #   "disktype": "ssd"
   ports:
     rpc: 9600
@@ -96,6 +116,16 @@ volumes: []
 disablePrometheus: true
 
 fuse:
+  # Metadata for Vineyard Fuse
+  labels:
+  # label1: value1
+  # label2: value2
+
+  annotations:
+  # annotation1: value1
+  # annotation2: value2
+
+  hostNetwork: false
   image: vineyardcloudnative/vineyard-fluid-fuse
   imageTag: v0.21.5
   imagePullPolicy: IfNotPresent
diff --git a/cmd/vineyard/app/vineyard.go b/cmd/vineyard/app/vineyard.go
index 1350a056..3ce05122 100644
--- a/cmd/vineyard/app/vineyard.go
+++ b/cmd/vineyard/app/vineyard.go
@@ -23,6 +23,7 @@ import (
 	zapOpt "go.uber.org/zap"
 	"go.uber.org/zap/zapcore"
 	"k8s.io/apimachinery/pkg/runtime"
+	"k8s.io/apimachinery/pkg/util/net"
 	clientgoscheme "k8s.io/client-go/kubernetes/scheme"
 	ctrl "sigs.k8s.io/controller-runtime"
 	"sigs.k8s.io/controller-runtime/pkg/controller"
@@ -32,6 +33,7 @@ import (
 	datav1alpha1 "github.com/fluid-cloudnative/fluid/api/v1alpha1"
 	vineyardctl "github.com/fluid-cloudnative/fluid/pkg/controllers/v1alpha1/vineyard"
 	"github.com/fluid-cloudnative/fluid/pkg/ddc/base"
+	"github.com/fluid-cloudnative/fluid/pkg/ddc/base/portallocator"
 	"github.com/fluid-cloudnative/fluid/pkg/ddc/vineyard"
 )
 
@@ -48,6 +50,8 @@ var (
 	development             bool
 	maxConcurrentReconciles int
 	pprofAddr               string
+	portRange               string
+	portAllocatePolicy      string
 
 	kubeClientQPS   float32
 	kubeClientBurst int
@@ -78,6 +82,8 @@ func init() {
 	startCmd.Flags().StringVarP(&leaderElectionNamespace, "leader-election-namespace", "", "fluid-system", "The namespace in which the leader election resource will be created.")
 	startCmd.Flags().StringVarP(&pprofAddr, "pprof-addr", "", "", "The address for pprof to use while exporting profiling results")
 	startCmd.Flags().BoolVarP(&development, "development", "", true, "Enable development mode for fluid controller.")
+	startCmd.Flags().StringVar(&portRange, "runtime-node-port-range", "32000-34000", "Set available port range for Vineyard")
+	startCmd.Flags().StringVar(&portAllocatePolicy, "port-allocate-policy", "random", "Set port allocating policy, available choice is bitmap or random(default random).")
 	startCmd.Flags().BoolVar(&eventDriven, "event-driven", true, "The reconciler's loop strategy. if it's false, it indicates period driven.")
 	startCmd.Flags().Float32VarP(&kubeClientQPS, "kube-api-qps", "", 20, "QPS to use while talking with kubernetes apiserver.")   // 20 is the default qps in controller-runtime
 	startCmd.Flags().IntVarP(&kubeClientBurst, "kube-api-burst", "", 30, "Burst to use while talking with kubernetes apiserver.") // 30 is the default burst in controller-runtime
@@ -143,6 +149,19 @@ func handle() {
 		setupLog.Error(err, "unable to create controller", "controller", "VineyardRuntime")
 		os.Exit(1)
 	}
+	pr, err := net.ParsePortRange(portRange)
+	if err != nil {
+		setupLog.Error(err, "can't parse port range. Port range must be like <min>-<max>")
+		os.Exit(1)
+	}
+	setupLog.Info("port range parsed", "port range", pr.String())
+
+	err = portallocator.SetupRuntimePortAllocator(mgr.GetClient(), pr, portAllocatePolicy, vineyard.GetReservedPorts)
+	if err != nil {
+		setupLog.Error(err, "failed to setup runtime port allocator")
+		os.Exit(1)
+	}
+	setupLog.Info("Set up runtime port allocator", "policy", portAllocatePolicy)
 
 	setupLog.Info("starting vineyardruntime-controller")
 	if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil {
diff --git a/config/crd/bases/data.fluid.io_vineyardruntimes.yaml b/config/crd/bases/data.fluid.io_vineyardruntimes.yaml
index 1ecd7d60..b745e0aa 100644
--- a/config/crd/bases/data.fluid.io_vineyardruntimes.yaml
+++ b/config/crd/bases/data.fluid.io_vineyardruntimes.yaml
@@ -116,6 +116,28 @@ spec:
                   imageTag:
                     description: Image Tag for Vineyard Fuse Default is `v0.21.5`
                     type: string
+                  networkMode:
+                    description: Whether to use hostnetwork or not Default is HostNetwork
+                    enum:
+                    - HostNetwork
+                    - ""
+                    - ContainerNetwork
+                    type: string
+                  podMetadata:
+                    description: PodMetadata defines labels and annotations that will
+                      be propagated to Vineyard's pods.
+                    properties:
+                      annotations:
+                        additionalProperties:
+                          type: string
+                        description: Annotations are annotations of pod specification
+                        type: object
+                      labels:
+                        additionalProperties:
+                          type: string
+                        description: Labels are labels of pod specification
+                        type: object
+                    type: object
                   resources:
                     description: Resources contains the resource requirements and
                       limits for the Vineyard Fuse. Default is not set.
@@ -219,6 +241,13 @@ spec:
                       the default image tag is `3.5.10`. For Worker, the default image
                       tag is `v0.21.5`.
                     type: string
+                  networkMode:
+                    description: Whether to use hostnetwork or not Default is HostNetwork
+                    enum:
+                    - HostNetwork
+                    - ""
+                    - ContainerNetwork
+                    type: string
                   nodeSelector:
                     additionalProperties:
                       type: string
@@ -239,6 +268,22 @@ spec:
                       \n vineyardd.reserve.memory: \"true\" etcd.prefix: \"/vineyard\"
                       wait.etcd.timeout: \"120\""
                     type: object
+                  podMetadata:
+                    description: PodMetadata defines labels and annotations that will
+                      be propagated to Vineyard's pods including Master and Worker.
+                      Default is not set.
+                    properties:
+                      annotations:
+                        additionalProperties:
+                          type: string
+                        description: Annotations are annotations of pod specification
+                        type: object
+                      labels:
+                        additionalProperties:
+                          type: string
+                        description: Labels are labels of pod specification
+                        type: object
+                    type: object
                   ports:
                     additionalProperties:
                       type: integer
@@ -328,6 +373,21 @@ spec:
                       type: object
                     type: array
                 type: object
+              podMetadata:
+                description: PodMetadata defines labels and annotations that will
+                  be propagated to Vineyard's pods.
+                properties:
+                  annotations:
+                    additionalProperties:
+                      type: string
+                    description: Annotations are annotations of pod specification
+                    type: object
+                  labels:
+                    additionalProperties:
+                      type: string
+                    description: Labels are labels of pod specification
+                    type: object
+                type: object
               replicas:
                 description: The replicas of the worker, need to be specified If worker.replicas
                   and the field are both specified, the field will be respected
@@ -3507,6 +3567,13 @@ spec:
                       the default image tag is `3.5.10`. For Worker, the default image
                       tag is `v0.21.5`.
                     type: string
+                  networkMode:
+                    description: Whether to use hostnetwork or not Default is HostNetwork
+                    enum:
+                    - HostNetwork
+                    - ""
+                    - ContainerNetwork
+                    type: string
                   nodeSelector:
                     additionalProperties:
                       type: string
@@ -3527,6 +3594,22 @@ spec:
                       \n vineyardd.reserve.memory: \"true\" etcd.prefix: \"/vineyard\"
                       wait.etcd.timeout: \"120\""
                     type: object
+                  podMetadata:
+                    description: PodMetadata defines labels and annotations that will
+                      be propagated to Vineyard's pods including Master and Worker.
+                      Default is not set.
+                    properties:
+                      annotations:
+                        additionalProperties:
+                          type: string
+                        description: Annotations are annotations of pod specification
+                        type: object
+                      labels:
+                        additionalProperties:
+                          type: string
+                        description: Labels are labels of pod specification
+                        type: object
+                    type: object
                   ports:
                     additionalProperties:
                       type: integer
diff --git a/docs/en/dev/api_doc.md b/docs/en/dev/api_doc.md
index 0a0e5578..be533910 100644
--- a/docs/en/dev/api_doc.md
+++ b/docs/en/dev/api_doc.md
@@ -2457,6 +2457,20 @@ Default is false</p>
 </tr>
 <tr>
 <td>
+<code>podMetadata</code></br>
+<em>
+<a href="#data.fluid.io/v1alpha1.PodMetadata">
+PodMetadata
+</a>
+</em>
+</td>
+<td>
+<em>(Optional)</em>
+<p>PodMetadata defines labels and annotations that will be propagated to Vineyard&rsquo;s pods.</p>
+</td>
+</tr>
+<tr>
+<td>
 <code>volumes</code></br>
 <em>
 <a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#volume-v1-core">
@@ -7488,7 +7502,9 @@ bool
 <a href="#data.fluid.io/v1alpha1.JuiceFSCompTemplateSpec">JuiceFSCompTemplateSpec</a>, 
 <a href="#data.fluid.io/v1alpha1.JuiceFSFuseSpec">JuiceFSFuseSpec</a>, 
 <a href="#data.fluid.io/v1alpha1.ThinCompTemplateSpec">ThinCompTemplateSpec</a>, 
-<a href="#data.fluid.io/v1alpha1.ThinFuseSpec">ThinFuseSpec</a>)
+<a href="#data.fluid.io/v1alpha1.ThinFuseSpec">ThinFuseSpec</a>, 
+<a href="#data.fluid.io/v1alpha1.VineyardCompTemplateSpec">VineyardCompTemplateSpec</a>, 
+<a href="#data.fluid.io/v1alpha1.VineyardSockSpec">VineyardSockSpec</a>)
 </p>
 <p>
 </p>
@@ -7749,7 +7765,10 @@ WaitingStatus
 <a href="#data.fluid.io/v1alpha1.JuiceFSFuseSpec">JuiceFSFuseSpec</a>, 
 <a href="#data.fluid.io/v1alpha1.JuiceFSRuntimeSpec">JuiceFSRuntimeSpec</a>, 
 <a href="#data.fluid.io/v1alpha1.Metadata">Metadata</a>, 
-<a href="#data.fluid.io/v1alpha1.Processor">Processor</a>)
+<a href="#data.fluid.io/v1alpha1.Processor">Processor</a>, 
+<a href="#data.fluid.io/v1alpha1.VineyardCompTemplateSpec">VineyardCompTemplateSpec</a>, 
+<a href="#data.fluid.io/v1alpha1.VineyardRuntimeSpec">VineyardRuntimeSpec</a>, 
+<a href="#data.fluid.io/v1alpha1.VineyardSockSpec">VineyardSockSpec</a>)
 </p>
 <p>
 <p>PodMetadata defines subgroup properties of metav1.ObjectMeta</p>
@@ -9992,6 +10011,36 @@ It is useful for specifying a persistent storage.
 Default is not set.</p>
 </td>
 </tr>
+<tr>
+<td>
+<code>podMetadata</code></br>
+<em>
+<a href="#data.fluid.io/v1alpha1.PodMetadata">
+PodMetadata
+</a>
+</em>
+</td>
+<td>
+<em>(Optional)</em>
+<p>PodMetadata defines labels and annotations that will be propagated to Vineyard&rsquo;s pods including Master and Worker.
+Default is not set.</p>
+</td>
+</tr>
+<tr>
+<td>
+<code>networkMode</code></br>
+<em>
+<a href="#data.fluid.io/v1alpha1.NetworkMode">
+NetworkMode
+</a>
+</em>
+</td>
+<td>
+<em>(Optional)</em>
+<p>Whether to use hostnetwork or not
+Default is HostNetwork</p>
+</td>
+</tr>
 </tbody>
 </table>
 <h3 id="data.fluid.io/v1alpha1.VineyardRuntimeSpec">VineyardRuntimeSpec
@@ -10122,6 +10171,20 @@ Default is false</p>
 </tr>
 <tr>
 <td>
+<code>podMetadata</code></br>
+<em>
+<a href="#data.fluid.io/v1alpha1.PodMetadata">
+PodMetadata
+</a>
+</em>
+</td>
+<td>
+<em>(Optional)</em>
+<p>PodMetadata defines labels and annotations that will be propagated to Vineyard&rsquo;s pods.</p>
+</td>
+</tr>
+<tr>
+<td>
 <code>volumes</code></br>
 <em>
 <a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#volume-v1-core">
@@ -10240,6 +10303,35 @@ Kubernetes core/v1.ResourceRequirements
 Default is not set.</p>
 </td>
 </tr>
+<tr>
+<td>
+<code>networkMode</code></br>
+<em>
+<a href="#data.fluid.io/v1alpha1.NetworkMode">
+NetworkMode
+</a>
+</em>
+</td>
+<td>
+<em>(Optional)</em>
+<p>Whether to use hostnetwork or not
+Default is HostNetwork</p>
+</td>
+</tr>
+<tr>
+<td>
+<code>podMetadata</code></br>
+<em>
+<a href="#data.fluid.io/v1alpha1.PodMetadata">
+PodMetadata
+</a>
+</em>
+</td>
+<td>
+<em>(Optional)</em>
+<p>PodMetadata defines labels and annotations that will be propagated to Vineyard&rsquo;s pods.</p>
+</td>
+</tr>
 </tbody>
 </table>
 <h3 id="data.fluid.io/v1alpha1.VolumeSource">VolumeSource
@@ -10308,5 +10400,5 @@ bool
 <hr/>
 <p><em>
 Generated with <code>gen-crd-api-reference-docs</code>
-on git commit <code>4ca57673e</code>.
+on git commit <code>acb0aec73</code>.
 </em></p>
diff --git a/docs/zh/dev/api_doc.md b/docs/zh/dev/api_doc.md
index 0a0e5578..be533910 100644
--- a/docs/zh/dev/api_doc.md
+++ b/docs/zh/dev/api_doc.md
@@ -2457,6 +2457,20 @@ Default is false</p>
 </tr>
 <tr>
 <td>
+<code>podMetadata</code></br>
+<em>
+<a href="#data.fluid.io/v1alpha1.PodMetadata">
+PodMetadata
+</a>
+</em>
+</td>
+<td>
+<em>(Optional)</em>
+<p>PodMetadata defines labels and annotations that will be propagated to Vineyard&rsquo;s pods.</p>
+</td>
+</tr>
+<tr>
+<td>
 <code>volumes</code></br>
 <em>
 <a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#volume-v1-core">
@@ -7488,7 +7502,9 @@ bool
 <a href="#data.fluid.io/v1alpha1.JuiceFSCompTemplateSpec">JuiceFSCompTemplateSpec</a>, 
 <a href="#data.fluid.io/v1alpha1.JuiceFSFuseSpec">JuiceFSFuseSpec</a>, 
 <a href="#data.fluid.io/v1alpha1.ThinCompTemplateSpec">ThinCompTemplateSpec</a>, 
-<a href="#data.fluid.io/v1alpha1.ThinFuseSpec">ThinFuseSpec</a>)
+<a href="#data.fluid.io/v1alpha1.ThinFuseSpec">ThinFuseSpec</a>, 
+<a href="#data.fluid.io/v1alpha1.VineyardCompTemplateSpec">VineyardCompTemplateSpec</a>, 
+<a href="#data.fluid.io/v1alpha1.VineyardSockSpec">VineyardSockSpec</a>)
 </p>
 <p>
 </p>
@@ -7749,7 +7765,10 @@ WaitingStatus
 <a href="#data.fluid.io/v1alpha1.JuiceFSFuseSpec">JuiceFSFuseSpec</a>, 
 <a href="#data.fluid.io/v1alpha1.JuiceFSRuntimeSpec">JuiceFSRuntimeSpec</a>, 
 <a href="#data.fluid.io/v1alpha1.Metadata">Metadata</a>, 
-<a href="#data.fluid.io/v1alpha1.Processor">Processor</a>)
+<a href="#data.fluid.io/v1alpha1.Processor">Processor</a>, 
+<a href="#data.fluid.io/v1alpha1.VineyardCompTemplateSpec">VineyardCompTemplateSpec</a>, 
+<a href="#data.fluid.io/v1alpha1.VineyardRuntimeSpec">VineyardRuntimeSpec</a>, 
+<a href="#data.fluid.io/v1alpha1.VineyardSockSpec">VineyardSockSpec</a>)
 </p>
 <p>
 <p>PodMetadata defines subgroup properties of metav1.ObjectMeta</p>
@@ -9992,6 +10011,36 @@ It is useful for specifying a persistent storage.
 Default is not set.</p>
 </td>
 </tr>
+<tr>
+<td>
+<code>podMetadata</code></br>
+<em>
+<a href="#data.fluid.io/v1alpha1.PodMetadata">
+PodMetadata
+</a>
+</em>
+</td>
+<td>
+<em>(Optional)</em>
+<p>PodMetadata defines labels and annotations that will be propagated to Vineyard&rsquo;s pods including Master and Worker.
+Default is not set.</p>
+</td>
+</tr>
+<tr>
+<td>
+<code>networkMode</code></br>
+<em>
+<a href="#data.fluid.io/v1alpha1.NetworkMode">
+NetworkMode
+</a>
+</em>
+</td>
+<td>
+<em>(Optional)</em>
+<p>Whether to use hostnetwork or not
+Default is HostNetwork</p>
+</td>
+</tr>
 </tbody>
 </table>
 <h3 id="data.fluid.io/v1alpha1.VineyardRuntimeSpec">VineyardRuntimeSpec
@@ -10122,6 +10171,20 @@ Default is false</p>
 </tr>
 <tr>
 <td>
+<code>podMetadata</code></br>
+<em>
+<a href="#data.fluid.io/v1alpha1.PodMetadata">
+PodMetadata
+</a>
+</em>
+</td>
+<td>
+<em>(Optional)</em>
+<p>PodMetadata defines labels and annotations that will be propagated to Vineyard&rsquo;s pods.</p>
+</td>
+</tr>
+<tr>
+<td>
 <code>volumes</code></br>
 <em>
 <a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#volume-v1-core">
@@ -10240,6 +10303,35 @@ Kubernetes core/v1.ResourceRequirements
 Default is not set.</p>
 </td>
 </tr>
+<tr>
+<td>
+<code>networkMode</code></br>
+<em>
+<a href="#data.fluid.io/v1alpha1.NetworkMode">
+NetworkMode
+</a>
+</em>
+</td>
+<td>
+<em>(Optional)</em>
+<p>Whether to use hostnetwork or not
+Default is HostNetwork</p>
+</td>
+</tr>
+<tr>
+<td>
+<code>podMetadata</code></br>
+<em>
+<a href="#data.fluid.io/v1alpha1.PodMetadata">
+PodMetadata
+</a>
+</em>
+</td>
+<td>
+<em>(Optional)</em>
+<p>PodMetadata defines labels and annotations that will be propagated to Vineyard&rsquo;s pods.</p>
+</td>
+</tr>
 </tbody>
 </table>
 <h3 id="data.fluid.io/v1alpha1.VolumeSource">VolumeSource
@@ -10308,5 +10400,5 @@ bool
 <hr/>
 <p><em>
 Generated with <code>gen-crd-api-reference-docs</code>
-on git commit <code>4ca57673e</code>.
+on git commit <code>acb0aec73</code>.
 </em></p>
diff --git a/pkg/ddc/vineyard/master_internal.go b/pkg/ddc/vineyard/master_internal.go
index 06f508d0..e96cc2b9 100644
--- a/pkg/ddc/vineyard/master_internal.go
+++ b/pkg/ddc/vineyard/master_internal.go
@@ -102,6 +102,10 @@ func (e *VineyardEngine) generateVineyardValueFile(runtime *datav1alpha1.Vineyar
 	return valueFileName, err
 }
 
+func (e *VineyardEngine) getHelmValuesConfigMapName() string {
+	return e.name + "-" + e.engineImpl + "-values"
+}
+
 func (e *VineyardEngine) getConfigmapName() string {
 	return e.name + "-" + e.engineImpl + "-values"
 }
diff --git a/pkg/ddc/vineyard/port_parser.go b/pkg/ddc/vineyard/port_parser.go
new file mode 100644
index 00000000..95d9ee4f
--- /dev/null
+++ b/pkg/ddc/vineyard/port_parser.go
@@ -0,0 +1,99 @@
+/*
+  Copyright 2023 The Fluid Authors.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+*/
+
+package vineyard
+
+import (
+	"context"
+	"fmt"
+
+	"github.com/fluid-cloudnative/fluid/api/v1alpha1"
+	"github.com/fluid-cloudnative/fluid/pkg/common"
+	"github.com/fluid-cloudnative/fluid/pkg/utils/kubeclient"
+	"github.com/pkg/errors"
+	corev1 "k8s.io/api/core/v1"
+	"sigs.k8s.io/controller-runtime/pkg/client"
+	"sigs.k8s.io/yaml"
+)
+
+// GetReservedPorts defines restoration logic for VineyardRuntime
+func GetReservedPorts(client client.Client) (ports []int, err error) {
+	var datasets v1alpha1.DatasetList
+	err = client.List(context.TODO(), &datasets)
+	if err != nil {
+		return nil, errors.Wrap(err, "can't list datasets when GetReservedPorts")
+	}
+
+	for _, dataset := range datasets.Items {
+		if len(dataset.Status.Runtimes) != 0 {
+			// Assume there is only one runtime with category "Accelerate"
+			accelerateRuntime := dataset.Status.Runtimes[0]
+			if accelerateRuntime.Type != common.VineyardRuntime {
+				continue
+			}
+			configMapName := fmt.Sprintf("%s-%s-values", accelerateRuntime.Name, accelerateRuntime.Type)
+			configMap, err := kubeclient.GetConfigmapByName(client, configMapName, accelerateRuntime.Namespace)
+			if err != nil {
+				return nil, errors.Wrap(err, "GetConfigMapByName when GetReservedPorts")
+			}
+
+			if configMap == nil {
+				continue
+			}
+
+			reservedPorts, err := parsePortsFromConfigMap(configMap)
+			if err != nil {
+				return nil, errors.Wrap(err, "parsePortsFromConfigMap when GetReservedPorts")
+			}
+			ports = append(ports, reservedPorts...)
+		}
+	}
+	return ports, nil
+}
+
+// parsePortsFromConfigMap extracts port usage information given a configMap
+func parsePortsFromConfigMap(configMap *corev1.ConfigMap) (ports []int, err error) {
+	var value Vineyard
+	if v, ok := configMap.Data["data"]; ok {
+		if err := yaml.Unmarshal([]byte(v), &value); err != nil {
+			return nil, err
+		}
+
+		if value.Master.HostNetwork && value.Master.Ports != nil {
+			clientPort, ok := value.Master.Ports[MasterClientName]
+			if ok {
+				fmt.Println("clientPort:", clientPort)
+				ports = append(ports, clientPort)
+			}
+			peerPort, ok := value.Master.Ports[MasterPeerName]
+			if ok {
+				fmt.Println("peerPort:", peerPort)
+				ports = append(ports, peerPort)
+			}
+		}
+		if value.Worker.HostNetwork && value.Worker.Ports != nil {
+			rpcPort, ok := value.Worker.Ports[WorkerRPCName]
+			if ok {
+				ports = append(ports, rpcPort)
+			}
+			exporterPort, ok := value.Worker.Ports[WorkerExporterName]
+			if ok {
+				ports = append(ports, exporterPort)
+			}
+		}
+	}
+	return ports, nil
+}
diff --git a/pkg/ddc/vineyard/shut_down.go b/pkg/ddc/vineyard/shut_down.go
index 9fd82162..a484e7c0 100644
--- a/pkg/ddc/vineyard/shut_down.go
+++ b/pkg/ddc/vineyard/shut_down.go
@@ -17,12 +17,15 @@ import (
 	"context"
 	"fmt"
 
+	datav1alpha1 "github.com/fluid-cloudnative/fluid/api/v1alpha1"
 	"github.com/fluid-cloudnative/fluid/pkg/common"
 	"github.com/fluid-cloudnative/fluid/pkg/ddc/base"
+	"github.com/fluid-cloudnative/fluid/pkg/ddc/base/portallocator"
 	"github.com/fluid-cloudnative/fluid/pkg/utils"
 	"github.com/fluid-cloudnative/fluid/pkg/utils/dataset/lifecycle"
 	"github.com/fluid-cloudnative/fluid/pkg/utils/helm"
 	"github.com/fluid-cloudnative/fluid/pkg/utils/kubeclient"
+	"github.com/pkg/errors"
 	corev1 "k8s.io/api/core/v1"
 	"k8s.io/apimachinery/pkg/labels"
 	"k8s.io/client-go/util/retry"
@@ -56,6 +59,21 @@ func (e *VineyardEngine) Shutdown() (err error) {
 		return
 	}
 
+	runtime, err := e.getRuntime()
+	if err != nil {
+		return err
+	}
+	if datav1alpha1.IsHostNetwork(runtime.Spec.Master.NetworkMode) ||
+		datav1alpha1.IsHostNetwork(runtime.Spec.Worker.NetworkMode) {
+		e.Log.Info("releasePorts for hostnetwork mode")
+		err = e.releasePorts()
+		if err != nil {
+			return
+		}
+	} else {
+		e.Log.Info("skip releasePorts for container network mode")
+	}
+
 	return e.cleanAll()
 }
 
@@ -201,6 +219,34 @@ func (e *VineyardEngine) cleanupCache() (err error) {
 	//return fmt.Errorf("to make sure if the remaining cache is cleaned up, check again")
 }
 
+func (e *VineyardEngine) releasePorts() (err error) {
+	var valueConfigMapName = e.getHelmValuesConfigMapName()
+
+	allocator, err := portallocator.GetRuntimePortAllocator()
+	if err != nil {
+		return errors.Wrap(err, "GetRuntimePortAllocator when releasePorts")
+	}
+
+	cm, err := kubeclient.GetConfigmapByName(e.Client, valueConfigMapName, e.namespace)
+	if err != nil {
+		return errors.Wrap(err, "GetConfigmapByName when releasePorts")
+	}
+
+	// The value configMap is not found
+	if cm == nil {
+		e.Log.Info("value configMap not found, there might be some unreleased ports", "valueConfigMapName", valueConfigMapName)
+		return nil
+	}
+
+	portsToRelease, err := parsePortsFromConfigMap(cm)
+	if err != nil {
+		return errors.Wrap(err, "parsePortsFromConfigMap when releasePorts")
+	}
+
+	allocator.ReleaseReservedPorts(portsToRelease)
+	return nil
+}
+
 // cleanAll cleans up the all
 func (e *VineyardEngine) cleanAll() (err error) {
 	count, err := e.Helper.CleanUpFuse()
diff --git a/pkg/ddc/vineyard/transform.go b/pkg/ddc/vineyard/transform.go
index d6a777cb..8c715873 100644
--- a/pkg/ddc/vineyard/transform.go
+++ b/pkg/ddc/vineyard/transform.go
@@ -18,6 +18,7 @@ import (
 	"time"
 
 	"github.com/fluid-cloudnative/fluid/pkg/common"
+	"github.com/fluid-cloudnative/fluid/pkg/ddc/base/portallocator"
 
 	datav1alpha1 "github.com/fluid-cloudnative/fluid/api/v1alpha1"
 	"github.com/fluid-cloudnative/fluid/pkg/utils"
@@ -58,6 +59,18 @@ func (e *VineyardEngine) transform(runtime *datav1alpha1.VineyardRuntime) (value
 
 	e.transformFuse(runtime, value)
 
+	e.transformPodMetadata(runtime, value)
+
+	// allocate ports for hostnetwork mode
+	if datav1alpha1.IsHostNetwork(runtime.Spec.Master.NetworkMode) ||
+		datav1alpha1.IsHostNetwork(runtime.Spec.Worker.NetworkMode) {
+		e.Log.Info("allocatePorts for hostnetwork mode")
+		err = e.allocatePorts(value, runtime)
+		if err != nil {
+			return
+		}
+	}
+
 	// TODO:(caoye) implement the metrics exporter
 	value.DisablePrometheus = true
 	return value, nil
@@ -97,6 +110,9 @@ func (e *VineyardEngine) transformMasters(runtime *datav1alpha1.VineyardRuntime,
 
 	e.transformResourcesForMaster(runtime, value)
 
+	// parse master pod network mode
+	value.Master.HostNetwork = datav1alpha1.IsHostNetwork(runtime.Spec.Worker.NetworkMode)
+
 	ports := e.transformMasterPorts(runtime)
 	if len(ports) != 0 {
 		value.Master.Ports = ports
@@ -137,6 +153,9 @@ func (e *VineyardEngine) transformWorkers(runtime *datav1alpha1.VineyardRuntime,
 		return err
 	}
 
+	// parse worker pod network mode
+	value.Worker.HostNetwork = datav1alpha1.IsHostNetwork(runtime.Spec.Worker.NetworkMode)
+
 	ports := e.transformWorkerPorts(runtime)
 	if len(ports) != 0 {
 		value.Worker.Ports = ports
@@ -168,6 +187,10 @@ func (e *VineyardEngine) transformFuse(runtime *datav1alpha1.VineyardRuntime, va
 	value.Fuse.HostPID = common.HostPIDEnabled(runtime.Annotations)
 
 	value.Fuse.TargetPath = e.getMountPoint()
+
+	// parse fuse pod network mode
+	value.Fuse.HostNetwork = datav1alpha1.IsHostNetwork(runtime.Spec.Fuse.NetworkMode)
+
 	e.transformResourcesForFuse(runtime, value)
 }
 
@@ -262,3 +285,54 @@ func (e *VineyardEngine) transformTieredStore(runtime *datav1alpha1.VineyardRunt
 
 	return tieredStore, nil
 }
+
+func (e *VineyardEngine) allocatePorts(value *Vineyard, runtime *datav1alpha1.VineyardRuntime) error {
+	expectedMasterPortNum, expectedWorkerPortNum := 0, 0
+	if datav1alpha1.IsHostNetwork(runtime.Spec.Master.NetworkMode) {
+		expectedMasterPortNum = 2
+	}
+	if datav1alpha1.IsHostNetwork(runtime.Spec.Worker.NetworkMode) {
+		expectedWorkerPortNum = 2
+	}
+	expectedPortNum := expectedMasterPortNum + expectedWorkerPortNum
+
+	allocator, err := portallocator.GetRuntimePortAllocator()
+	if err != nil {
+		e.Log.Error(err, "can't get runtime port allocator")
+		return err
+	}
+
+	allocatedPorts, err := allocator.GetAvailablePorts(expectedPortNum)
+	if err != nil {
+		e.Log.Error(err, "can't get available ports", "expected port num", expectedPortNum)
+		return err
+	}
+
+	index := 0
+	if expectedMasterPortNum > 0 {
+		value.Master.Ports[MasterClientName] = allocatedPorts[index]
+		value.Master.Ports[MasterPeerName] = allocatedPorts[index+1]
+		index += 2
+	}
+
+	if expectedWorkerPortNum > 0 {
+		value.Worker.Ports[WorkerRPCName] = allocatedPorts[index]
+		value.Worker.Ports[WorkerExporterName] = allocatedPorts[index+1]
+	}
+
+	return nil
+}
+
+func (e *VineyardEngine) transformPodMetadata(runtime *datav1alpha1.VineyardRuntime, value *Vineyard) {
+	// transform labels
+	commonLabels := utils.UnionMapsWithOverride(map[string]string{}, runtime.Spec.PodMetadata.Labels)
+	value.Master.Labels = utils.UnionMapsWithOverride(commonLabels, runtime.Spec.Master.PodMetadata.Labels)
+	value.Worker.Labels = utils.UnionMapsWithOverride(commonLabels, runtime.Spec.Worker.PodMetadata.Labels)
+	value.Fuse.Labels = utils.UnionMapsWithOverride(commonLabels, runtime.Spec.Fuse.PodMetadata.Labels)
+
+	// transform annotations
+	commonAnnotations := utils.UnionMapsWithOverride(map[string]string{}, runtime.Spec.PodMetadata.Annotations)
+	value.Master.Annotations = utils.UnionMapsWithOverride(commonAnnotations, runtime.Spec.Master.PodMetadata.Annotations)
+	value.Worker.Annotations = utils.UnionMapsWithOverride(commonAnnotations, runtime.Spec.Worker.PodMetadata.Annotations)
+	value.Fuse.Annotations = utils.UnionMapsWithOverride(commonAnnotations, runtime.Spec.Fuse.PodMetadata.Annotations)
+}
diff --git a/pkg/ddc/vineyard/type.go b/pkg/ddc/vineyard/type.go
index c8b274ee..2f422862 100644
--- a/pkg/ddc/vineyard/type.go
+++ b/pkg/ddc/vineyard/type.go
@@ -49,9 +49,12 @@ type Endpoint struct {
 
 type Master struct {
 	Replicas         int32                `json:"replicas,omitempty"`
+	Labels           map[string]string    `json:"labels,omitempty"`
+	Annotations      map[string]string    `json:"annotations,omitempty"`
 	Image            string               `json:"image,omitempty"`
 	ImageTag         string               `json:"imageTag,omitempty"`
 	ImagePullPolicy  string               `json:"imagePullPolicy,omitempty"`
+	HostNetwork      bool                 `json:"hostNetwork,omitempty"`
 	NodeSelector     map[string]string    `json:"nodeSelector,omitempty"`
 	Ports            map[string]int       `json:"ports,omitempty"`
 	Env              map[string]string    `json:"env,omitempty"`
@@ -63,9 +66,12 @@ type Master struct {
 
 type Worker struct {
 	Replicas        int32                `json:"replicas,omitempty"`
+	Labels          map[string]string    `json:"labels,omitempty"`
+	Annotations     map[string]string    `json:"annotations,omitempty"`
 	Image           string               `json:"image,omitempty"`
 	ImageTag        string               `json:"imageTag,omitempty"`
 	ImagePullPolicy string               `json:"imagePullPolicy,omitempty"`
+	HostNetwork     bool                 `json:"hostNetwork,omitempty"`
 	NodeSelector    map[string]string    `json:"nodeSelector,omitempty"`
 	Ports           map[string]int       `json:"ports,omitempty"`
 	Env             map[string]string    `json:"env,omitempty"`
@@ -75,9 +81,12 @@ type Worker struct {
 }
 
 type Fuse struct {
+	Labels          map[string]string            `json:"labels,omitempty"`
+	Annotations     map[string]string            `json:"annotations,omitempty"`
 	Image           string                       `json:"image,omitempty"`
 	ImageTag        string                       `json:"imageTag,omitempty"`
 	ImagePullPolicy string                       `json:"imagePullPolicy,omitempty"`
+	HostNetwork     bool                         `json:"hostNetwork,omitempty"`
 	Env             map[string]string            `json:"env,omitempty"`
 	CleanPolicy     datav1alpha1.FuseCleanPolicy `json:"cleanPolicy,omitempty"`
 	TargetPath      string                       `json:"targetPath,omitempty"`


Test patch:
diff --git a/pkg/ddc/vineyard/master_internal_test.go b/pkg/ddc/vineyard/master_internal_test.go
index 3de1d060..4b4b7b1d 100644
--- a/pkg/ddc/vineyard/master_internal_test.go
+++ b/pkg/ddc/vineyard/master_internal_test.go
@@ -21,13 +21,24 @@ import (
 	"k8s.io/apimachinery/pkg/api/resource"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 	"k8s.io/apimachinery/pkg/runtime"
+	"k8s.io/apimachinery/pkg/util/net"
+	"sigs.k8s.io/controller-runtime/pkg/client"
 
 	datav1alpha1 "github.com/fluid-cloudnative/fluid/api/v1alpha1"
+	"github.com/fluid-cloudnative/fluid/pkg/ddc/base/portallocator"
 	"github.com/fluid-cloudnative/fluid/pkg/utils/fake"
 	"github.com/fluid-cloudnative/fluid/pkg/utils/helm"
 )
 
 func TestSetupMasterInternal(t *testing.T) {
+	pr := net.ParsePortRangeOrDie("14000-15999")
+	dummyPorts := func(client client.Client) (ports []int, err error) {
+		return []int{14000, 14001, 14002, 14003}, nil
+	}
+	err := portallocator.SetupRuntimePortAllocator(nil, pr, "bitmap", dummyPorts)
+	if err != nil {
+		t.Fatal(err.Error())
+	}
 	mockExecCheckReleaseCommonFound := func(name string, namespace string) (exist bool, err error) {
 		return true, nil
 	}
@@ -105,7 +116,7 @@ func TestSetupMasterInternal(t *testing.T) {
 			},
 		},
 	}
-	err := engine.setupMasterInternal()
+	err = engine.setupMasterInternal()
 	if err == nil {
 		t.Errorf("fail to catch the error")
 	}
diff --git a/pkg/ddc/vineyard/port_parser_test.go b/pkg/ddc/vineyard/port_parser_test.go
new file mode 100644
index 00000000..6a5d6d38
--- /dev/null
+++ b/pkg/ddc/vineyard/port_parser_test.go
@@ -0,0 +1,116 @@
+/*
+  Copyright 2023 The Fluid Authors.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+*/
+
+package vineyard
+
+import (
+	"reflect"
+	"testing"
+
+	"github.com/fluid-cloudnative/fluid/api/v1alpha1"
+	"github.com/fluid-cloudnative/fluid/pkg/utils/fake"
+	corev1 "k8s.io/api/core/v1"
+	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+	"k8s.io/apimachinery/pkg/runtime"
+)
+
+var (
+	dummyConfigMapData = `master:
+  hostNetwork: true
+  ports:
+    client: 14001
+    peer: 14002
+worker:
+  hostNetwork: true
+  ports:
+    rpc: 14003
+    exporter: 14004
+`
+)
+
+func TestGetReservedPorts(t *testing.T) {
+	configMap := &corev1.ConfigMap{
+		ObjectMeta: metav1.ObjectMeta{
+			Name:      "test-vineyard-values",
+			Namespace: "fluid",
+		},
+		Data: map[string]string{
+			"data": mockConfigMapData,
+		},
+	}
+	dataSets := []*v1alpha1.Dataset{
+		{
+			ObjectMeta: metav1.ObjectMeta{Name: "test", Namespace: "fluid"},
+			Status: v1alpha1.DatasetStatus{
+				Runtimes: []v1alpha1.Runtime{{
+					Name:      "test",
+					Namespace: "fluid",
+					Type:      "vineyard",
+				}},
+			},
+		},
+	}
+	runtimeObjs := []runtime.Object{}
+	runtimeObjs = append(runtimeObjs, configMap)
+	for _, dataSet := range dataSets {
+		runtimeObjs = append(runtimeObjs, dataSet.DeepCopy())
+	}
+	fakeClient := fake.NewFakeClientWithScheme(testScheme, runtimeObjs...)
+	wantPorts := []int{14001, 14002, 14003, 14004}
+	ports, err := GetReservedPorts(fakeClient)
+	if err != nil {
+		t.Errorf("GetReservedPorts failed.")
+	}
+	if !reflect.DeepEqual(ports, wantPorts) {
+		t.Errorf("gotPorts = %v, want %v", ports, wantPorts)
+	}
+
+}
+
+func Test_parsePortsFromConfigMap(t *testing.T) {
+	type args struct {
+		configMap *corev1.ConfigMap
+	}
+	tests := []struct {
+		name      string
+		args      args
+		wantPorts []int
+		wantErr   bool
+	}{
+		{
+			name: "parsePortsFromConfigMap",
+			args: args{configMap: &corev1.ConfigMap{
+				Data: map[string]string{
+					"data": dummyConfigMapData,
+				},
+			}},
+			wantPorts: []int{14001, 14002, 14003, 14004},
+			wantErr:   false,
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			gotPorts, err := parsePortsFromConfigMap(tt.args.configMap)
+			if (err != nil) != tt.wantErr {
+				t.Errorf("parsePortsFromConfigMap() error = %v, wantErr %v", err, tt.wantErr)
+				return
+			}
+			if !reflect.DeepEqual(gotPorts, tt.wantPorts) {
+				t.Errorf("parsePortsFromConfigMap() gotPorts = %v, want %v", gotPorts, tt.wantPorts)
+			}
+		})
+	}
+}
diff --git a/pkg/ddc/vineyard/shut_down_test.go b/pkg/ddc/vineyard/shut_down_test.go
index d7697dba..f93cc2a0 100644
--- a/pkg/ddc/vineyard/shut_down_test.go
+++ b/pkg/ddc/vineyard/shut_down_test.go
@@ -18,11 +18,13 @@ import (
 	"testing"
 
 	appsv1 "k8s.io/api/apps/v1"
+	"sigs.k8s.io/controller-runtime/pkg/client"
 
 	. "github.com/agiledragon/gomonkey/v2"
 	datav1alpha1 "github.com/fluid-cloudnative/fluid/api/v1alpha1"
 	"github.com/fluid-cloudnative/fluid/pkg/ctrl"
 	"github.com/fluid-cloudnative/fluid/pkg/ddc/base"
+	"github.com/fluid-cloudnative/fluid/pkg/ddc/base/portallocator"
 	"github.com/fluid-cloudnative/fluid/pkg/utils/fake"
 	"github.com/fluid-cloudnative/fluid/pkg/utils/helm"
 	"github.com/fluid-cloudnative/fluid/pkg/utils/kubeclient"
@@ -30,27 +32,22 @@ import (
 	corev1 "k8s.io/api/core/v1"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 	"k8s.io/apimachinery/pkg/runtime"
+	"k8s.io/apimachinery/pkg/util/net"
 )
 
 var (
 	testScheme        *runtime.Scheme
-	mockConfigMapData = `master:
-	ports:
-	  rpc: 30399
-	  web: 31203
-  jobMaster:
-	ports:
-	  rpc: 28362
-	  web: 31380
-  worker:
-	ports:
-	  rpc: 31285
-	  web: 31674
-  jobWorker:
-	ports:
-	  rpc: 29476
-	  web: 27403
-	  data: 30918`
+	mockConfigMapData = `
+master:
+  hostNetwork: true
+  ports:
+    client: 14001
+    peer: 14002
+worker:
+  hostNetwork: true
+  ports:
+    rpc: 14003
+    exporter: 14004`
 )
 
 func init() {
@@ -369,3 +366,69 @@ func TestVineyardEngineDestroyMaster(t *testing.T) {
 		})
 	}
 }
+
+func TestVineyardEngineReleasePorts(t *testing.T) {
+	dummyPorts := func(client client.Client) (ports []int, err error) {
+		return []int{14000, 14001, 14002, 14003}, nil
+	}
+	type fields struct {
+		runtime     *datav1alpha1.VineyardRuntime
+		name        string
+		namespace   string
+		runtimeType string
+		cm          *corev1.ConfigMap
+	}
+	tests := []struct {
+		name    string
+		fields  fields
+		wantErr bool
+	}{
+		{
+			name: "vineyard",
+			fields: fields{
+				name:        "vineyard",
+				namespace:   "fluid",
+				runtimeType: "vineyard",
+				cm: &corev1.ConfigMap{
+					ObjectMeta: metav1.ObjectMeta{
+						Name:      "vineyard-values",
+						Namespace: "fluid",
+					},
+					Data: map[string]string{"data": mockConfigMapData},
+				},
+			},
+			wantErr: false,
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			portRange := "14000-16000"
+			pr, _ := net.ParsePortRange(portRange)
+			testObjs := []runtime.Object{}
+			testObjs = append(testObjs, tt.fields.cm.DeepCopy())
+			client := fake.NewFakeClientWithScheme(testScheme, testObjs...)
+
+			e := &VineyardEngine{
+				runtime:   tt.fields.runtime,
+				name:      tt.fields.name,
+				namespace: tt.fields.namespace,
+				Client:    client,
+				Log:       fake.NullLogger(),
+			}
+
+			err := portallocator.SetupRuntimePortAllocator(client, pr, "bitmap", dummyPorts)
+			if err != nil {
+				t.Fatal(err.Error())
+			}
+			allocator, _ := portallocator.GetRuntimePortAllocator()
+			patch1 := ApplyMethod(reflect.TypeOf(allocator), "ReleaseReservedPorts",
+				func(_ *portallocator.RuntimePortAllocator, ports []int) {
+				})
+			defer patch1.Reset()
+
+			if err := e.releasePorts(); (err != nil) != tt.wantErr {
+				t.Errorf("VineyardEngine.releasePorts() error = %v, wantErr %v", err, tt.wantErr)
+			}
+		})
+	}
+}
diff --git a/pkg/ddc/vineyard/transform_test.go b/pkg/ddc/vineyard/transform_test.go
index a6c15e6e..f29adfe7 100755
--- a/pkg/ddc/vineyard/transform_test.go
+++ b/pkg/ddc/vineyard/transform_test.go
@@ -21,9 +21,12 @@ import (
 
 	datav1alpha1 "github.com/fluid-cloudnative/fluid/api/v1alpha1"
 	"github.com/fluid-cloudnative/fluid/pkg/ddc/base"
+	"github.com/fluid-cloudnative/fluid/pkg/ddc/base/portallocator"
 	"github.com/fluid-cloudnative/fluid/pkg/utils/fake"
 	"k8s.io/apimachinery/pkg/api/resource"
+	"k8s.io/apimachinery/pkg/util/net"
 	ctrl "sigs.k8s.io/controller-runtime"
+	"sigs.k8s.io/controller-runtime/pkg/client"
 	"sigs.k8s.io/controller-runtime/pkg/log/zap"
 )
 
@@ -622,3 +625,230 @@ func TestTransformTieredStore(t *testing.T) {
 		})
 	}
 }
+
+func TestVineyardEngineAllocatePorts(t *testing.T) {
+	pr := net.ParsePortRangeOrDie("14000-16000")
+	dummyPorts := func(client client.Client) (ports []int, err error) {
+		return []int{14000, 14001, 14002, 14003}, nil
+	}
+	err := portallocator.SetupRuntimePortAllocator(nil, pr, "bitmap", dummyPorts)
+	if err != nil {
+		t.Fatal(err.Error())
+	}
+	type args struct {
+		runtime *datav1alpha1.VineyardRuntime
+		value   *Vineyard
+	}
+	tests := []struct {
+		name            string
+		args            args
+		wantErr         bool
+		wantMasterPorts map[string]int
+		wantWorkerPorts map[string]int
+	}{
+		{
+			name: "Expect not to allocate ports",
+			args: args{
+				runtime: &datav1alpha1.VineyardRuntime{
+					Spec: datav1alpha1.VineyardRuntimeSpec{
+						Master: datav1alpha1.MasterSpec{
+							VineyardCompTemplateSpec: datav1alpha1.VineyardCompTemplateSpec{
+								NetworkMode: "ContainerNetwork",
+							},
+						},
+						Worker: datav1alpha1.VineyardCompTemplateSpec{
+							NetworkMode: "ContainerNetwork",
+						},
+					},
+				},
+				value: &Vineyard{
+					Master: Master{
+						Ports: map[string]int{
+							MasterClientName: MasterClientPort,
+							MasterPeerName:   MasterPeerPort,
+						},
+					},
+					Worker: Worker{
+						Ports: map[string]int{
+							WorkerRPCName:      WorkerRPCPort,
+							WorkerExporterName: WorkerExporterPort,
+						},
+					},
+				},
+			},
+			wantErr: false,
+			wantMasterPorts: map[string]int{
+				MasterClientName: MasterClientPort,
+				MasterPeerName:   MasterPeerPort,
+			},
+			wantWorkerPorts: map[string]int{
+				WorkerRPCName:      WorkerRPCPort,
+				WorkerExporterName: WorkerExporterPort,
+			},
+		},
+		{
+			name: "Expect to allocate ports",
+			args: args{
+				runtime: &datav1alpha1.VineyardRuntime{
+					Spec: datav1alpha1.VineyardRuntimeSpec{
+						Master: datav1alpha1.MasterSpec{
+							VineyardCompTemplateSpec: datav1alpha1.VineyardCompTemplateSpec{
+								NetworkMode: "HostNetwork",
+							},
+						},
+						Worker: datav1alpha1.VineyardCompTemplateSpec{
+							NetworkMode: "HostNetwork",
+						},
+					},
+				},
+				value: &Vineyard{
+					Master: Master{
+						Ports: map[string]int{
+							MasterClientName: MasterClientPort,
+							MasterPeerName:   MasterPeerPort,
+						},
+					},
+					Worker: Worker{
+						Ports: map[string]int{
+							WorkerRPCName:      WorkerRPCPort,
+							WorkerExporterName: WorkerExporterPort,
+						},
+					},
+				},
+			},
+			wantErr: false,
+			wantMasterPorts: map[string]int{
+				MasterClientName: MasterClientPort,
+				MasterPeerName:   MasterPeerPort,
+			},
+			wantWorkerPorts: map[string]int{
+				WorkerRPCName:      WorkerRPCPort,
+				WorkerExporterName: WorkerExporterPort,
+			},
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			v := &VineyardEngine{}
+			if err := v.allocatePorts(tt.args.value, tt.args.runtime); (err != nil) != tt.wantErr {
+				t.Errorf("allocatePorts() error = %v, wantErr %v", err, tt.wantErr)
+			}
+			if strings.Contains(tt.name, "Expect not to allocate ports") {
+				if !reflect.DeepEqual(tt.wantMasterPorts, tt.args.value.Master.Ports) {
+					t.Errorf("allocatePorts() got master ports = %v, want %v", tt.args.value.Master.Ports, tt.wantMasterPorts)
+				}
+				if !reflect.DeepEqual(tt.wantWorkerPorts, tt.args.value.Worker.Ports) {
+					t.Errorf("allocatePorts() got worker ports = %v, want %v", tt.args.value.Worker.Ports, tt.wantWorkerPorts)
+				}
+			} else {
+				if len(tt.args.value.Master.Ports) != 2 {
+					t.Errorf("allocatePorts() got master ports = %v, want 2", len(tt.args.value.Master.Ports))
+				}
+				if len(tt.args.value.Worker.Ports) != 2 {
+					t.Errorf("allocatePorts() got worker ports = %v, want 2", len(tt.args.value.Worker.Ports))
+				}
+				if tt.args.value.Master.Ports[MasterClientName] < 14000 || tt.args.value.Master.Ports[MasterClientName] > 16000 {
+					t.Errorf("allocatePorts() got master client port = %v, want between 14000 and 16000", tt.args.value.Master.Ports[MasterClientName])
+				}
+				if tt.args.value.Master.Ports[MasterPeerName] < 14000 || tt.args.value.Master.Ports[MasterPeerName] > 16000 {
+					t.Errorf("allocatePorts() got master peer port = %v, want between 14000 and 16000", tt.args.value.Master.Ports[MasterPeerName])
+				}
+				if tt.args.value.Worker.Ports[WorkerRPCName] < 14000 || tt.args.value.Worker.Ports[WorkerRPCName] > 16000 {
+					t.Errorf("allocatePorts() got worker rpc port = %v, want between 14000 and 16000", tt.args.value.Worker.Ports[WorkerRPCName])
+				}
+				if tt.args.value.Worker.Ports[WorkerExporterName] < 14000 || tt.args.value.Worker.Ports[WorkerExporterName] > 16000 {
+					t.Errorf("allocatePorts() got worker exporter port = %v, want between 14000 and 16000", tt.args.value.Worker.Ports[WorkerExporterName])
+				}
+			}
+		})
+	}
+}
+
+func TestVineyardEngineTransformPodMetadata(t *testing.T) {
+	engine := &VineyardEngine{Log: fake.NullLogger()}
+
+	type testCase struct {
+		Name    string
+		Runtime *datav1alpha1.VineyardRuntime
+		Value   *Vineyard
+
+		wantValue *Vineyard
+	}
+
+	testCases := []testCase{
+		{
+			Name: "set_common_labels_and_annotations",
+			Runtime: &datav1alpha1.VineyardRuntime{
+				Spec: datav1alpha1.VineyardRuntimeSpec{
+					PodMetadata: datav1alpha1.PodMetadata{
+						Labels:      map[string]string{"common-key": "common-value"},
+						Annotations: map[string]string{"common-annotation": "val"},
+					},
+				},
+			},
+			Value: &Vineyard{},
+			wantValue: &Vineyard{
+				Master: Master{
+					Labels:      map[string]string{"common-key": "common-value"},
+					Annotations: map[string]string{"common-annotation": "val"},
+				},
+				Worker: Worker{
+					Labels:      map[string]string{"common-key": "common-value"},
+					Annotations: map[string]string{"common-annotation": "val"},
+				},
+				Fuse: Fuse{
+					Labels:      map[string]string{"common-key": "common-value"},
+					Annotations: map[string]string{"common-annotation": "val"},
+				},
+			},
+		},
+		{
+			Name: "set_master_and_workers_labels_and_annotations",
+			Runtime: &datav1alpha1.VineyardRuntime{
+				Spec: datav1alpha1.VineyardRuntimeSpec{
+					PodMetadata: datav1alpha1.PodMetadata{
+						Labels:      map[string]string{"common-key": "common-value"},
+						Annotations: map[string]string{"common-annotation": "val"},
+					},
+					Master: datav1alpha1.MasterSpec{
+						VineyardCompTemplateSpec: datav1alpha1.VineyardCompTemplateSpec{
+							PodMetadata: datav1alpha1.PodMetadata{
+								Labels:      map[string]string{"common-key": "master-value"},
+								Annotations: map[string]string{"common-annotation": "master-val"},
+							},
+						},
+					},
+					Worker: datav1alpha1.VineyardCompTemplateSpec{
+						PodMetadata: datav1alpha1.PodMetadata{
+							Labels:      map[string]string{"common-key": "worker-value"},
+							Annotations: map[string]string{"common-annotation": "worker-val"},
+						},
+					},
+				},
+			},
+			Value: &Vineyard{},
+			wantValue: &Vineyard{
+				Master: Master{
+					Labels:      map[string]string{"common-key": "master-value"},
+					Annotations: map[string]string{"common-annotation": "master-val"},
+				},
+				Worker: Worker{
+					Labels:      map[string]string{"common-key": "worker-value"},
+					Annotations: map[string]string{"common-annotation": "worker-val"},
+				},
+				Fuse: Fuse{
+					Labels:      map[string]string{"common-key": "common-value"},
+					Annotations: map[string]string{"common-annotation": "val"},
+				},
+			},
+		},
+	}
+
+	for _, tt := range testCases {
+		engine.transformPodMetadata(tt.Runtime, tt.Value)
+
+		if !reflect.DeepEqual(tt.Value, tt.wantValue) {
+			t.Fatalf("test name: %s. Expect value %v, but got %v", tt.Name, tt.wantValue, tt.Value)
+		}
+	}
+}