当前位置:网站首页>Kubernetes configures two ways of hot update
Kubernetes configures two ways of hot update
2022-06-24 05:26:00 【Honest1y】
1 background
Any application needs some specific configuration items , Features used to customize the application . These configurations can generally be divided into two categories :
- One is non sensitive configuration such as running environment and external dependencies
- One is such as keys and SSH Sensitive configurations such as certificates .
These configurations should not be placed directly in the container image , Instead, it should be configured to be separated from the container , Through data volume 、 Environment variables are dynamically mounted at runtime .
When we use kubernetes In the process of , Usually, the application configuration file will be placed in ConfigMap or / and Secret in , However, we often encounter the problem of how to make the configuration file effective after it is updated .
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
2.1 Reloader
- Limiting conditions :Kubernetes Version in 1.9 And above
- Cluster installation
reloader - By adding comments
annotationThe way to achieve
kubectl apply -f https://raw.githubusercontent.com/stakater/Reloader/master/deployments/kubernetes/reloader.yaml
2.1.1 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"2.1.2 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"2.2 checksum annotation
checksum The note is Helm Charts The most commonly used rolling update method in , That is to say Deployment Of annotations Medium plus Secret perhaps ConfigMap Of sha256sum, Such existing Pod Will follow Secret perhaps ConfigMap Update with changes in .
kind: Deployment
spec:
template:
metadata:
annotations:
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
[...] The effect of adding this section is , stay /configmap.yaml Any changes in , Will result in Deployment Of sepc Under the annotation Be updated , And drive reconstruction pod, To achieve the effect we want .
边栏推荐
- Massif tool of Valgrind
- [sharing of competition experience] Rank5 in goose Rose Square - hard search
- 3D visualization of smart dam
- Where to check the computer domain name and where to buy the domain name is more reliable
- Where is the cheaper domain name? What should I pay attention to when buying a domain name?
- API service orchestration platform, full web visual orchestration
- [competition experience sharing] a problem-solving summary of the whole DFS (internal track)
- PHP uasort() function
- Bert series Roberta Albert erine detailed explanation and use learning notes
- Fluent version control FVM
猜你喜欢

Answer questions! This article explains the automated testing framework in software testing from beginning to end

Intensive learning and application of "glory of the king" to complete the application of 7 real worlds other than human players
![[leetcode daily question] push domino](/img/81/1c31e97d9a245816514bcf47c92107.jpg)
[leetcode daily question] push domino

How should we learn cloud native in 2022?

How does win10 turn off f1~f12 shortcut keys?

Hard core observation 553 AI needs to identify almost everyone in the world with hundreds of billions of photos
Easy to understand JDBC tutorial - absolutely suitable for zero Foundation
Learning routes and materials for cloud native O & M engineers
What cloud native knowledge should programmers master?
随机推荐
What domain name is XYZ? How to register a domain name
What is a top-level domain name? Is it expensive to register a domain name
[competition experience sharing] a problem-solving summary of the whole DFS (internal track)
[competition experience sharing] [Tencent internal track rank6] goose Rose Square half hand (TAS) experience
Bert series Roberta Albert erine detailed explanation and use learning notes
Deleting a data table in a command prompt window
Skillfully compiling openwrt routing firmware with pay as you go ECS
When we talk about zero trust, what are we talking about?
What is the use of domain name cloud resolution? What are the factors for domain name errors
[leetcode daily question] push domino
[Tencent cloud] enterprise micro marketing, private domain traffic value growth and operation efficiency improvement
What is a domain name? How to use a domain name?
[2021 techo youth cloud high-quality course replay, waiting for you to take away]
What kind of intelligent connection design do we need in an interconnected society?
What is the secondary domain name of the website? What is the relationship between the secondary domain name and the primary domain name?
How to change the domain name and why to rush to register the domain name
Where to register the HK domain name? What should I pay attention to when registering the domain name
When a beef cow has an "electronic ID card"
What is cloud server? How to access the ECS Homepage
How to create a virtual machine on vSphere client -- a reliable virtual machine creation tutorial