当前位置:网站首页>Automatic reconstruction of pod after modifying resource object

Automatic reconstruction of pod after modifying resource object

2022-06-24 12:25:00 Honest1y

1 background

User defined Kubernetes Resource object ( for example Deployment、Daemonset etc. ), Profile to configmap Definition , adopt Volumemounts Mount To Pod in , After the configuration file is modified , The service can automatically reload Load update configuration .

2 Solution

  • Limiting conditions :Kubernetes Version in 1.9 And above
  • Cluster installation reloader
  • By adding comments annotation The way to achieve
kubectl apply -f https://raw.githubusercontent.com/stakater/Reloader/master/deployments/kubernetes/reloader.yaml

overall situation configmap Trigger update

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: filebeat
  namespace: log 
  labels:
    k8s-app: filebeat
  annotations:
    reloader.stakater.com/auto: "true"

As specified configmap Changes automatically trigger configuration updates for resource objects

  • single ConfigMap to update
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: filebeat
  namespace: log 
  labels:
    k8s-app: filebeat
  annotations:
    configmap.reloader.stakater.com/reload: "filebeat-config"
  • many configmap, Multiple... With commas configmap In isolation
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: filebeat
  namespace: log 
  labels:
    k8s-app: filebeat
  annotations:
    configmap.reloader.stakater.com/reload: "filebeat-config,foo-config"
原网站

版权声明
本文为[Honest1y]所创,转载请带上原文链接,感谢
https://yzsam.com/2021/06/20210602191026699u.html