how to scale daemon set about kubernetes using kubectl

3/30/2020

Now I only have terminal to access kubernetes cluster now, check the ingress controller like this:

$ k get daemonset --all-namespaces
NAMESPACE     NAME                         DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR                              AGE
kube-system   traefik-ingress-controller   0         0         0       0            0           IngressProxy=true                          60d
logging       fluentd-es                   0         0         0       0            0           beta.kubernetes.io/fluentd-ds-ready=true   28d

I am now using kubectl(v1.15.2) to scale daemon set like this:

kubectl scale --replicas=1 DaemonSet/traefik-ingress-controller -n kube-system

but it shows:

Error from server (NotFound): the server could not find the requested resource

what should I do to start the traefik in terminal using command line? This is my daemon set describe output:

~/Library/Mobile Documents/com~apple~CloudDocs/Document/k8s/work/traefik-deployment-yaml/k8s-backup ⌚ 17:49:58
$ k describe daemonset traefik-ingress-controller -n kube-system
Name:           traefik-ingress-controller
Selector:       app=traefik
Node-Selector:  IngressProxy=true
Labels:         app=traefik
Annotations:    deprecated.daemonset.template.generation: 18
                kubectl.kubernetes.io/last-applied-configuration:
                  {"apiVersion":"apps/v1","kind":"DaemonSet","metadata":{"annotations":{},"labels":{"app":"traefik"},"name":"traefik-ingress-controller","na...
Desired Number of Nodes Scheduled: 0
Current Number of Nodes Scheduled: 0
Number of Nodes Scheduled with Up-to-date Pods: 0
Number of Nodes Scheduled with Available Pods: 0
Number of Nodes Misscheduled: 0
Pods Status:  0 Running / 0 Waiting / 0 Succeeded / 0 Failed
Pod Template:
  Labels:           app=traefik
  Service Account:  traefik-ingress-controller
  Containers:
   traefik-ingress-lb:
    Image:       traefik:v2.1.6
    Ports:       80/TCP, 443/TCP, 8080/TCP
    Host Ports:  80/TCP, 443/TCP, 0/TCP
    Args:
      --configfile=/config/traefik.yaml
      --logLevel=INFO
      --metrics=true
      --metrics.prometheus=true
      --entryPoints.metrics.address=:8080
      --metrics.prometheus.entryPoint=metrics
      --metrics.prometheus.addServicesLabels=true
      --metrics.prometheus.addEntryPointsLabels=true
      --metrics.prometheus.buckets=0.100000, 0.300000, 1.200000, 5.000000
    Limits:
      cpu:     2
      memory:  1Gi
    Requests:
      cpu:        1
      memory:     1Gi
    Environment:  <none>
    Mounts:
      /config from config (rw)
  Volumes:
   config:
    Type:      ConfigMap (a volume populated by a ConfigMap)
    Name:      traefik-config
    Optional:  false
Events:
  Type     Reason            Age    From                  Message
  ----     ------            ----   ----                  -------
  Warning  FailedDaemonPod   3h32m  daemonset-controller  Found failed daemon pod kube-system/traefik-ingress-controller-wdpsq on node azshara-k8s03, will try to kill it
  Normal   SuccessfulDelete  3h32m  daemonset-controller  Deleted pod: traefik-ingress-controller-wdpsq
  Normal   SuccessfulCreate  3h32m  daemonset-controller  Created pod: traefik-ingress-controller-qmttl
  Warning  FailedDaemonPod   3h32m  daemonset-controller  Found failed daemon pod kube-system/traefik-ingress-controller-qmttl on node azshara-k8s03, will try to kill it
  Normal   SuccessfulDelete  3h32m  daemonset-controller  Deleted pod: traefik-ingress-controller-qmttl
  Normal   SuccessfulCreate  3h32m  daemonset-controller  Created pod: traefik-ingress-controller-nlxwc
-- Dolphin
kubernetes

1 Answer

3/30/2020

You don not need to scale a deamon set on K8s.

A Daemon Set ensures that all eligible nodes run a copy of a Pod..

As nodes are added to the cluster, Pods are added to them. So you need to add new node to cluster and deamon set will be scheduled there unless you have a very unique taint to disallow given deamon set.

-- DT.
Source: StackOverflow