I keep getting the older pods while listing pods (pods in older deployment) for a deployment after recreating the deployment (either by replace or delete and create), using this code:
List<Pod> otelCollectorPods =
client
.pods()
.inNamespace(LOGCOLLECTION_NAMESPACE)
.withLabels(otelCollectorDeployment.getMetadata().getLabels())
.list()
.getItems();
for (Pod pod : otelCollectorPods) {
String podName = pod.getMetadata().getName();
InputStream outputJsonFileInputStream =
client
.pods()
.inNamespace(LOGCOLLECTION_NAMESPACE)
.withName(podName)
.file("/otel-output/json-out.json")
.read();
// do something with the inputstream...
}
I have tried creating deployment using createOrReplace
as well as delete
and the create
, nothing worked:
client
.apps()
.deployments()
.inNamespace(LOGCOLLECTION_NAMESPACE)
.withName(otelCollectorDeployment.getMetadata().getName())
.createOrReplace(otelCollectorDeployment);
--
client
.apps()
.deployments()
.inNamespace(LOGCOLLECTION_NAMESPACE)
.withName(otelCollectorDeployment.getMetadata().getName())
.delete();
client
.apps()
.deployments()
.inNamespace(LOGCOLLECTION_NAMESPACE)
.withName(otelCollectorDeployment.getMetadata().getName())
.create(otelCollectorDeployment);