Closed d11wtq closed 6 years ago
Apologies. Figured out that the way to do this is:
resources = K8s::Resource.from_files('/path/to/manifests')
resources.each do |resource|
server_resource = begin
client.get_resource(resource)
rescue K8s::Error::NotFound
client.create_resource(resource)
end
client.update_resource(server_resource)
end
I'm trying to do the following (should essentially be a no-op, equivalent to
kubectl apply
with unchanged resources):Which produces an error because
resourceVersion
andclusterIP
seem to be sent as empty strings to the server.There are two resources in the list:
Deployment
andService
(NodePort). Both were originally created withkubectl apply
. The deployment seems to be update fine, but the service always blows up on the error above. I'm not sure if this is expected, or if I'm supposed to change the spec in some way once I've read the manifests off disk.Is this the correct way to do something along the lines of
kubectl apply
? Happy with anything that more or less performs an upsert style operation for the resource.Here is the entire manifest, if it helps: