A煤n no tienes acceso a esta clase

Crea una cuenta y contin煤a viendo este curso

Curso de Kubernetes

Curso de Kubernetes

Marcos Lilljedahl

Marcos Lilljedahl

Introducci贸n a namespaces


Aportes 12

Preguntas 1

Ordenar por:

驴Quieres ver m谩s aportes, preguntas y respuestas de la comunidad? Crea una cuenta o inicia sesi贸n.

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.

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.

  • 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

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

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