No tienes acceso a esta clase

¡Continúa aprendiendo! Únete y comienza a potenciar tu carrera

Introducción a namespaces

27/33
Recursos

Aportes 12

Preguntas 1

Ordenar por:

¿Quieres ver más aportes, preguntas y respuestas de la comunidad?

You can list the current namespaces in a cluster using:

kubectl get namespace

To set the namespace for a current request, use the --namespace flag. For example:

kubectl get pods --namespace=[namespaceName]

You can permanently save the namespace for all subsequent kubectl commands in that context.

kubectl config set-context --current --namespace=[namespaceName]

Kubernetes starts with four initial namespaces:

  1. default The default namespace for objects with no other namespace
  2. kube-system The namespace for objects created by the Kubernetes system
  3. kube-public This namespace is created automatically and is readable by all users (including those not authenticated). This namespace is mostly reserved for cluster usage, in case that some resources should be visible and readable publicly throughout the whole cluster. The public aspect of this namespace is only a convention, not a requirement.
  4. kube-node-lease This namespace for the lease objects associated with each node which improves the performance of the node heartbeats as the cluster scales.

Crear un namespace llamado blue
kubectl create namespace blue
Cambiar al nuevo namespace
kubectl config set-context --current --namespace=blue
Validar que se cambio de namespace
kubectl config get-contexts

When to Use Multiple Namespaces

  1. Namespaces are intended for use in environments with many users spread across multiple teams, or projects. For clusters with a few to tens of users, you should not need to create or think about namespaces at all. Start using namespaces when you need the features they provide.

  2. Namespaces provide a scope for names. Names of resources need to be unique within a namespace, but not across namespaces. Namespaces cannot be nested inside one another and each Kubernetes resource can only be in one namespace.

  3. Namespaces are a way to divide cluster resources between multiple users (via resource quota).

It is not necessary to use multiple namespaces just to separate slightly different resources, such as different versions of the same software: use labels to distinguish resources within the same namespace.

Muy útil y bien explicada.

kg namespaces
kg pod -n kube-system
k create namespace dbz
k -n heon get service
k get service
k config get-contexts
//Mover de contexto o namespaces
k config set-context --current --namespace=dbz
k config get-contexts
  • Los atributos que definen univocamente a un recurso del cluster son tipo de recurso(pods, servicios, deployment), nombre del recurso y el namespace.
  • Los Namespaces no proveen aislación de recursos.
  • Un pod en un namespace A puede comunicarse con otro en un namespace B.
  • Desde cualquier pod en el cluster podemos comunicarnos al K8S API…
kubectl create namespace <NAME>
#ver los contextos del namespaces
kubectl config get-contexts 
#cambiar de namespace
kubectl config set-context --current --namespace=blue

Namespace provides an additional qualification to a resource name. This is helpful when multiple teams are using the same cluster and there is a potential of name collision. It can be as a virtual wall between multiple clusters.

Para cambiar entre diferentes namespaces del cluster también es muy útil el comando kubeselect, la documentación está en https://github.com/fatliverfreddy/kubeselect. Asegúrense de clonar el repositorio en Downloads y cuando envíen el segundo comando, primero envían cd kubeselect, y una vez en esa carpeta sí envían el comando cp de la docu.

Esta clase cortica pero bien detallada.

Setear el contexto actual al namespace indicado

Following are some of the important functionalities of a Namespace in Kubernetes:

  • Namespaces help pod-to-pod communication using the same namespace.

  • Namespaces are virtual clusters that can sit on top of the same physical cluster.

  • They provide logical separation between the teams and their environments.

Namespaces no provee aislación de recursos

😃