m/n/k/reconciler: implement updates
The reconciler now checks if already present object are equal to the
expected object, and else updates them. If the update fails due to
immutable fields, the object is instead deleted and recreated.
Also, the reconciler now logs create/update/delete operations.
For the CSI driver, the StorageCapacity and RequiresRepublish were added
and set to their default value. If we don't do this, the API server will
add these defaults, and then our update comparison fails. There is also
a new test which ensures that expected objects have all defaults already
applied. This test will fail if a Kubernetes upgrade adds new fields
with default values.
Closes #288.
Change-Id: Ibfb37d07b4613ae1a883ad47715feeda87135820
Reviewed-on: https://review.monogon.dev/c/monogon/+/2893
Tested-by: Jenkins CI
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
diff --git a/metropolis/node/kubernetes/reconciler/BUILD.bazel b/metropolis/node/kubernetes/reconciler/BUILD.bazel
index caa239a..f7bb47f 100644
--- a/metropolis/node/kubernetes/reconciler/BUILD.bazel
+++ b/metropolis/node/kubernetes/reconciler/BUILD.bazel
@@ -30,6 +30,9 @@
"@io_k8s_api//node/v1:node",
"@io_k8s_api//rbac/v1:rbac",
"@io_k8s_api//storage/v1:storage",
+ "@io_k8s_apimachinery//pkg/api/equality",
+ "@io_k8s_apimachinery//pkg/api/errors",
+ "@io_k8s_apimachinery//pkg/api/validation",
"@io_k8s_apimachinery//pkg/apis/meta/v1:meta",
"@io_k8s_client_go//kubernetes",
"@org_golang_google_protobuf//proto",
@@ -53,8 +56,18 @@
"//version",
"//version/spec",
"@io_etcd_go_etcd_tests_v3//integration",
+ "@io_k8s_apimachinery//pkg/api/equality",
+ "@io_k8s_apimachinery//pkg/api/errors",
+ "@io_k8s_apimachinery//pkg/api/validation",
"@io_k8s_apimachinery//pkg/apis/meta/v1:meta",
+ "@io_k8s_apimachinery//pkg/runtime",
+ "@io_k8s_apimachinery//pkg/runtime/schema",
+ "@io_k8s_apimachinery//pkg/util/validation/field",
"@io_k8s_client_go//kubernetes/fake",
+ "@io_k8s_kubernetes//pkg/apis/node/install",
+ "@io_k8s_kubernetes//pkg/apis/policy/install",
+ "@io_k8s_kubernetes//pkg/apis/rbac/install",
+ "@io_k8s_kubernetes//pkg/apis/storage/install",
"@org_golang_google_protobuf//proto",
],
)