mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-13 11:25:19 +00:00
Stores hash of pod manifest in mirror pod's annotation
Use the hash to track whether the mirror pod is a truthful representation of the static pod.
This commit is contained in:
@@ -52,7 +52,7 @@ func (mc *basicMirrorClient) CreateMirrorPod(pod *api.Pod) error {
|
||||
for k, v := range pod.Annotations {
|
||||
copyPod.Annotations[k] = v
|
||||
}
|
||||
copyPod.Annotations[kubetypes.ConfigMirrorAnnotationKey] = kubetypes.MirrorType
|
||||
copyPod.Annotations[kubetypes.ConfigMirrorAnnotationKey] = getPodHash(pod)
|
||||
|
||||
_, err := mc.apiserverClient.Pods(copyPod.Namespace).Create(©Pod)
|
||||
return err
|
||||
@@ -81,9 +81,16 @@ func IsStaticPod(pod *api.Pod) bool {
|
||||
}
|
||||
|
||||
func IsMirrorPod(pod *api.Pod) bool {
|
||||
if value, ok := pod.Annotations[kubetypes.ConfigMirrorAnnotationKey]; !ok {
|
||||
return false
|
||||
} else {
|
||||
return value == kubetypes.MirrorType
|
||||
}
|
||||
_, ok := pod.Annotations[kubetypes.ConfigMirrorAnnotationKey]
|
||||
return ok
|
||||
}
|
||||
|
||||
func getHashFromMirrorPod(pod *api.Pod) (string, bool) {
|
||||
hash, ok := pod.Annotations[kubetypes.ConfigMirrorAnnotationKey]
|
||||
return hash, ok
|
||||
}
|
||||
|
||||
func getPodHash(pod *api.Pod) string {
|
||||
// The annotation exists for all static pods.
|
||||
return pod.Annotations[kubetypes.ConfigHashAnnotationKey]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user