Skip to content

Commit

Permalink
Add support for Kubernetes metadata (labels/annotations) (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
0x2b3bfa0 authored Oct 12, 2021
1 parent 4194d33 commit 82d1b60
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions iterative/kubernetes/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ func ResourceMachineCreate(ctx context.Context, d *terraform_schema.ResourceData
jobName := d.Id()
jobNamespace := namespace

// Define the metadata
jobMetadata := map[string]string{}
for key, value := range d.Get("metadata").(map[string]interface{}) {
jobMetadata[key] = value.(string)
}

// Define the accelerator settings (i.e. GPU type, model, ...)
jobNodeSelector := map[string]string{}
jobAccelerator := instanceType["accelerator"]["model"]
Expand Down Expand Up @@ -88,8 +94,10 @@ func ResourceMachineCreate(ctx context.Context, d *terraform_schema.ResourceData

job := kubernetes_batch.Job{
ObjectMeta: kubernetes_meta.ObjectMeta{
Name: jobName,
Namespace: jobNamespace,
Name: jobName,
Namespace: jobNamespace,
Labels: jobMetadata,
Annotations: jobMetadata,
},
Spec: kubernetes_batch.JobSpec{
BackoffLimit: &jobBackoffLimit,
Expand Down

0 comments on commit 82d1b60

Please sign in to comment.