Я пытаюсь использовать клиент Godaddy K8s для исправления CRD.
Следуя их примеру , я попытался:
Перевод их примера напрямую:
const patchService = await client.apis["serving.knative.dev"].v1alpha1.namespaces('default').services.patch({body: {
"spec": {
"template": {
"spec": {
"containers": [
{
"image": "docker.io/quantomworks/mcsh-site:" + build.metadata.annotations['hook-to-k8s']
}
]
}
}
}
}})
console.log("Patch result:")
console.log(patchService)
Созданиеобъект исправления службы , , следуя этому примеру .
const servicePatchObject = [{ op: "replace", path: "/spec/runLatest/configuration/revisionTemplate/spec/container/image", value: "docker.io/quantomworks/mcsh-site:" + build.metadata.annotations['hook-to-k8s']}]
const patchService = await client.apis["serving.knative.dev"].v1alpha1.namespaces('default').services('mcserverhosting-net-site').patch({body: servicePatchObject})
Взяв файл yaml , который я могу запустить с содержимым, которое соответствует успешному kubectl patch services.serving.knative.dev mcserverhosting-net-site --type json -p
- op: replace
path: /spec/runLatest/configuration/revisionTemplate/spec/container/image
value: docker.io/quantomworks/mcsh-site:latest
И , а затем отправка непосредственно
const patchService = await client.apis["serving.knative.dev"].v1alpha1.namespaces('default').services('mcserverhosting-net-site').patch(servicePatch)
Все приводит к следующей ошибке:
node-webhook┊ (node:17) UnhandledPromiseRejectionWarning: Error: the body of the request was in an unknown format - accepted media types include: application/json-patch+json, application/merge-patch+json
node-webhook┊ at /usr/src/app/node_modules/kubernetes-client/lib/backends/request.js:189:25
node-webhook┊ at Request._callback (/usr/src/app/node_modules/kubernetes-client/lib/backends/request.js:148:14)
node-webhook┊ at Request.self.callback (/usr/src/app/node_modules/request/request.js:185:22)
node-webhook┊ at Request.emit (events.js:196:13)
node-webhook┊ at Request.<anonymous> (/usr/src/app/node_modules/request/request.js:1161:10)
node-webhook┊ at Request.emit (events.js:196:13)
node-webhook┊ at IncomingMessage.<anonymous> (/usr/src/app/node_modules/request/request.js:1083:12)
node-webhook┊ at Object.onceWrapper (events.js:284:20)
node-webhook┊ at IncomingMessage.emit (events.js:201:15)
node-webhook┊ at endReadableNT (_stream_readable.js:1130:12)
node-webhook┊ (node:17) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with
.catch(). (rejection id: 2)
Полный исходный код можетможно найти на GitHub .