Kubernetes version:
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.2", GitCommit:"52c56ce7a8272c798dbc29846288d7cd9fbae032", GitTreeState:"clean", BuildDate:"2020-04-16T11:56:40Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.4", GitCommit:"d360454c9bcd1634cf4cc52d1867af5491dc9c5f", GitTreeState:"clean", BuildDate:"2020-11-11T13:09:17Z", GoVersion:"go1.15.2", Compiler:"gc", Platform:"linux/amd64"}
test-patch.json
{
"minReadySeconds" : null,
"paused" : null,
"progressDeadlineSeconds" : null,
"replicas" : null,
"revisionHistoryLimit" : null,
"selector" : null,
"strategy" : null,
"template" : {
"metadata" : null,
"spec" : {
"activeDeadlineSeconds" : null,
"affinity" : null,
"automountServiceAccountToken" : null,
"containers" : [ {
"args" : null,
"command" : null,
"env" : null,
"envFrom" : null,
"image" : null,
"imagePullPolicy" : null,
"lifecycle" : null,
"livenessProbe" : null,
"name" : "database",
"ports" : null,
"readinessProbe" : null,
"resources" : null,
"securityContext" : null,
"stdin" : null,
"stdinOnce" : null,
"terminationMessagePath" : null,
"terminationMessagePolicy" : null,
"tty" : null,
"volumeDevices" : null,
"volumeMounts" : [ {
"mountPath" : "/var/lib/postgresql/",
"mountPropagation" : null,
"name" : "olddatadir",
"readOnly" : null,
"subPath" : null,
"subPathExpr" : null
} ],
"workingDir" : null
} ],
"dnsConfig" : null,
"dnsPolicy" : null,
"enableServiceLinks" : null,
"hostAliases" : null,
"hostIPC" : null,
"hostNetwork" : null,
"hostPID" : null,
"hostname" : null,
"imagePullSecrets" : null,
"initContainers" : null,
"nodeName" : null,
"nodeSelector" : null,
"priority" : null,
"priorityClassName" : null,
"readinessGates" : null,
"restartPolicy" : null,
"runtimeClassName" : null,
"schedulerName" : null,
"securityContext" : null,
"serviceAccount" : null,
"serviceAccountName" : null,
"shareProcessNamespace" : null,
"subdomain" : null,
"terminationGracePeriodSeconds" : null,
"tolerations" : null,
"volumes" : [ {
"awsElasticBlockStore" : null,
"azureDisk" : null,
"azureFile" : null,
"cephfs" : null,
"cinder" : null,
"configMap" : null,
"csi" : null,
"downwardAPI" : null,
"emptyDir" : null,
"fc" : null,
"flexVolume" : null,
"flocker" : null,
"gcePersistentDisk" : null,
"gitRepo" : null,
"glusterfs" : null,
"hostPath" : {
"path" : "/vol/database/",
"type" : "Directory"
},
"iscsi" : null,
"name" : "olddatadir",
"nfs" : null,
"persistentVolumeClaim" : null,
"photonPersistentDisk" : null,
"portworxVolume" : null,
"projected" : null,
"quobyte" : null,
"rbd" : null,
"scaleIO" : null,
"secret" : null,
"storageos" : null,
"vsphereVolume" : null
} ]
}
}
}
deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "22"
meta.helm.sh/release-name: test-provisioning-3
meta.helm.sh/release-namespace: test-provisioning-3
creationTimestamp: "2020-11-24T14:18:55Z"
generation: 29
labels:
app: app-name
io.cattle.field/appId: test-provisioning-3
io.rancher.container.network: "false"
name: database
namespace: test-provisioning-3
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app: app-name
strategy:
rollingUpdate:
maxSurge: 0
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
app: app-name
spec:
containers:
- command:
- /bin/sleep
- "9999"
image: postgres:9.6
imagePullPolicy: Always
name: database
resources: {}
securityContext:
capabilities: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /var/lib/postgresql/data
name: database
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
volumes:
- hostPath:
path: /vol/database/data
type: DirectoryOrCreate
name: database
I am trying to patch this deployment with the provided patch. However, all I am getting is deployment.apps/database patched (no change)
, even though the volumes that should be added are clearly not added.
Tested this with plain old kubectl
but this should primarily work through the Kubernetes Java API.
The JSONs seen here are taking directly from what the Kubernetes Java API generated.
The patchNamespacedDeployment
operation is executed by a ClientBuilder.standard().setOverridePatchFormat(V1Patch.PATCH_FORMAT_STRATEGIC_MERGE_PATCH).build()
, so this form of “adding” a volume should be absolutely supported and a valid operation.
How can I make this work?