code: func ValidatePodTemplateSpecForReplicaSet(template *api.PodTemplateSpec, selector labels.Selector, replicas int32, fldPath *field.Path) field.ErrorList {
  	allErrs := field.ErrorList{}
  	if template == nil {
  		allErrs = append(allErrs, field.Required(fldPath, ""))
  	} else {
  		if !selector.Empty() {
  			// Verify that the ReplicaSet selector matches the labels in template.
  			labels := labels.Set(template.Labels)
  			if !selector.Matches(labels) {
  				allErrs = append(allErrs, field.Invalid(fldPath.Child("metadata", "labels"), template.Labels, "`selector` does not match template `labels`"))
  			}
  		}
  		allErrs = append(allErrs, apivalidation.ValidatePodTemplateSpec(template, fldPath)...)
  		if replicas > 1 {
  			allErrs = append(allErrs, apivalidation.ValidateReadOnlyPersistentDisks(template.Spec.Volumes, fldPath.Child("spec", "volumes"))...)
  		}
  		// RestartPolicy has already been first-order validated as per ValidatePodTemplateSpec().
  		if template.Spec.RestartPolicy != api.RestartPolicyAlways {
  			allErrs = append(allErrs, field.NotSupported(fldPath.Child("spec", "restartPolicy"), template.Spec.RestartPolicy, []string{string(api.RestartPolicyAlways)}))
  		}
  		if template.Spec.ActiveDeadlineSeconds != nil {
  			allErrs = append(allErrs, field.Forbidden(fldPath.Child("spec", "activeDeadlineSeconds"), "activeDeadlineSeconds in ReplicaSet is not Supported"))
  		}
  	}
  	return allErrs
  }
docs: // ValidatePodTemplateSpecForReplicaSet validates the given template and ensures that it is in accordance with the desired selector and replicas.