@@ -189,9 +189,11 @@ func createCoreDNSAddon(deploymentBytes, serviceBytes, configBytes []byte, clien
189
189
// Assume that migration is always possible, rely on migrateCoreDNSCorefile() to fail if not.
190
190
canMigrateCorefile := true
191
191
192
+ configMapClient := client .CoreV1 ().ConfigMaps (coreDNSConfigMap .GetNamespace ())
193
+
192
194
if corefile == "" || migration .Default ("" , corefile ) {
193
195
// If the Corefile is empty or default, the latest default Corefile will be applied
194
- if err := apiclient .CreateOrUpdateConfigMap ( client , coreDNSConfigMap ); err != nil {
196
+ if err := apiclient .CreateOrUpdate ( configMapClient , coreDNSConfigMap ); err != nil {
195
197
return err
196
198
}
197
199
} else if corefileMigrationRequired {
@@ -201,13 +203,13 @@ func createCoreDNSAddon(deploymentBytes, serviceBytes, configBytes []byte, clien
201
203
// to ignore preflight check errors.
202
204
canMigrateCorefile = false
203
205
klog .Warningf ("the CoreDNS Configuration was not migrated: %v. The existing CoreDNS Corefile configuration has been retained." , err )
204
- if err := apiclient .CreateOrRetainConfigMap ( client , coreDNSConfigMap , kubeadmconstants .CoreDNSConfigMap ); err != nil {
206
+ if err := apiclient .CreateOrRetain ( configMapClient , coreDNSConfigMap , kubeadmconstants .CoreDNSConfigMap ); err != nil {
205
207
return err
206
208
}
207
209
}
208
210
} else {
209
211
// If the Corefile is modified and doesn't require any migration, it'll be retained for the benefit of the user
210
- if err := apiclient .CreateOrRetainConfigMap ( client , coreDNSConfigMap , kubeadmconstants .CoreDNSConfigMap ); err != nil {
212
+ if err := apiclient .CreateOrRetain ( configMapClient , coreDNSConfigMap , kubeadmconstants .CoreDNSConfigMap ); err != nil {
211
213
return err
212
214
}
213
215
}
@@ -218,7 +220,7 @@ func createCoreDNSAddon(deploymentBytes, serviceBytes, configBytes []byte, clien
218
220
}
219
221
220
222
// Create the Clusterroles for CoreDNS or update it in case it already exists
221
- if err := apiclient .CreateOrUpdateClusterRole (client , coreDNSClusterRoles ); err != nil {
223
+ if err := apiclient .CreateOrUpdate (client . RbacV1 (). ClusterRoles () , coreDNSClusterRoles ); err != nil {
222
224
return err
223
225
}
224
226
@@ -228,7 +230,7 @@ func createCoreDNSAddon(deploymentBytes, serviceBytes, configBytes []byte, clien
228
230
}
229
231
230
232
// Create the Clusterrolebindings for CoreDNS or update it in case it already exists
231
- if err := apiclient .CreateOrUpdateClusterRoleBinding (client , coreDNSClusterRolesBinding ); err != nil {
233
+ if err := apiclient .CreateOrUpdate (client . RbacV1 (). ClusterRoleBindings () , coreDNSClusterRolesBinding ); err != nil {
232
234
return err
233
235
}
234
236
@@ -238,7 +240,7 @@ func createCoreDNSAddon(deploymentBytes, serviceBytes, configBytes []byte, clien
238
240
}
239
241
240
242
// Create the ConfigMap for CoreDNS or update it in case it already exists
241
- if err := apiclient .CreateOrUpdateServiceAccount (client , coreDNSServiceAccount ); err != nil {
243
+ if err := apiclient .CreateOrUpdate (client . CoreV1 (). ServiceAccounts ( coreDNSServiceAccount . GetNamespace ()) , coreDNSServiceAccount ); err != nil {
242
244
return err
243
245
}
244
246
@@ -248,13 +250,14 @@ func createCoreDNSAddon(deploymentBytes, serviceBytes, configBytes []byte, clien
248
250
}
249
251
250
252
// Create the deployment for CoreDNS or retain it in case the CoreDNS migration has failed during upgrade
253
+ deploymentsClient := client .AppsV1 ().Deployments (coreDNSDeployment .GetNamespace ())
251
254
if ! canMigrateCorefile {
252
- if err := apiclient .CreateOrRetainDeployment ( client , coreDNSDeployment , kubeadmconstants .CoreDNSDeploymentName ); err != nil {
255
+ if err := apiclient .CreateOrRetain ( deploymentsClient , coreDNSDeployment , kubeadmconstants .CoreDNSDeploymentName ); err != nil {
253
256
return err
254
257
}
255
258
} else {
256
259
// Create the Deployment for CoreDNS or update it in case it already exists
257
- if err := apiclient .CreateOrUpdateDeployment ( client , coreDNSDeployment ); err != nil {
260
+ if err := apiclient .CreateOrUpdate ( deploymentsClient , coreDNSDeployment ); err != nil {
258
261
return err
259
262
}
260
263
}
0 commit comments