import ( k8sapi "k8s.io/kubernetes/pkg/api" v1 "k8s.io/api/core/v1" ) podSpec := k8sapi.PodSpec{ Containers: []v1.Container{ { Name: "my-container", Image: "my-image", Resources: v1.ResourceRequirements{ Limits: v1.ResourceList{ v1.ResourceCPU: resource.MustParse("1"), v1.ResourceMemory: resource.MustParse("512Mi"), }, Requests: v1.ResourceList{ v1.ResourceCPU: resource.MustParse("500m"), v1.ResourceMemory: resource.MustParse("256Mi"), }, }, }, }, }
podSpec := k8sapi.PodSpec{ Containers: []v1.Container{ { Name: "my-container", Image: "my-image", VolumeMounts: []v1.VolumeMount{ { MountPath: "/data", Name: "my-volume", }, }, }, }, Volumes: []v1.Volume{ { Name: "my-volume", PersistentVolumeClaim: &v1.PersistentVolumeClaimVolumeSource{ ClaimName: "my-pvc", }, }, }, }In both examples, we see the use of the k8s.io/kubernetes/pkg/api PodSpec package library, which defines and sets container and pod attributes for Kubernetes Pods. These examples show how the PodSpec can be used to define resource limits and persistent volume mounting for the containers in a pod.