I'm trying to deploy updates. Installation works fine, but when I change the image field in the yaml file for Job and try to roll updates, an error occurs.
Error: UPGRADE FAILED: cannot patch "dev1-test-db-migrate-job" with kind Job: Job.batch "dev1-test-db-migrate-job" is invalid: spec.template: Invalid value: core.PodTemplateSpec{ObjectMeta:v1.ObjectMeta{Name:"", GenerateName:"", Namespace:"", SelfLink:"", UID:"", ResourceVersion:"", Generation:0, CreationTimestamp:v1.Time{Time:time.Time{wall:0x0, ext:0, loc:(*time.Location)(nil)}}, DeletionTimestamp:(*v1.Time)(nil), DeletionGracePeriodSeconds:(*int64)(nil), Labels:map[string]string{"controller-uid":"e60854c6-9a57-413c-8f19-175a755c9852", "job-name":"dev1-test-db-migrate-job", "target-app":"db-migrate", "target-domain":"dev1...", "target-service":"test"}, Annotations:map[string]string(nil), OwnerReferences:[]v1.OwnerReference(nil), Finalizers:[]string(nil), ClusterName:"", ManagedFields:[]v1.ManagedFieldsEntry(nil)}, Spec:core.PodSpec{Volumes:[]core.Volume(nil), InitContainers:[]core.Container(nil), Containers:[]core.Container{core.Container{Name:"app", Image:"...:insurance-master-682", Command:[]string{"/bin/sh", "-c"}, Args:[]string{"java -jar ./db/liquibase.jar --logLevel=debug --classpath=./db/mariadb-java-client-2.5.3.jar --driver=org.mariadb.jdbc.Driver --changeLogFile=./db/changelog-insurance.xml --url=$DB_HOST --username=$DB_USER --password=$DB_PASSWORD update"}, WorkingDir:"", Ports:[]core.ContainerPort(nil), EnvFrom:[]core.EnvFromSource{core.EnvFromSource{Prefix:"", ConfigMapRef:(*core.ConfigMapEnvSource)(nil), SecretRef:(*core.SecretEnvSource)(0xc01a48c8a0)}}, Env:[]core.EnvVar(nil), Resources:core.ResourceRequirements{Limits:core.ResourceList{"cpu":resource.Quantity{i:resource.int64Amount{value:200, scale:-3}, d:resource.infDecAmount{Dec:(*inf.Dec)(nil)}, s:"200m", Format:"DecimalSI"}, "memory":resource.Quantity{i:resource.int64Amount{value:268435456, scale:0}, d:resource.infDecAmount{Dec:(*inf.Dec)(nil)}, s:"", Format:"BinarySI"}}, Requests:core.ResourceList{"cpu":resource.Quantity{i:resource.int64Amount{value:100, scale:-3}, d:resource.infDecAmount{Dec:(*inf.Dec)(nil)}, s:"100m", Format:"DecimalSI"}, "memory":resource.Quantity{i:resource.int64Amount{value:134217728, scale:0}, d:resource.infDecAmount{Dec:(*inf.Dec)(nil)}, s:"", Format:"BinarySI"}}}, VolumeMounts:[]core.VolumeMount(nil), VolumeDevices:[]core.VolumeDevice(nil), LivenessProbe:(*core.Probe)(nil), ReadinessProbe:(*core.Probe)(nil), StartupProbe:(*core.Probe)(nil), Lifecycle:(*core.Lifecycle)(nil), TerminationMessagePath:"/dev/termination-log", TerminationMessagePolicy:"File", ImagePullPolicy:"IfNotPresent", SecurityContext:(*core.SecurityContext)(nil), Stdin:false, StdinOnce:false, TTY:false}}, EphemeralContainers:[]core.EphemeralContainer(nil), RestartPolicy:"Never", TerminationGracePeriodSeconds:(*int64)(0xc014591f78), ActiveDeadlineSeconds:(*int64)(nil), DNSPolicy:"ClusterFirst", NodeSelector:map[string]string(nil), ServiceAccountName:"", AutomountServiceAccountToken:(*bool)(nil), NodeName:"", SecurityContext:(*core.PodSecurityContext)(0xc010460000), ImagePullSecrets:[]core.LocalObjectReference{core.LocalObjectReference{Name:"artifactory-tradeplace-registry"}}, Hostname:"", Subdomain:"", Affinity:(*core.Affinity)(nil), SchedulerName:"default-scheduler", Tolerations:[]core.Toleration(nil), HostAliases:[]core.HostAlias(nil), PriorityClassName:"", Priority:(*int32)(nil), PreemptionPolicy:(*core.PreemptionPolicy)(nil), DNSConfig:(*core.PodDNSConfig)(nil), ReadinessGates:[]core.PodReadinessGate(nil), RuntimeClassName:(*string)(nil), Overhead:core.ResourceList(nil), EnableServiceLinks:(*bool)(nil), TopologySpreadConstraints:[]core.TopologySpreadConstraint(nil)}}: field is immutable
I still didn’t understand which field should be immutable, probably Image, but it’s very strange, it makes sense that I can embed Image.
The error occurs when I change the field Image from ...: insurance-master-682 to ...: insurance-master-681 for example
I change the chart file every time I install or update, I change the version field. So, has anyone encountered this? while I see the only way out is to apply 'kubectl delete job ...' before updating
part of yamls in 'templetes' directory:
apiVersion: batch/v1
kind: Job
metadata:
labels:
target-domain: dev1...
target-service: test
name: dev1-test-db-migrate-job
spec:
backoffLimit: 0
template:
metadata:
labels:
target-app: db-migrate
target-domain: dev1...
target-service: test
spec:
containers:
- args:
- java -jar ./db/liquibase.jar --logLevel=debug --classpath=./db/mariadb-java-client-2.5.3.jar
--driver=org.mariadb.jdbc.Driver --changeLogFile=./db/changelog-insurance.xml
--url=$DB_HOST --username=$DB_USER --password=$DB_PASSWORD update
command:
- /bin/sh
- -c
envFrom:
- secretRef:
name: dev1-secret-config-deploy-for-app-gk5b59mb86
image: ...:insurance-master-682
imagePullPolicy: IfNotPresent
name: app
resources:
limits:
cpu: 200m
memory: 256Mi
requests:
cpu: 100m
memory: 128Mi
imagePullSecrets:
- name: artifactory-tradeplace-registry
restartPolicy: Never
Chart.yaml example
apiVersion: v2
name:
description: A Helm chart for Kubernetes
type: application
version: 0.1.20200505t154055
appVersion: 1.16.0