def convert_to_valid_label(label: str) -> str:
  """Kubernetes labels must be RFC 1123 format compliant.

  https://github.com/kubernetes/kubernetes/blob/master/pkg/apis/apps/validation/validation.go
  A lowercase RFC 1123 label must consist of lower case alphanumeric characters
  or '-', and must start and end with an alphanumeric character (e.g. 'my-name',
  or '123-abc', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?')

  Args:
    label: Label that may or may not be RFC 1123 compliant.

  Returns:
    A RFC 1123 format compliant label.
  """
  return label.replace('_', '-')