Creates volume mount for kubeconfig file
This commit is contained in:
parent
c348ca9849
commit
b5e5570145
|
@ -112,15 +112,17 @@
|
|||
|
||||
public class VolumeMount
|
||||
{
|
||||
public VolumeMount(string volumeName, string mountPath, string resourceQuantity)
|
||||
public VolumeMount(string volumeName, string mountPath, string? subPath = null, string? resourceQuantity = null)
|
||||
{
|
||||
VolumeName = volumeName;
|
||||
MountPath = mountPath;
|
||||
SubPath = subPath;
|
||||
ResourceQuantity = resourceQuantity;
|
||||
}
|
||||
|
||||
public string VolumeName { get; }
|
||||
public string MountPath { get; }
|
||||
public string ResourceQuantity { get; }
|
||||
public string? SubPath { get; }
|
||||
public string? ResourceQuantity { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,12 +97,17 @@ namespace KubernetesWorkflow
|
|||
podAnnotations.Add(name, value);
|
||||
}
|
||||
|
||||
protected void AddVolume(string name, string mountPath, string subPath)
|
||||
{
|
||||
volumeMounts.Add(new VolumeMount(name, mountPath, subPath));
|
||||
}
|
||||
|
||||
protected void AddVolume(string mountPath, ByteSize volumeSize)
|
||||
{
|
||||
volumeMounts.Add(new VolumeMount(
|
||||
$"autovolume-{Guid.NewGuid().ToString().ToLowerInvariant()}",
|
||||
mountPath,
|
||||
volumeSize.ToSuffixNotation()));
|
||||
resourceQuantity: volumeSize.ToSuffixNotation()));
|
||||
}
|
||||
|
||||
protected void Additional(object userData)
|
||||
|
|
|
@ -441,7 +441,8 @@ namespace KubernetesWorkflow
|
|||
return new V1VolumeMount
|
||||
{
|
||||
Name = v.VolumeName,
|
||||
MountPath = v.MountPath
|
||||
MountPath = v.MountPath,
|
||||
SubPath = v.SubPath,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -457,6 +458,12 @@ namespace KubernetesWorkflow
|
|||
|
||||
private V1Volume CreateVolume(VolumeMount v)
|
||||
{
|
||||
var resourcesRequests = new Dictionary<string, ResourceQuantity>();
|
||||
if (v.ResourceQuantity != null)
|
||||
{
|
||||
resourcesRequests.Add("storage", new ResourceQuantity(v.ResourceQuantity));
|
||||
}
|
||||
|
||||
client.Run(c => c.CreateNamespacedPersistentVolumeClaim(new V1PersistentVolumeClaim
|
||||
{
|
||||
ApiVersion = "v1",
|
||||
|
@ -472,10 +479,7 @@ namespace KubernetesWorkflow
|
|||
},
|
||||
Resources = new V1ResourceRequirements
|
||||
{
|
||||
Requests = new Dictionary<string, ResourceQuantity>
|
||||
{
|
||||
{"storage", new ResourceQuantity(v.ResourceQuantity) }
|
||||
}
|
||||
Requests = resourcesRequests
|
||||
}
|
||||
}
|
||||
}, K8sNamespace));
|
||||
|
|
|
@ -20,6 +20,8 @@ namespace DeployAndRunPlugin
|
|||
AddEnvVar("DNR_NAME", setup.Name);
|
||||
AddEnvVar("DNR_FILTER", setup.Filter);
|
||||
AddEnvVar("DNR_DURATION", setup.Duration.TotalSeconds.ToString());
|
||||
|
||||
AddVolume(name: "kubeconfig", mountPath: "/opt/kubeconfig.yaml", subPath: "kubeconfig.yaml");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue