From 1543ad4c4217006b66c2fc00d52c2243780bb4c4 Mon Sep 17 00:00:00 2001 From: fhanportainer <79428273+fhanportainer@users.noreply.github.com> Date: Wed, 8 Sep 2021 13:40:10 +1200 Subject: [PATCH] fix(k8s): fixed apply a note to k8s application (#5586) --- app/kubernetes/converters/deployment.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/kubernetes/converters/deployment.js b/app/kubernetes/converters/deployment.js index 080644641..0d7705441 100644 --- a/app/kubernetes/converters/deployment.js +++ b/app/kubernetes/converters/deployment.js @@ -54,10 +54,15 @@ class KubernetesDeploymentConverter { payload.spec.template.metadata.labels.app = deployment.Name; payload.spec.template.metadata.labels[KubernetesPortainerApplicationNameLabel] = deployment.ApplicationName; payload.spec.template.spec.containers[0].name = deployment.Name; - payload.spec.template.spec.containers[0].image = buildImageFullURI(deployment.ImageModel); - if (deployment.ImageModel.Registry && deployment.ImageModel.Registry.Authentication) { - payload.spec.template.spec.imagePullSecrets = [{ name: `registry-${deployment.ImageModel.Registry.Id}` }]; + + if (deployment.ImageModel) { + payload.spec.template.spec.containers[0].image = buildImageFullURI(deployment.ImageModel); + + if (deployment.ImageModel.Registry && deployment.ImageModel.Registry.Authentication) { + payload.spec.template.spec.imagePullSecrets = [{ name: `registry-${deployment.ImageModel.Registry.Id}` }]; + } } + payload.spec.template.spec.affinity = deployment.Affinity; KubernetesCommonHelper.assignOrDeleteIfEmpty(payload, 'spec.template.spec.containers[0].env', deployment.Env); KubernetesCommonHelper.assignOrDeleteIfEmpty(payload, 'spec.template.spec.containers[0].volumeMounts', deployment.VolumeMounts);