func writePodTemplateSpec(r *schema.ResourceData, item *api.PodTemplateSpec) error {
	var template map[string]interface{}
	if x, ok := extractSingleMap(r.Get("template")); ok {
		template = x
	}
	if template == nil {
		return fmt.Errorf("missing template")
	}

	if x, ok := extractSingleMap(template["labels"]); ok && x != nil {
		item.Labels = map[string]string{}
		for k, v := range x {
			item.Labels[k] = v.(string)
		}
	}

	if x, ok := extractSingleMap(template["node_selector"]); ok && x != nil {
		item.Spec.NodeSelector = map[string]string{}
		for k, v := range x {
			item.Spec.NodeSelector[k] = v.(string)
		}
	}

	if x, ok := template["volume"].([]interface{}); ok && x != nil {
		for _, i := range x {
			volume := api.Volume{}
			writePodVolume(i.(map[string]interface{}), &volume)
			item.Spec.Volumes = append(item.Spec.Volumes, volume)
		}
	}

	if x, ok := template["image_pull_secret"].([]interface{}); ok && x != nil {
		for _, i := range x {
			ref := api.LocalObjectReference{}
			writePodImagePullSecret(i.(map[string]interface{}), &ref)
			item.Spec.ImagePullSecrets = append(item.Spec.ImagePullSecrets, ref)
		}
	}

	if x, ok := template["container"].([]interface{}); ok && x != nil {
		for _, i := range x {
			ref := api.Container{}
			err := writePodContainer(i.(map[string]interface{}), &ref)
			if err != nil {
				return err
			}
			item.Spec.Containers = append(item.Spec.Containers, ref)
		}
	}

	if x, ok := template["restart_policy"].(string); ok {
		item.Spec.RestartPolicy = api.RestartPolicy(x)
	}

	if x, ok := template["dns_policy"].(string); ok {
		item.Spec.DNSPolicy = api.DNSPolicy(x)
	}

	if x, ok := template["service_account_name"].(string); ok {
		item.Spec.ServiceAccountName = x
	}

	if x, ok := template["node_name"].(string); ok {
		item.Spec.NodeName = x
	}

	if x, ok := template["termination_grace_period"].(int); ok && x > 0 {
		l := int64(x)
		item.Spec.TerminationGracePeriodSeconds = &l
	}

	if x, ok := template["active_deadline"].(int); ok && x > 0 {
		l := int64(x)
		item.Spec.ActiveDeadlineSeconds = &l
	}

	return nil
}