diff --git a/lib/bonny/admission_control.ex b/lib/bonny/admission_control.ex index 4e427c5..91dca1f 100644 --- a/lib/bonny/admission_control.ex +++ b/lib/bonny/admission_control.ex @@ -10,18 +10,20 @@ defmodule Bonny.AdmissionControl do {:admission_config, get_admission_config(conn, operator_name)}, {:cert_bundle, {:ok, cert_bundle}} <- {:cert_bundle, get_or_create_cert_bundle(conn, operator_name)} do + encoded_ca = Base.encode64(cert_bundle["ca"]) + admission_configurations |> Enum.reject(fn config -> Enum.all?( List.wrap(config["webhooks"]), - &(&1["clientConfig"]["caBundle"] == cert_bundle["ca"]) + &(&1["clientConfig"]["caBundle"] == encoded_ca) ) end) |> Enum.map(fn config -> put_in( config, - ["webhooks", Access.all(), ["clientConfig"]["caBundle"]], - cert_bundle["ca"] + ["webhooks", Access.all(), "clientConfig", "caBundle"], + encoded_ca ) end) |> Enum.each(&apply_admission_config(conn, &1)) @@ -199,9 +201,8 @@ defmodule Bonny.AdmissionControl do defp apply_admission_config(conn, admission_config) do result = admission_config - |> K8s.Client.apply() - |> K8s.Client.put_conn(conn) - |> K8s.Client.run() + |> Bonny.Resource.drop_managed_fields() + |> Bonny.Resource.apply(conn, []) case result do {:ok, _} -> :ok