Skip to content

Commit

Permalink
Fixed support for SGX on exposed services
Browse files Browse the repository at this point in the history
  • Loading branch information
catttam committed Oct 26, 2023
1 parent c5e2fdd commit 83222e9
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions pkg/utils/expose.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,17 +211,7 @@ func getPodTemplateSpec(e Expose) v1.PodTemplateSpec {
ContainerPort: int32(e.Port),
}
cores := resource.NewMilliQuantity(500, resource.DecimalSI)
var container v1.Container = v1.Container{
Name: e.Name,
Image: e.Image,
Env: types.ConvertEnvVars(e.Variables),
Ports: []v1.ContainerPort{ports},
Resources: v1.ResourceRequirements{
Requests: v1.ResourceList{
"cpu": *cores,
},
},
}

template := v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Name: e.Name,
Expand All @@ -232,19 +222,31 @@ func getPodTemplateSpec(e Expose) v1.PodTemplateSpec {
},
Spec: v1.PodSpec{
InitContainers: []v1.Container{},
Containers: []v1.Container{container},
Containers: []v1.Container{
{
Name: e.Name,
Image: e.Image,
Env: types.ConvertEnvVars(e.Variables),
Ports: []v1.ContainerPort{ports},
Resources: v1.ResourceRequirements{
Requests: v1.ResourceList{
"cpu": *cores,
},
},
},
},
},
}

if e.EnableSGX {
types.SetSecurityContext(&template.Spec)
sgx, _ := resource.ParseQuantity("1")
container.Resources.Limits["sgx.intel.com/enclave"] = sgx
template.Spec.Containers[0].Resources.Limits["sgx.intel.com/enclave"] = sgx
}

if e.EnableGPU {
gpu, _ := resource.ParseQuantity("1")
container.Resources.Limits["nvidia.com/gpu"] = gpu
template.Spec.Containers[0].Resources.Limits["nvidia.com/gpu"] = gpu
}

return template
Expand Down

0 comments on commit 83222e9

Please sign in to comment.