如何将持久卷声明链接到kubernetes中的daemonset卷?

时间:2020-02-13 17:32:22

标签: kubernetes

我正在尝试将acme文件存储在kubernetes上的持久卷中。 我正在学习本教程:https://blog.nobugware.com/post/2019/advanced-traefik-2-0-with-kubernetes/

我有一个名为traefik-acme-storage的永久批量声明(pvc)。

acme-storage.yaml

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  labels:
    app: traefik
  name: traefik-acme-storage
  namespace: traefik
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: "100Mi"

我还有一个守护程序集,它公开traefik并安装一个与我的持久卷声明链接的名为storage-volume的卷。

traefik.yaml

---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  namespace: traefik
  name: traefik-ingress-controller
  labels:
    k8s-app: traefik-ingress
    app: traefik

spec:
  selector:
    matchLabels:
      k8s-app: traefik-ingress-lb
      name: traefik-ingress-lb
  template:
    metadata:
      labels:
        k8s-app: traefik-ingress-lb
        name: traefik-ingress-lb
    spec:
      terminationGracePeriodSeconds: 60
      dnsPolicy: ClusterFirstWithHostNet
      hostNetwork: true
      serviceAccountName: traefik-ingress-controller
      containers:
      - name: traefik-ingress-lb
        image: traefik:v2.1.4
        args:
          - --log.level=INFO
          - --entrypoints.web.Address=:80
          - --entrypoints.websecure.Address=:443
          - --providers.kubernetescrd
          - --certificatesresolvers.default.acme.storage=/data/acme.json
        ports:
          - name: http
            containerPort: 80
          - name: https
            containerPort: 443
          - name: admin
            containerPort: 8080
        volumeMounts:
          - name: storage-volume
            mountPath: /data
      volumes:
        - name: storage-volume
          persistentVolumeClaim:
            claimName: traefik-acme-storage

当我应用这两个文件时,由守护程序创建的pod和持久卷声明都处于挂起状态。

我在广告连播中出现的错误:

Events:
  Type     Reason            Age        From               Message
  ----     ------            ----       ----               -------
  Warning  FailedScheduling  <unknown>  default-scheduler  error while running "VolumeBinding" filter plugin for pod "traefik-ingress-controller-9xgns": pod has unbound immediate PersistentVolumeClaims

我在永久卷声明中存在错误:

Events:
  Type    Reason         Age                From                         Message
  ----    ------         ----               ----                         -------
  Normal  FailedBinding  11s (x4 over 49s)  persistentvolume-controller  no persistent volumes available for this claim and no storage class is set

有人可以向我解释为什么pvc无法绑定在守护程序容器中声明的卷以及如何解决此问题吗?

多谢

0 个答案:

没有答案