How do I get all the options of a field? In Drupal 7, we are using the following code.

$field = field_info_field('field_name');
$allowed_values = list_allowed_values($field);


What can we use in Drupal 8?
Drupal 8.9.x still has the options_allowed_values() (a function implemented in the Options module). If the field uses a selection, check box, or a radio button widget, you could use the following code. The same function is still implemented in Drupal 9.3.x, the latest Drupal version under development, at the time I am adding this note.
$field_definitions = \Drupal::service('entity_field.manager')-&gt;getFieldDefinitions('entity', 'bundle');
if (isset($field_definitions['field'])) {
    $allowed_options = options_allowed_values($field_definitions['field']-&gt;getFieldStorageDefinition());
}

Replace 'entity' with the entity ID (for example, 'node' for nodes), 'bundle' with the bundle machine name (for example, 'article' for Article nodes), and 'field' with the field machine name.
Keep in mind that this code requires the Options module. The module using the code I shown should declare its dependency from it.
Using options_allowed_values() has the benefit that, if the field has a function returning the allowed values, that function is called. The following is the code used by options_allowed_values() to achieve that.
if (!isset($allowed_values[$cache_id])) {
  $function = $definition-&gt;getSetting('allowed_values_function');
  $cacheable = TRUE;
  if (!empty($function)) {
    $values = $function($definition, $entity, $cacheable);
  }
  else {
    $values = $definition-&gt;getSetting('allowed_values');
  }
  if ($cacheable) {
    $allowed_values[$cache_id] = $values;
  }
  else {
    return $values;
  }
}

Using options_allowed_values() also allow to cache the allowed values. In this way, calling options_allowed_values() for the same field (and same entity type) multiple times has a minimal impact on performance.