others-How to reload kubernetes(k8s) deployment/daemonset/statefulset when configmap changed ?

How to reload kubernetes(k8s) deployment/daemonset/statefulset when configmap changed ?

Problem

When you update a configmap in kubernetes(k8s), you may notice that the config loaded in the deployment/daemonset/statefulset is not changed as expected.

Environment

I am using kubernetes version 1.17+

Client Version: version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.3", GitCommit:"06ad960bfd03b39c8310aaf92d1e7c12ce618213", GitTreeState:"clean", BuildDate:"2020-02-13T18:06:54Z", GoVersion:"go1.13.8", Compiler:"gc", Platform:"darwin/amd64"}

Server Version: version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.6", GitCommit:"d32e40e20d167e103faf894261614c5b45c44198", GitTreeState:"clean", BuildDate:"2020-05-20T13:08:34Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}

Solution

Just input this command to rolling update your deployment/daemonset/statefulset :

kubectl rollout restart daemonset/myapp
kubectl rollout restart deployment/myapp
kubectl rollout restart statefulset/myapp

The whole rollout docuements are:

➜ kubectl rollout --help                                                                      
Manage the rollout of a resource.
  
 Valid resource types include:

  *  deployments
  *  daemonsets
  *  statefulsets

Examples:
  # Rollback to the previous deployment
  kubectl rollout undo deployment/abc
  
  # Check the rollout status of a daemonset
  kubectl rollout status daemonset/foo

Available Commands:
  history     View rollout history
  pause       Mark the provided resource as paused
  restart     Restart a resource
  resume      Resume a paused resource
  status      Show the status of the rollout
  undo        Undo a previous rollout

Usage:
  kubectl rollout SUBCOMMAND [options]