Kubernetes的pod控制器之DaemonSet

DaemonSet 顶级参数介绍

[[email protected] manifests]#  kubectl explain ds
KIND:     DaemonSet
VERSION:  extensions/v1beta1

DESCRIPTION:
     DEPRECATED - This group version of DaemonSet is deprecated by
     apps/v1beta2/DaemonSet. See the release notes for more information.
     DaemonSet represents the configuration of a daemon set.

FIELDS:
   apiVersion	<string>
     APIVersion defines the versioned schema of this representation of an
     object. Servers should convert recognized schemas to the latest internal
     value, and may reject unrecognized values. More info:
     https://git.k8s.io/community/contributors/devel/api-conventions.md#resources

   kind	<string>
     Kind is a string value representing the REST resource this object
     represents. Servers may infer this from the endpoint the client submits
     requests to. Cannot be updated. In CamelCase. More info:
     https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds

   metadata	<Object>  元数据
     Standard object‘s metadata. More info:
     https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata

   spec	<Object>  期望状态
     The desired behavior of this daemon set. More info:
     https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status

   status	<Object>
     The current status of this daemon set. This data may be out of date by some
     window of time. Populated by the system. Read-only. More info:
     https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status

  控制spec的参数

[[email protected] manifests]#  kubectl explain ds.spec
KIND:     DaemonSet
VERSION:  extensions/v1beta1

RESOURCE: spec <Object>

DESCRIPTION:
     The desired behavior of this daemon set. More info:
     https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status

     DaemonSetSpec is the specification of a daemon set.

FIELDS:
   minReadySeconds	<integer>  保存历史版本数
     The minimum number of seconds for which a newly created DaemonSet pod
     should be ready without any of its container crashing, for it to be
     considered available. Defaults to 0 (pod will be considered available as
     soon as it is ready).

   revisionHistoryLimit	<integer>
     The number of old history to retain to allow rollback. This is a pointer to
     distinguish between explicit zero and not specified. Defaults to 10.

   selector	<Object>
     A label query over pods that are managed by the daemon set. Must match in
     order to be controlled. If empty, defaulted to labels on Pod template. More
     info:
     https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors

   template	<Object> -required-
     An object that describes the pod that will be created. The DaemonSet will
     create exactly one copy of this pod on every node that matches the
     template‘s node selector (or on every node if no node selector is
     specified). More info:
     https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller#pod-template

   templateGeneration	<integer>
     DEPRECATED. A sequence number representing a specific generation of the
     template. Populated by the system. It can be set only during the creation.

   updateStrategy	<Object> 更新策略
     An update strategy to replace existing DaemonSet pods with new pods.

  创建DaemonSet 控制器模板

[[email protected] manifests]# cat ds-demo.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
   name: redis
   namespace: default
spec:
  replicas: 1
  revisionHistoryLimit: 3
  selector:
    matchLabels:
      app: redis
  strategy:
    rollingUpdate:
      maxSurge: 2
      maxUnavailable: 0
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: redis
    spec:
      containers:
      - name: redis
        image: redis:4.0-alpine
        ports:
        - name: redis
          containerPort: 6379
---
apiVersion: apps/v1
kind: DaemonSet
metadata:  元数据
  name: myapp-ds
  namespace: default
spec:  控制器期望状态
  revisionHistoryLimit: 5 保留历史版本的个数
  selector:  定义标签选择器
    matchLabels:  标签选择器
      app: myapp-ds  选定的标签
      cx: ds
  updateStrategy:  更新策略
    rollingUpdate:
      maxUnavailable: 1
    type: RollingUpdate
  template:  pod 的定义
    metadata:  pod 元数据定义
      labels:   定义标签
        app: myapp-ds
        cx: ds
      name: myapp-ds  pod的名字
      namespace: default  pod 名称空间
    spec:   pod 期望状态定义
      containers:  pod 里容器的定义
      - name: filebea   容器名字
        image: ikubernetes/filebeat:5.6.5-alpine  容器镜像的定义
        env:  环境变量定义
        - name: REDIS_HOST
          value: redis.default.svc.cluster.local
        - name: REDIS_LOG_LEVEL
          value: info

运行pod

[[email protected] manifests]# kubectl  apply -f ds-demo.yaml
deployment.apps/redis unchanged
daemonset.apps/myapp-ds configured

  查看创建的pod

[[email protected] manifests]# kubectl get pods
NAME                       READY   STATUS    RESTARTS   AGE
myapp-ds-b5hsx             1/1     Running   0          50s
myapp-ds-m7pss             1/1     Running   0          47s
redis-54f5db865-hcdwd      1/1     Running   0          17m

  查看pod运行日志

[[email protected] manifests]# kubectl logs myapp-ds-m7pss
2019/08/11 16:12:21.734552 beat.go:297: INFO Home path: [/usr/local/bin] Config path: [/usr/local/bin] Data path: [/usr/local/bin/data] Logs path: [/usr/local/bin/logs]
2019/08/11 16:12:21.734604 beat.go:192: INFO Setup Beat: filebeat; Version: 5.6.5
2019/08/11 16:12:21.734771 metrics.go:23: INFO Metrics logging every 30s
2019/08/11 16:12:21.734940 redis.go:140: INFO Max Retries set to: 3
2019/08/11 16:12:21.734961 outputs.go:108: INFO Activated redis as output plugin.
2019/08/11 16:12:21.735038 publish.go:300: INFO Publisher name: myapp-ds-m7pss
2019/08/11 16:12:21.735169 async.go:63: INFO Flush Interval set to: 1s
2019/08/11 16:12:21.735178 async.go:64: INFO Max Bulk Size set to: 2048
2019/08/11 16:12:21.735332 modules.go:95: ERR Not loading modules. Module directory not found: /usr/local/bin/module
2019/08/11 16:12:21.735534 beat.go:233: INFO filebeat start running.
2019/08/11 16:12:21.735704 registrar.go:68: INFO No registry file found under: /var/log/containers/filebeat_registry. Creating a new registry file.
2019/08/11 16:12:21.736963 registrar.go:106: INFO Loading registrar data from /var/log/containers/filebeat_registry
2019/08/11 16:12:21.737003 registrar.go:123: INFO States Loaded from registrar: 0
2019/08/11 16:12:21.737028 crawler.go:38: INFO Loading Prospectors: 1
2019/08/11 16:12:21.737153 prospector_log.go:65: INFO Prospector with previous states loaded: 0
2019/08/11 16:12:21.737408 config.go:95: WARN DEPRECATED: document_type is deprecated. Use fields instead.
2019/08/11 16:12:21.737430 prospector.go:124: INFO Starting prospector of type: log; id: 11998382299604891537
2019/08/11 16:12:21.737438 crawler.go:58: INFO Loading and starting Prospectors completed. Enabled prospectors: 1
2019/08/11 16:12:21.737451 registrar.go:236: INFO Starting Registrar
2019/08/11 16:12:21.737470 sync.go:41: INFO Start sending events to output
2019/08/11 16:12:21.737498 spooler.go:63: INFO Starting spooler: spool_size: 2048; idle_timeout: 5s
2019/08/11 16:12:51.735339 metrics.go:39: INFO Non-zero metrics in the last 30s: registrar.writes=1
2019/08/11 16:13:21.736172 metrics.go:34: INFO No non-zero metrics in the last 30s
2019/08/11 16:13:51.735741 metrics.go:34: INFO No non-zero metrics in the last 30s
2019/08/11 16:14:21.736297 metrics.go:34: INFO No non-zero metrics in the last 30s
2019/08/11 16:14:51.736150 metrics.go:34: INFO No non-zero metrics in the last 30s
2019/08/11 16:15:21.735939 metrics.go:34: INFO No non-zero metrics in the last 30s

  进入一个pod里面

[[email protected] manifests]# kubectl exec -it myapp-ds-m7pss -- /bin/sh
/ #

   

手动创建server

[[email protected] manifests]# kubectl expose deploy redis --port=6379

  查看创建的server

[[email protected] manifests]# kubectl get svc
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE
kubernetes   ClusterIP   10.96.0.1        <none>        443/TCP        17d
myapp        NodePort    10.103.191.244   <none>        80:31339/TCP   17d
nginx        ClusterIP   10.108.177.175   <none>        80/TCP         17d
redis        ClusterIP   10.104.114.16    <none>        6379/TCP       8m41s

  

原文地址:https://www.cnblogs.com/rdchenxi/p/11332684.html

时间: 2024-07-29 09:10:47

Kubernetes的pod控制器之DaemonSet的相关文章

k8s中的pod控制器之Deployment、DaemonSet、StatefulSet

pod控制器分类:1.ReplicationController2.ReplicaSet3.Deployment4.StatefulSet5.DaemonSet6.Job,Cronjob7.HPApod控制器:一般包括3部分1.标签选择器2.期望的副本数(DaemonSet控制器不需要)3.pod模板deploy控制器构建于rs控制器之上,新特性包括:1.事件和状态查看2.回滚3.版本记录4.暂停和启动5.支持两种自动更新方案Recreate删除重建RollingUpdate回滚升级(默认方式)

Kubernetes之Pod控制器,ReplicaSet,Deployment,DaemonSet

目录 Kubernetes之Pod控制器,ReplicaSet,Deployment,DaemonSet ReplicaSet Deployment控制器 创建Deployment Deployment更新 Deployment扩容 金丝雀发布 Deployment回滚 DaemonSet 定义 DaemonSet演示 redis-filebeat DaemonSet的滚动更新 Kubernetes之Pod控制器,ReplicaSet,Deployment,DaemonSet Kubernete

kubernetes之pod超详细解读--第二篇(三)

8.资源对象对pod的调度 ??在kubernetes集群中,pod基本上都是容器的载体,通常需要通过相应的资源对象来完成一组pod的调度和自动控制功能,比如:deployment.daemonSet.RC.Job等等.接下来小编将一一介绍这些资源对象如何调度pod. (1)Deployment/RC 自动化调度 ??Deployment/RC的主要功能之一就是自动部署一个容器应用的多个副本,以及持续监控副本数量,在集群内始终维持用户指定的副本数量.举例:(这里以deployment为例) ap

Kubernetes中Pod间共享内存方案

摘要:一些公共服务组件在追求性能过程中,与业务耦合太紧,造成在制作基础镜像时,都会把这些基础组件都打包进去,因此当业务镜像启动后,容器里面一大堆进程,这让Kubernetes对Pod的管理存在很大隐患.为了让业务容器瘦身,更是为了基础组件自身的管理更独立和方便,将基础组件从业务镜像中剥离并DaemonSet容器化部署.然而一些基础组件Agent与业务Pod之间通过共享内存的方式进行通信,同一Node中跨Pod的共享内存方案是首先要解决的问题. 为什么要将公共基础组件Agent进行DaemonSe

Kubernetes之Pod控制器应用进阶

目录 Kubernetes之Pod控制器应用进阶 Pod控制器下spec常用字段 标签(Labels)和标签选择器(LabelSelector) 标签 标签选择器 Kubernetes之Pod控制器应用进阶 Pod控制器下spec常用字段 #containers [[email protected] ~]# kubectl explain pods.spec.containers. name <string> -required- #容器名,必选字段 image <string>

Kubernetes之Pod的生命周期

目录 Kubernetes之Pod的生命周期 理解Pod Pod内如何管理多个容器 Pod的使用 其他替代选择 Pod的持久性 Pod的终止 Init容器 Pause容器 Pod的生命周期 Pod的phase Pod的状态 容器探针 存活性探测 livenessProbe 就绪性探测 readnessProbe livenessProbe和readinessProbe使用场景 lifecycle Kubernetes之Pod的生命周期 理解Pod Pod是kubernetes中你可以创建和部署的

kubernetes之pod健康检查

目录 kubernetes之pod健康检查 1.概述和分类 2.LivenessProbe探针(存活性探测) 3.ReadinessProbe探针(就绪型探测) 4.探针的实现方式 4.1.ExecAction 4.2.HTTPGetAction 4.3.TCPSocketAction 5.探测行为属性 6.扩展的探测机制 kubernetes之pod健康检查 1.概述和分类 pod通过两类探针来检查容器的健康状态.分别是LivenessProbe(存活性探测)和ReadinessProbe(就

Kubernetes基石-pod容器

引用三个问题来叙述Kubernetes的pod容器 1.为什么不直接在一个Docker容器中运行所有的应用进程. 2.为什么pod这种容器中要同时运行多个Docker容器(可以只有一个) 3.为什么k8s使用pod这种容器而不直接使用Docker容器 一个由多个进程进行组成的应用程序,无论是通过ipc(进程间通信)还是本地存储文件进行通信,都要求它们运行于同一台机器上.Docker容器非常像一台独立的机器,此时你可能认为在单个容器中运行多个进程是合乎逻辑的,然而在实践中这种做法并不合理. 容器被

Kubernetes 控制器之 Deployment 介绍(六)

一.Deployment.ReplicaSet.Pod之间的关系 我们接着前面的文章说,如果不清楚的请查看之前的博文:http://blog.51cto.com/wzlinux/2322616 前面我们已经了解到,Kubernetes 通过各种 Controller 来管理 Pod 的生命周期.为了满足不同业务场景,Kubernetes 开发了 Deployment.ReplicaSet.DaemonSet.StatefuleSet.Job 等多种 Controller.我们首先学习最常用的 D