@@ -32,15 +32,25 @@ const (
3232 kubeAPIServer = "kube-apiserver"
3333)
3434
35- var podAPIServerMeta = unversioned.TypeMeta {
36- APIVersion : "v1" ,
37- Kind : "Pod" ,
38- }
39-
4035var (
4136 secureAPIAddr = fmt .Sprintf ("https://%s:%s" , os .Getenv ("KUBERNETES_SERVICE_HOST" ), os .Getenv ("KUBERNETES_SERVICE_PORT_HTTPS" ))
4237)
4338
39+ var tempAPIServerManifest = v1.Pod {
40+ TypeMeta : unversioned.TypeMeta {
41+ APIVersion : "v1" ,
42+ Kind : "Pod" ,
43+ },
44+ ObjectMeta : v1.ObjectMeta {
45+ Name : "temp-apiserver" ,
46+ Namespace : api .NamespaceSystem ,
47+ },
48+ }
49+
50+ var tempPodSpecMap = map [string ]v1.Pod {
51+ tempAPIServer : tempAPIServerManifest ,
52+ }
53+
4454func main () {
4555 flag .Set ("logtostderr" , "true" )
4656 defer glog .Flush ()
@@ -69,9 +79,13 @@ func run(actualPodName, tempPodName, namespace string) {
6979 // The actual is running. Let's snapshot the pod,
7080 // clean it up a bit, and then save it to the ignore path for
7181 // later use.
72- checkpointPod := createCheckpointPod (podList , actualPodName , namespace )
73- convertSecretsToVolumeMounts (client , & checkpointPod )
74- writeManifest (checkpointPod , tempPodName )
82+ tempSpec , ok := tempPodSpecMap [tempPodName ]
83+ if ! ok {
84+ glog .Fatalf ("cannot find pod spec for %v" , tempPodName )
85+ }
86+ tempSpec .Spec = parseAPIPodSpec (podList , actualPodName , namespace )
87+ convertSecretsToVolumeMounts (client , & tempSpec )
88+ writeManifest (tempSpec , tempPodName )
7589 glog .Infof ("finished creating temp pod %v manifest at %s\n " , tempPodName , checkpointManifest (tempPodName ))
7690
7791 default :
@@ -174,20 +188,17 @@ func writeManifest(manifest v1.Pod, name string) {
174188 writeAndAtomicCopy (m , checkpointManifest (name ))
175189}
176190
177- func createCheckpointPod (podList v1.PodList , n , ns string ) v1.Pod {
178- var checkpointPod v1.Pod
191+ func parseAPIPodSpec (podList v1.PodList , n , ns string ) v1.PodSpec {
192+ var apiPod v1.Pod
179193 for _ , p := range podList .Items {
180194 if isPod (p , n , ns ) {
181- checkpointPod = p
195+ apiPod = p
182196 break
183197 }
184198 }
185- // the pod we manifest we got from kubelet does not have TypeMeta.
186- // Add it now.
187- checkpointPod .TypeMeta = podAPIServerMeta
188- cleanVolumes (& checkpointPod )
189- stripNonessentialInfo (& checkpointPod )
190- return checkpointPod
199+ cleanVolumes (& apiPod )
200+ stripNonessentialInfo (& apiPod )
201+ return apiPod .Spec
191202}
192203
193204func newAPIClient () clientset.Interface {
0 commit comments