当前位置:网站首页>Kubernetes (V): annotation and namespace

Kubernetes (V): annotation and namespace

2021-01-23 23:44:11 Light ink mark

This paper focuses on two parts :

1. Introduction and use of annotations ;

2. The introduction and use of namespace .

One 、 annotation

K8S In addition to being identified by labels / Out of category , You can also annotate (annotations) attribute , It belongs to metadata The child tag of , It's also the format of key value pairs . The notes and java The annotations in are completely different , If you have to make an analogy ,Java The annotations in are more like Kubernetes The label in - Identify specific uses , and Kubernetes Annotations in are more like annotations , Compared to labels , You can add more and more details , But not more than 256KB.

The tag has a corresponding tag selector , So it can be used to identify / classified , But annotations have no corresponding annotation selector .

Annotations use :

add to / Modify the note ( It's similar to the format of the action tag ):

kubectl annotate pod podname  annotationkey=annotationvalue

After you add it, when you look at pod You can see this annotation when you read the message .

 

Two 、 Namespace

A namespace can isolate a group from other objects , Object names within the same namespace cannot be duplicated , But objects between different namespace have no such constraint .Kubernetes Is the scope of an object , Only through this namespace can objects in the scope be manipulated . There is no network isolation between different namespace .

operation :

Look at the existing namespace in the cluster :

kubectl get ns

Look at objects in a namespace :

kubectl get pod -n namespace-name

Create a namespace by yaml File creation , You can also use the following command directly :

kubectl create namespace  namespace-name

Note that the name of the namespace cannot have a dot

How to divide an object into its corresponding namespace ? You can specify a namespace when you create an object :

kubectl create -f xxx.yaml  -n  namespace-name

Or in yaml In file , stay metadata Add... Under the label namespace label .

 

版权声明
本文为[Light ink mark]所创,转载请带上原文链接,感谢
https://chowdera.com/2021/01/20210123234349810N.html

随机推荐