我正在尝试部署更新。安装工作正常,但是当我更改 Job 的 yaml 文件中的图像字段并尝试滚动更新时,会发生错误。
错误:升级失败:无法使用种类作业修补“dev1-test-db-migrate-job”:Job.batch “dev1-test-db-migrate-job”无效:spec.template:无效值: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"}, 注释: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", 命令:[]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" , 格式:"DecimalSI"}, "memory":resource.Quantity{i:resource.int64Amount{value:134217728, scale:0}, d:resource.infDecAmount{Dec:(*inf.Dec)(nil)}, s:"",格式:"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 :(*核。PodSecurityContext)(0xc010460000), ImagePullSecrets:[]core.LocalObjectReference{core.LocalObjectReference{Name:"artifactory-tradeplace-registry"}}, 主机名:"", 子域:"", 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)}}:字段不可变主机名:“”,子域:“”,亲和力:(*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)}}:字段不可变主机名:“”,子域:“”,亲和力:(*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)}}:字段不可变DNSConfig:(*core.PodDNSConfig)(nil), ReadinessGates:[]core.PodReadinessGate(nil), RuntimeClassName:(*string)(nil), Overhead:core.ResourceList(nil), EnableServiceLinks:(*bool)(nil ), TopologySpreadConstraints:[]core.TopologySpreadConstraint(nil)}}: 字段是不可变的DNSConfig:(*core.PodDNSConfig)(nil), ReadinessGates:[]core.PodReadinessGate(nil), RuntimeClassName:(*string)(nil), Overhead:core.ResourceList(nil), EnableServiceLinks:(*bool)(nil ), TopologySpreadConstraints:[]core.TopologySpreadConstraint(nil)}}: 字段是不可变的
还是没明白哪个字段应该是不可变的,大概是Image,不过很奇怪,能嵌入Image是有道理的。
例如,当我将字段图像从 ...: insurance-master-682 更改为 ...: insurance-master-681 时,会发生错误
每次安装或更新时,我都会更改图表文件,更改版本字段。那么,有人遇到过这种情况吗?虽然我看到唯一的出路是在更新之前应用“kubectl delete job ...”
'templetes' 目录中的 yamls 的一部分:
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 示例
apiVersion: v2
name:
description: A Helm chart for Kubernetes
type: application
version: 0.1.20200505t154055
appVersion: 1.16.0