繁体   English   中英

在 kube.netes 集群上创建 daemonset 的问题

[英]Problem with daemonset creation on kubernetes cluster

我在主节点上运行以下命令,以在 Kube.netes 集群上创建守护程序集。

$ kubectl apply -f https://k8s.io/examples/controllers/daemonset.yaml

我认为它已成功创建,因为显示了以下消息,

daemonset.apps/fluentd-elasticsearch created

但在那之后,当我跑步时,

$ kubectl get daemonsets
No resources found in default namespace

所以我试着重新创建相同的但这次它显示,

$ kubectl apply -f https://k8s.io/examples/controllers/daemonset.yaml
daemonset.apps/fluentd-elasticsearch unchanged

我不明白这里发生了什么。 一个解释将不胜感激。

它被部署在kube-system命名空间中,因为部署 yaml 具有namespace: kube-system

kubectl get daemonsets命令显示来自default命名空间的daemonsets ,因此它给出了No resources found

您需要在命令中添加-n参数以检查在特定命名空间(例如daemonsets kube-system )中创建的守护程序集

kubectl get daemonsets -n kube-system

跑步

kubectl get daemonsets —all-namespaces -o wide

这将为您提供命名空间和工作节点上存在的所有守护程序集

当您 go 到官方 kube.netes 文档并检查此链接DaemonSet时,您将看到您的 DaemonSet 的名称空间。

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: fluentd-elasticsearch
  namespace: kube-system
  labels:
    k8s-app: fluentd-logging
spec:
  selector:
    matchLabels:
      name: fluentd-elasticsearch
  template:
    metadata:
      labels:
        name: fluentd-elasticsearch
    spec:
      tolerations:
      # this toleration is to have the daemonset runnable on master nodes
      # remove it if your masters can't run pods
      - key: node-role.kubernetes.io/master
        effect: NoSchedule
      containers:
      - name: fluentd-elasticsearch
        image: quay.io/fluentd_elasticsearch/fluentd:v2.5.2
        resources:
          limits:
            memory: 200Mi
          requests:
            cpu: 100m
            memory: 200Mi
        volumeMounts:
        - name: varlog
          mountPath: /var/log
        - name: varlibdockercontainers
          mountPath: /var/lib/docker/containers
          readOnly: true
      terminationGracePeriodSeconds: 30
      volumes:
      - name: varlog
        hostPath:
          path: /var/log
      - name: varlibdockercontainers
        hostPath:
          path: /var/lib/docker/containers

您用于创建守护程序集的 URL 在 kube-system 命名空间中创建了一个守护程序集。 而不是在默认名称空间中查看 daemonset。 使用以下命令。 它将显示所有 daemonset 及其运行的名称空间。

Kubectl get ds --all-namespaces 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM