Skip to content
v2.278.0

HostPathVolumeOptions Struct ​

Options for a kubernetes HostPath volume.

Example ​

ts
declare const jobDefn: batch.EksJobDefinition;
jobDefn.container.addVolume(batch.EksVolume.emptyDir({
  name: 'emptyDir',
  mountPath: '/Volumes/emptyDir',
}));
jobDefn.container.addVolume(batch.EksVolume.hostPath({
  name: 'hostPath',
  hostPath: '/sys',
  mountPath: '/Volumes/hostPath',
}));
jobDefn.container.addVolume(batch.EksVolume.secret({
  name: 'secret',
  optional: true,
  mountPath: '/Volumes/secret',
  secretName: 'mySecret',
}));
python
# job_defn: batch.EksJobDefinition

job_defn.container.add_volume(batch.EksVolume.empty_dir(
    name="emptyDir",
    mount_path="/Volumes/emptyDir"
))
job_defn.container.add_volume(batch.EksVolume.host_path(
    name="hostPath",
    host_path="/sys",
    mount_path="/Volumes/hostPath"
))
job_defn.container.add_volume(batch.EksVolume.secret(
    name="secret",
    optional=True,
    mount_path="/Volumes/secret",
    secret_name="mySecret"
))
java
EksJobDefinition jobDefn;

jobDefn.container.addVolume(EksVolume.emptyDir(EmptyDirVolumeOptions.builder()
        .name("emptyDir")
        .mountPath("/Volumes/emptyDir")
        .build()));
jobDefn.container.addVolume(EksVolume.hostPath(HostPathVolumeOptions.builder()
        .name("hostPath")
        .hostPath("/sys")
        .mountPath("/Volumes/hostPath")
        .build()));
jobDefn.container.addVolume(EksVolume.secret(SecretPathVolumeOptions.builder()
        .name("secret")
        .optional(true)
        .mountPath("/Volumes/secret")
        .secretName("mySecret")
        .build()));
csharp
// Install: dotnet add package Amazon.CDK.Lib
EksJobDefinition jobDefn;

jobDefn.Container.AddVolume(EksVolume.EmptyDir(new EmptyDirVolumeOptions {
    Name = "emptyDir",
    MountPath = "/Volumes/emptyDir"
}));
jobDefn.Container.AddVolume(EksVolume.HostPath(new HostPathVolumeOptions {
    Name = "hostPath",
    HostPath = "/sys",
    MountPath = "/Volumes/hostPath"
}));
jobDefn.Container.AddVolume(EksVolume.Secret(new SecretPathVolumeOptions {
    Name = "secret",
    Optional = true,
    MountPath = "/Volumes/secret",
    SecretName = "mySecret"
}));
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var jobDefn EksJobDefinition

jobDefn.Container.AddVolume(batch.EksVolume_EmptyDir(&EmptyDirVolumeOptions{
	Name: jsii.String("emptyDir"),
	MountPath: jsii.String("/Volumes/emptyDir"),
}))
jobDefn.Container.AddVolume(batch.EksVolume_HostPath(&HostPathVolumeOptions{
	Name: jsii.String("hostPath"),
	HostPath: jsii.String("/sys"),
	MountPath: jsii.String("/Volumes/hostPath"),
}))
jobDefn.Container.AddVolume(batch.EksVolume_Secret(&SecretPathVolumeOptions{
	Name: jsii.String("secret"),
	Optional: jsii.Boolean(true),
	MountPath: jsii.String("/Volumes/secret"),
	SecretName: jsii.String("mySecret"),
}))

Properties ​

hostPathstringhost_pathstrhostPathStringHostPathstringHostPath*string required #
The path of the file or directory on the host to mount into containers on the pod.

Note: HothPath Volumes present many security risks, and should be avoided when possible.

mountPathoptionalstringmount_pathoptionalstrmountPathoptionalStringMountPathoptionalstringMountPathoptional*string #
The path on the container where the volume is mounted.

Default: the volume is not mounted

namestringnamestrnameStringNamestringName*string required #
The name of this volume.

The name must be a valid DNS subdomain name.

readonlyoptionalbooleanreadonlyoptionalboolreadonlyoptionalBooleanReadonlyoptionalboolReadonlyoptional*bool = false #
If specified, the container has readonly access to the volume.

Otherwise, the container has read/write access.