diff --git a/apis/core/v1alpha2/core_trait_volume_types.go b/apis/core/v1alpha2/core_trait_volume_types.go index f330b40..0259c88 100644 --- a/apis/core/v1alpha2/core_trait_volume_types.go +++ b/apis/core/v1alpha2/core_trait_volume_types.go @@ -18,6 +18,7 @@ package v1alpha2 import ( runtimev1alpha1 "github.com/crossplane/crossplane-runtime/apis/core/v1alpha1" + v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/xishengcai/oam/pkg/oam" @@ -41,9 +42,15 @@ type VolumeMountItem struct { // PathItem define storageClass, size, path, name type PathItem struct { - Name string `json:"name"` - PersistentVolumeClaim string `json:"persistentVolumeClaim"` - Path string `json:"path"` + // set volumeMount and volumes link name + Name string `json:"name"` + + // Path is the name of directory in container + Path string `json:"path"` + + // It's either PVC or HostPath + PersistentVolumeClaim string `json:"persistentVolumeClaim,omitempty"` + HostPath *v1.HostPathVolumeSource `json:"hostPath,omitempty"` } // A VolumeTraitStatus represents the observed state of a diff --git a/apis/core/v1alpha2/volume_claim.go b/apis/core/v1alpha2/volume_claim.go index 1598b12..d86c335 100644 --- a/apis/core/v1alpha2/volume_claim.go +++ b/apis/core/v1alpha2/volume_claim.go @@ -10,9 +10,9 @@ import ( var _ oam.Object = &VolumeClaim{} type VolumeClaimSpec struct { - // type enum:"HostPath,StorageClass", default is StorageClass - Type string `json:"type,omitempty"` - HostPath string `json:"hostPath,omitempty"` + // type enum:"StorageClass", default is StorageClass + Type string `json:"type,omitempty"` + //HostPath string `json:"hostPath,omitempty"` StorageClassName string `json:"storageClassName,omitempty"` // type enum:"ReadWriteOnce,ReadOnlyMany,ReadWriteMany" // ReadWriteOnce – the volume can be mounted as read-write by a single node @@ -61,9 +61,9 @@ type VolumeClaimList struct { type VolumeClaimConfig struct { Name string `json:"name"` - // +kubebuilder:validation:Enum=HostPath;StorageClass - Type string `json:"type,omitempty"` - HostPath string `json:"hostPath,omitempty"` + // +kubebuilder:validation:Enum=StorageClass + Type string `json:"type,omitempty"` + //HostPath string `json:"hostPath,omitempty"` StorageClassName string `json:"storageClassName,omitempty"` Size string `json:"size,omitempty"` AccessMode v1.PersistentVolumeAccessMode `json:"accessMode,omitempty"` diff --git a/apis/core/v1alpha2/zz_generated.deepcopy.go b/apis/core/v1alpha2/zz_generated.deepcopy.go index 908481d..4d8251c 100644 --- a/apis/core/v1alpha2/zz_generated.deepcopy.go +++ b/apis/core/v1alpha2/zz_generated.deepcopy.go @@ -1524,6 +1524,11 @@ func (in *MemoryResources) DeepCopy() *MemoryResources { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PathItem) DeepCopyInto(out *PathItem) { *out = *in + if in.HostPath != nil { + in, out := &in.HostPath, &out.HostPath + *out = new(v1.HostPathVolumeSource) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PathItem. @@ -1912,7 +1917,9 @@ func (in *VolumeMountItem) DeepCopyInto(out *VolumeMountItem) { if in.Paths != nil { in, out := &in.Paths, &out.Paths *out = make([]PathItem, len(*in)) - copy(*out, *in) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } } } diff --git a/charts/oam-kubernetes-runtime/crds/core.oam.dev_applicationconfigurations.yaml b/charts/oam-kubernetes-runtime/crds/core.oam.dev_applicationconfigurations.yaml index 1e8f471..0295947 100644 --- a/charts/oam-kubernetes-runtime/crds/core.oam.dev_applicationconfigurations.yaml +++ b/charts/oam-kubernetes-runtime/crds/core.oam.dev_applicationconfigurations.yaml @@ -244,11 +244,11 @@ spec: size: type: string storageClassName: + description: HostPath string `json:"hostPath,omitempty"` type: string type: enum: - - HostPath - - StorageClass + - StorageClass type: string required: - name @@ -374,9 +374,9 @@ spec: description: UID of the referenced object. type: string required: - - apiVersion - - kind - - name + - apiVersion + - kind + - name type: object type: object type: array @@ -402,9 +402,9 @@ spec: description: UID of the referenced object. type: string required: - - apiVersion - - kind - - name + - apiVersion + - kind + - name type: object type: array status: diff --git a/charts/oam-kubernetes-runtime/crds/core.oam.dev_containerizedworkloads.yaml b/charts/oam-kubernetes-runtime/crds/core.oam.dev_containerizedworkloads.yaml index c7adb90..2e6896b 100644 --- a/charts/oam-kubernetes-runtime/crds/core.oam.dev_containerizedworkloads.yaml +++ b/charts/oam-kubernetes-runtime/crds/core.oam.dev_containerizedworkloads.yaml @@ -438,16 +438,16 @@ spec: kind: description: Kind of the referenced object. enum: - - HelmRelease + - HelmRelease - ContainerizedWorkload - - Third + - Third type: string name: description: Name of the referenced object. type: string required: - - kind - - name + - kind + - name type: object type: array forceUpdateTimestamp: @@ -483,8 +483,8 @@ spec: description: The name of the secret. type: string required: - - key - - name + - key + - name type: object path: description: Path within the container at which the configuration file should be written. @@ -496,8 +496,8 @@ spec: description: Value that should be written to the configuration file. type: string required: - - path - - value + - path + - value type: object type: array env: @@ -515,8 +515,8 @@ spec: description: The name of the secret. type: string required: - - key - - name + - key + - name type: object name: description: Name of the environment variable. Must be composed of valid Unicode letter and number characters, as well as _ and -. @@ -526,7 +526,7 @@ spec: description: Value of the environment variable. type: string required: - - name + - name type: object type: array image: @@ -569,8 +569,8 @@ spec: description: The header field value type: string required: - - name - - value + - name + - value type: object type: array path: @@ -578,15 +578,15 @@ spec: type: string port: anyOf: - - type: integer - - type: string + - type: integer + - type: string description: Name or number of the port to access on the container. Number must be in the range 1 to 65535. Name must be an IANA_SVC_NAME. x-kubernetes-int-or-string: true scheme: description: Scheme to use for connecting to the host. Defaults to HTTP. type: string required: - - port + - port type: object initialDelaySeconds: description: 'Number of seconds after the container has started before liveness probes are initiated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' @@ -608,12 +608,12 @@ spec: type: string port: anyOf: - - type: integer - - type: string + - type: integer + - type: string description: Number or name of the port to access on the container. Number must be in the range 1 to 65535. Name must be an IANA_SVC_NAME. x-kubernetes-int-or-string: true required: - - port + - port type: object timeoutSeconds: description: 'Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' @@ -650,8 +650,8 @@ spec: - SCTP type: string required: - - containerPort - - name + - containerPort + - name type: object type: array readinessProbe: @@ -688,8 +688,8 @@ spec: description: The header field value type: string required: - - name - - value + - name + - value type: object type: array path: @@ -697,15 +697,15 @@ spec: type: string port: anyOf: - - type: integer - - type: string + - type: integer + - type: string description: Name or number of the port to access on the container. Number must be in the range 1 to 65535. Name must be an IANA_SVC_NAME. x-kubernetes-int-or-string: true scheme: description: Scheme to use for connecting to the host. Defaults to HTTP. type: string required: - - port + - port type: object initialDelaySeconds: description: 'Number of seconds after the container has started before liveness probes are initiated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' @@ -727,12 +727,12 @@ spec: type: string port: anyOf: - - type: integer - - type: string + - type: integer + - type: string description: Number or name of the port to access on the container. Number must be in the range 1 to 65535. Name must be an IANA_SVC_NAME. x-kubernetes-int-or-string: true required: - - port + - port type: object timeoutSeconds: description: 'Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' @@ -751,7 +751,7 @@ spec: description: Required CPU count. 1.0 represents one CPU core. type: string required: - - required + - required type: object extended: description: Extended resources required by this container. @@ -763,13 +763,13 @@ spec: type: string required: anyOf: - - type: integer - - type: string + - type: integer + - type: string description: Required extended resource(s), e.g. 8 or "very-cool-widget" x-kubernetes-int-or-string: true required: - - name - - required + - name + - required type: object type: array gpu: @@ -779,7 +779,7 @@ spec: description: Required GPU count. type: string required: - - required + - required type: object memory: description: Memory required by this container. @@ -790,7 +790,7 @@ spec: description: Required memory. type: string required: - - required + - required type: object volumes: description: Volumes required by this container. @@ -800,8 +800,8 @@ spec: accessMode: description: AccessMode of this volume; RO (read only) or RW (read and write). enum: - - RO - - RW + - RO + - RW type: string disk: description: Disk requirements of this volume. @@ -813,7 +813,7 @@ spec: description: Required disk space. type: string required: - - required + - required type: object mountPath: description: MountPath at which this volume will be mounted within its container. @@ -824,21 +824,21 @@ spec: sharingPolicy: description: SharingPolicy of this volume; Exclusive or Shared. enum: - - Exclusive - - Shared + - Exclusive + - Shared type: string required: - - mountPath - - name + - mountPath + - name type: object type: array required: - - cpu - - memory + - cpu + - memory type: object required: - - image - - name + - image + - name type: object type: array nodeSelector: @@ -849,8 +849,8 @@ spec: osType: description: OperatingSystem required by this workload. enum: - - linux - - windows + - linux + - windows type: string pointToGrayName: description: old grey workload name need modify match selector @@ -869,7 +869,7 @@ spec: description: Type support deployment and statefulSet type: string required: - - containers + - containers type: object status: description: A ContainerizedWorkloadStatus represents the observed state of a ContainerizedWorkload. diff --git a/charts/oam-kubernetes-runtime/crds/core.oam.dev_volumeclaims.yaml b/charts/oam-kubernetes-runtime/crds/core.oam.dev_volumeclaims.yaml index bcc5021..37cc6e7 100644 --- a/charts/oam-kubernetes-runtime/crds/core.oam.dev_volumeclaims.yaml +++ b/charts/oam-kubernetes-runtime/crds/core.oam.dev_volumeclaims.yaml @@ -42,9 +42,10 @@ spec: size: type: string storageClassName: + description: HostPath string `json:"hostPath,omitempty"` type: string type: - description: type enum:"HostPath,StorageClass", default is StorageClass + description: type enum:"StorageClass", default is StorageClass type: string type: object status: @@ -86,8 +87,8 @@ spec: format: int64 type: integer required: - - name - - revision + - name + - revision type: object observedGeneration: description: The generation observed by the component controller. @@ -111,9 +112,9 @@ spec: description: UID of the referenced object. type: string required: - - apiVersion - - kind - - name + - apiVersion + - kind + - name type: object type: array type: object diff --git a/charts/oam-kubernetes-runtime/crds/core.oam.dev_volumetraits.yaml b/charts/oam-kubernetes-runtime/crds/core.oam.dev_volumetraits.yaml index c67329c..62760de 100644 --- a/charts/oam-kubernetes-runtime/crds/core.oam.dev_volumetraits.yaml +++ b/charts/oam-kubernetes-runtime/crds/core.oam.dev_volumetraits.yaml @@ -47,16 +47,30 @@ spec: items: description: PathItem define storageClass, size, path, name properties: + hostPath: + description: Represents a host path mapped into a pod. Host path volumes do not support ownership management or SELinux relabeling. + properties: + path: + description: 'Path of the directory on the host. If the path is a symlink, it will follow the link to the real path. More info: https://kubernetes.io/docs/concepts/storage/volumes#hostpath' + type: string + type: + description: 'Type for HostPath Volume Defaults to "" More info: https://kubernetes.io/docs/concepts/storage/volumes#hostpath' + type: string + required: + - path + type: object name: + description: set volumeMount and volumes link name type: string path: + description: Path is the name of directory in container type: string persistentVolumeClaim: + description: It's either PVC or HostPath type: string required: - name - path - - persistentVolumeClaim type: object type: array required: diff --git a/examples/containerized-workload-hostpath/sample_application_config.yaml b/examples/containerized-workload-hostpath/sample_application_config.yaml index e2e3e4d..24d6fc5 100644 --- a/examples/containerized-workload-hostpath/sample_application_config.yaml +++ b/examples/containerized-workload-hostpath/sample_application_config.yaml @@ -16,11 +16,8 @@ spec: - containerIndex: 0 paths: - path: /var/log/test - hostPath: /data/test - type: HostPath + hostPath: + path: /data/x + type: DirectoryOrCreate name: path-1 - - size: 20Gi - path: /var/log/test3 - storageClassName: local-path - name: path-2 diff --git a/legacy/charts/oam-kubernetes-runtime-legacy/crds/core.oam.dev_servicetraits.yaml b/legacy/charts/oam-kubernetes-runtime-legacy/crds/core.oam.dev_servicetraits.yaml new file mode 100644 index 0000000..ad34550 --- /dev/null +++ b/legacy/charts/oam-kubernetes-runtime-legacy/crds/core.oam.dev_servicetraits.yaml @@ -0,0 +1,160 @@ + +--- +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.2.4 + creationTimestamp: null + name: servicetraits.core.oam.dev +spec: + group: core.oam.dev + names: + categories: + - crossplane + - oam + kind: ServiceTrait + listKind: ServiceTraitList + plural: servicetraits + singular: servicetrait + scope: Namespaced + subresources: + status: {} + validation: + openAPIV3Schema: + description: A ServiceTrait determines how many replicas a workload should have. + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: ServiceTraitSpec service trait + properties: + ports: + description: 'The list of ports that are exposed by this service. More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies' + items: + description: ServicePort contains information on service's port. + properties: + appProtocol: + description: The application protocol for this port. This field follows standard Kubernetes label syntax. Un-prefixed names are reserved for IANA standard service names (as per RFC-6335 and http://www.iana.org/assignments/service-names). Non-standard protocols should use prefixed names such as mycompany.com/my-custom-protocol. Field can be enabled with ServiceAppProtocol feature gate. + type: string + name: + description: The name of this port within the service. This must be a DNS_LABEL. All ports within a ServiceSpec must have unique names. When considering the endpoints for a Service, this must match the 'name' field in the EndpointPort. Optional if only one ServicePort is defined on this service. + type: string + nodePort: + description: 'The port on each node on which this service is exposed when type=NodePort or LoadBalancer. Usually assigned by the system. If specified, it will be allocated to the service if unused or else creation of the service will fail. Default is to auto-allocate a port if the ServiceType of this Service requires one. More info: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport' + format: int32 + type: integer + port: + description: The port that will be exposed by this service. + format: int32 + type: integer + protocol: + description: The IP protocol for this port. Supports "TCP", "UDP", and "SCTP". Default is TCP. + type: string + targetPort: + anyOf: + - type: integer + - type: string + description: 'Number or name of the port to access on the pods targeted by the service. Number must be in the range 1 to 65535. Name must be an IANA_SVC_NAME. If this is a string, it will be looked up as a named port in the target Pod''s container ports. If this is not specified, the value of the ''port'' field is used (an identity map). This field is ignored for services with clusterIP=None, and should be omitted or set equal to the ''port'' field. More info: https://kubernetes.io/docs/concepts/services-networking/service/#defining-a-service' + x-kubernetes-int-or-string: true + required: + - port + type: object + type: array + type: + description: 'type determines how the Service is exposed. Defaults to ClusterIP. Valid options are ExternalName, ClusterIP, NodePort, and LoadBalancer. "ExternalName" maps to the specified externalName. "ClusterIP" allocates a cluster-internal IP address for load-balancing to endpoints. Endpoints are determined by the selector or if that is not specified, by manual construction of an Endpoints object. If clusterIP is "None", no virtual IP is allocated and the endpoints are published as a set of endpoints rather than a stable IP. "NodePort" builds on ClusterIP and allocates a port on every node which routes to the clusterIP. "LoadBalancer" builds on NodePort and creates an external load-balancer (if supported in the current cloud) which routes to the clusterIP. More info: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types' + type: string + workloadRef: + description: A TypedReference refers to an object by Name, Kind, and APIVersion. It is commonly used to reference cluster-scoped objects or objects where the namespace is already known. + properties: + apiVersion: + description: APIVersion of the referenced object. + type: string + kind: + description: Kind of the referenced object. + type: string + name: + description: Name of the referenced object. + type: string + uid: + description: UID of the referenced object. + type: string + required: + - apiVersion + - kind + - name + type: object + type: object + status: + description: A CanaryTraitStatus represents the observed state of a CanaryTrait. + properties: + conditions: + description: Conditions of the resource. + items: + description: A Condition that may apply to a resource. + properties: + lastTransitionTime: + description: LastTransitionTime is the last time this condition transitioned from one status to another. + format: date-time + type: string + message: + description: A Message containing details about this condition's last transition from one status to another, if any. + type: string + reason: + description: A Reason for this condition's last transition from one status to another. + type: string + status: + description: Status of this condition; is it currently True, False, or Unknown? + type: string + type: + description: Type of this condition. At most one of each condition type may apply to a resource at any point in time. + type: string + required: + - lastTransitionTime + - reason + - status + - type + type: object + type: array + resources: + description: Resources managed by this canary trait + items: + description: A TypedReference refers to an object by Name, Kind, and APIVersion. It is commonly used to reference cluster-scoped objects or objects where the namespace is already known. + properties: + apiVersion: + description: APIVersion of the referenced object. + type: string + kind: + description: Kind of the referenced object. + type: string + name: + description: Name of the referenced object. + type: string + uid: + description: UID of the referenced object. + type: string + required: + - apiVersion + - kind + - name + type: object + type: array + type: object + type: object + version: v1alpha2 + versions: + - name: v1alpha2 + served: true + storage: true +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/legacy/charts/oam-kubernetes-runtime-legacy/crds/core.oam.dev_volumeclaims.yaml b/legacy/charts/oam-kubernetes-runtime-legacy/crds/core.oam.dev_volumeclaims.yaml new file mode 100644 index 0000000..1a9ba13 --- /dev/null +++ b/legacy/charts/oam-kubernetes-runtime-legacy/crds/core.oam.dev_volumeclaims.yaml @@ -0,0 +1,128 @@ + +--- +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.2.4 + creationTimestamp: null + name: volumeclaims.core.oam.dev +spec: + group: core.oam.dev + names: + categories: + - crossplane + - oam + kind: VolumeClaim + listKind: VolumeClaimList + plural: volumeclaims + singular: volumeclaim + scope: Namespaced + subresources: + status: {} + validation: + openAPIV3Schema: + description: A VolumeClaim describes how an OAM VolumeClaim kind may be instantiated. + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + properties: + hostPath: + type: string + size: + type: string + storageClassName: + type: string + type: + description: type enum:"HostPath,StorageClass", default is StorageClass + type: string + type: object + status: + properties: + conditions: + description: Conditions of the resource. + items: + description: A Condition that may apply to a resource. + properties: + lastTransitionTime: + description: LastTransitionTime is the last time this condition transitioned from one status to another. + format: date-time + type: string + message: + description: A Message containing details about this condition's last transition from one status to another, if any. + type: string + reason: + description: A Reason for this condition's last transition from one status to another. + type: string + status: + description: Status of this condition; is it currently True, False, or Unknown? + type: string + type: + description: Type of this condition. At most one of each condition type may apply to a resource at any point in time. + type: string + required: + - lastTransitionTime + - reason + - status + - type + type: object + type: array + latestRevision: + description: LatestRevision of applicationConfig + properties: + name: + type: string + revision: + format: int64 + type: integer + required: + - name + - revision + type: object + observedGeneration: + description: The generation observed by the component controller. + format: int64 + type: integer + resources: + description: Resources managed by this canary trait + items: + description: A TypedReference refers to an object by Name, Kind, and APIVersion. It is commonly used to reference cluster-scoped objects or objects where the namespace is already known. + properties: + apiVersion: + description: APIVersion of the referenced object. + type: string + kind: + description: Kind of the referenced object. + type: string + name: + description: Name of the referenced object. + type: string + uid: + description: UID of the referenced object. + type: string + required: + - apiVersion + - kind + - name + type: object + type: array + type: object + type: object + version: v1alpha2 + versions: + - name: v1alpha2 + served: true + storage: true +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/pkg/controller/v1alpha2/applicationconfiguration/volumeclaim_render.go b/pkg/controller/v1alpha2/applicationconfiguration/volumeclaim_render.go index 38c5d89..9aaa510 100644 --- a/pkg/controller/v1alpha2/applicationconfiguration/volumeclaim_render.go +++ b/pkg/controller/v1alpha2/applicationconfiguration/volumeclaim_render.go @@ -62,7 +62,6 @@ func (r *volumeClaims) renderVolumeClaims(ctx context.Context, ac *v1alpha2.Appl }, Spec: v1alpha2.VolumeClaimSpec{ Type: vcc.Type, - HostPath: vcc.HostPath, StorageClassName: vcc.StorageClassName, AccessMode: vcc.AccessMode, Size: vcc.Size, diff --git a/pkg/controller/v1alpha2/core/traits/volumeclaimtrait/controller.go b/pkg/controller/v1alpha2/core/traits/volumeclaimtrait/controller.go index d6c721c..5a3e431 100644 --- a/pkg/controller/v1alpha2/core/traits/volumeclaimtrait/controller.go +++ b/pkg/controller/v1alpha2/core/traits/volumeclaimtrait/controller.go @@ -124,6 +124,7 @@ func (r *Reconcile) Reconcile(req ctrl.Request) (ctrl.Result, error) { oam.LabelVolumeClaim: labelName, }, } + // generate pvc switch volumeClaim.Spec.Type { case StorageClass: diff --git a/pkg/controller/v1alpha2/core/traits/volumetrait/volumetrait_controller.go b/pkg/controller/v1alpha2/core/traits/volumetrait/volumetrait_controller.go index a918986..528a31e 100644 --- a/pkg/controller/v1alpha2/core/traits/volumetrait/volumetrait_controller.go +++ b/pkg/controller/v1alpha2/core/traits/volumetrait/volumetrait_controller.go @@ -182,8 +182,8 @@ func (r *Reconcile) mountVolume(ctx context.Context, volumeTrait *oamv1alpha2.Vo var volumeMounts []v1.VolumeMount for _, path := range item.Paths { volumeMount := v1.VolumeMount{ - Name: path.PersistentVolumeClaim, MountPath: path.Path, + Name: path.Name, } volumeMounts = append(volumeMounts, volumeMount) var volumeClaim oamv1alpha2.VolumeClaim @@ -215,7 +215,7 @@ func (r *Reconcile) mountVolume(ctx context.Context, volumeTrait *oamv1alpha2.Vo if item.IsInitContainer { initContainer, _ := initContainers.([]interface{})[item.ContainerIndex].(map[string]interface{}) oldVolumeMounts := getVolumeMountsFromContainer(initContainer) - // 找出非pvc,hostPath 的volumeMounts + // 找出非pvc,hostPath 的volumeMounts,例如configmap volumeMounts = append(volumeMounts, findConfigVolumes(oldVolumes, oldVolumeMounts)...) initContainer["volumeMounts"] = volumeMounts } else {