ReplocaSet,DaemonSet

ReplicaSet

RC: ReplicationController (the older generation of Pod Controller)

Pod number of objects used to ensure that a copy of its management and control, to meet user expectations, as many as delete, ranging from creation through templates.

Features:

  • Ensure that the object Pod precise amount of resources
  • Pod ensure the monitoring operation
  • Elastically stretchable.

Similarly, it can also be created by the resource list yaml or json format. Spec field in which it is generally nested field

  • Pod expect the number of copies of the object: replicas
  • selector: The current controller copy of the object matches the tag selector Pod
  • template: Pod copy of the template

Compared with the RC concerned, RS not only supports the equivalent tag selector, but also supports tag selector based on the collection.

Tags: solve the same type of resource object more and more, in order to better manage, in accordance with the label group.

Common Tags Category:

release (version information): stable (stable version), canary (canary version), beta (test version)

environment (environment variables): dev (development), qa (test), production (production)

application (Application): ui, as (application software reference software), pc, sc

tier (tier architecture): frontend (front end), backend (back-end), cache (cache)

partition (Partition): customerA (Client A), customerB (client B)

triack (quality control level): daily (per day), weekly (every week)

Tags To do: See the name to know Italian.

[Root @ master ~] # vim label.yaml

kind: Pod
apiVersion: v1
metadata:
  name: labels
  labels:
    env: qa
    tier: frontend
spec:
  containers:
  - name: myapp
    image: httpd

[root@master ~]# kubectl apply -f label.yaml
pod/labels created

// display the label resource object by --show-labels.

[root@master ~]# kubectl get pod --show-labels 

// By -l, see a label that contains only resources

[root@master ~]# kubectl get po -L env,tier

ReplocaSet,DaemonSet

[root@master ~]# kubectl get po -l env,tier

ReplocaSet,DaemonSet

Add tags to labels resources:

[root@master ~]# kubectl label pod labels  app=pc
pod/labels labeled

Check labels Resources tab:

[root@master ~]# kubectl get pod -l app

ReplocaSet,DaemonSet

[root@master ~]# kubectl get pod -l tier --show-labels

ReplocaSet,DaemonSet

Resources labels to delete the label:

[root@master ~]# kubectl label pod labels  app-
pod/labels labeled

ReplocaSet,DaemonSet

Resources labels to modify the label:

[root@master ~]# kubectl label pod labels env=dev --overwrite 
pod/labels labeled

ReplocaSet,DaemonSet

[Root @ master ~] # vim-label svc.yaml

apiVersion: v1
kind: Service
metadata:
  name: labels-svc
spec:
  type: NodePort
  selector:
    env: qa
    tier: frontend
  ports:
  - protocol: TCP
    port: 80
    targetPort: 80
[root@master ~]# kubectl apply -f label-svc.yaml 
service/labels-svc created
[root@master ~]# kubectl describe svc labels-svc 

If there are multiple labels, tag selector to select one of them, can also be associated with success, on the contrary, if there are multiple selector, then the label must fully meet the conditions, it can be associated with success!

The tag selector: query filter condition tags.

The first two are equal "=", "==", and, finally, unequal: based on equivalence relations (equality-based) "!"

Based on a set of relations (set-based): in, notin, exits three.

example:

[Root @ master ~] # vim slector.yaml

selector:
  matchLabels:
    app: nginx
  matchExpressions:
    - {key: name,operator: In,values: [zhangsan,lisi]}
    - {key: age,operator: Exists,values:}

matchLabels: given key tag representing the selector.

matchExpressions: Based expression to specify the tag selector. SELECT list is "AND" relation; ln or use Notln operation, which values ​​are not mandatory non-empty list of strings, or while using Exists DostNotExist, which values ​​must be empty.

Logical tag selector:

  1. While the logical relationship between the plurality of tags specified for the "and" operation.
  2. NULL tag selector means that each resource object will be the selection.
  3. Empty tag selector can not select any resources.

DaemonSet

It is also a Pod Controller.

Usage scenarios: If you must run the Pod in a fixed or a few nodes, and to give priority to other start-Pod. Typically, each node runs by default and can only run a Pod. This case is recommended DaemonSet resource object.

Monitor:

Log collection program:

[root@master ~]# kubectl get ds -n kube-system

Run a web program, at each node runs a Pod.

[root@master ~]# vim daemonset.yaml

kind: DaemonSet
apiVersion: extensions/v1beta1
metadata:
  name: test-ds
spec:
  template:
    metadata:
      labels:
        name: test-ds
    spec:
      containers:
      - name: test-ds
        image: httpd

[root@master ~]# kubectl apply -f daemonset.yaml
daemonset.extensions/test-ds created

RC, RS, Deployment, DaemonSet. Pod controller. statfulSet, lngress. pod

RBAC. Based on user authentication and authorization mechanisms

Guess you like

Origin blog.51cto.com/13997536/2466762