我正在尝试部署更新。安装工作正常,但是当我更改Job的yaml文件中的image字段并尝试滚动更新时,会发生错误。
错误:升级失败:无法修补类型为Job:Job.batch“ dev1-test-db-migrate-job”的“ dev1-test-db-migrate-job”无效:spec.template:无效值:core .PodTemplateSpec {ObjectMeta:v1.ObjectMeta {名称:“”,GenerateName:“”,命名空间:“”,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),标签: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) ,终结器:[] string(nil),ClusterName:“”,ManagedFields:[] v1.ManagedFieldsEntry(nil)},Spec:core.PodSpec {卷:[] core.Volume(nil),InitContainers:[] core。 Container(nil),容器:[] core.Container {core.Container {名称:“ app”,图像:“ ...:insurance-master-68 2“,命令:[] 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:”“,端口:[] 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”,格式:“ DecimalSI”},“内存” :resource.Quantity {i:resource.int64Amount {value:268435456,scale:0},d:resource.infDecAmount {Dec:(* inf.Dec)(nil)},s:“”,格式:“ BinarySI”} },Requests:core.ResourceList {“ cpu”:resource.Quantity {i:resource.int64Amount {value:100,scale:-3},d:resource.infDecAmount {D ec:(* 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),生命周期:(* core.Lifecycle)(nil ),TerminationMessagePath:“ / dev / termination-log”,TerminationMessagePolicy:“文件”,ImagePullPolicy:“ IfNotPresent”,SecurityContext:(* core.SecurityContext)(nil),Stdin:false,StdinOnce:false,TTY:false}} ,EphemeralContainers:[] core.EphemeralContainer(nil),RestartPolicy:“从不”,TerminationGracePeriodSeconds:(* int64)(0xc014591f78),ActiveDeadlineSeconds:(* int64)(nil),DNSPolicy:“ ClusterFirst”,NodeSelector:map [字符串(nil),ServiceAccountName:“”,AutomountServiceAccountToken:(* bool)(nil),NodeName:“”,SecurityContext:(* core.PodSecurityContext)(0xc010460000),ImagePullSecrets :[] core.LocalObjectReference {core.LocalObjectReference {名称:“ artifactory-tradeplace-registry”}},主机名:“”,子域:“”,亲和力:(* 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),开销:core.ResourceList(nil),EnableServiceLinks:(* bool) (nil),TopologySpreadConstraints:[] core.TopologySpreadConstraint(nil)}}:字段是不可变的
我仍然不知道哪个字段应该是不可变的,可能是Image,但这很奇怪,我可以嵌入Image是很有意义的。
例如,当我将“图像”字段从...:Insurance-master-682更改为...:insurance-master-681时,就会发生错误
每次安装或更新时都会更改图表文件,因此会更改版本字段。 那么,有人遇到过这个吗? 虽然我看到的唯一出路是在更新之前应用“ kubectl删除作业...”
“ 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
答案 0 :(得分:1)
您需要删除现有作业并重新运行。可能无法重新运行相同的作业。问题似乎是工作名称。当我尝试使用相同的名称进行升级时,我确实看到了类似的情况,例如:“dev1-test-db-migrate-job”。