Migrate auditd settings from the Cluster object to the auditd module¶
The deprecated auditd parameters of the Cluster object are no longer
applied to the host operating system after the cluster update to 26.1 for
MOSK clusters and to 2.31.0 for management clusters.
Therefore, if auditd is enabled on the management or
MOSK clusters, migrate its settings to the dedicated auditd
host operating system configuration module after updating to the releases
mentioned above to unblock the feature.
To migrate auditd settings from the Cluster object to the auditd module:
Obtain the management cluster
kubeconfigas described in Connect to a MOSK cluster.Set the following variables:
NAMESPACE="cluster_namespace" KUBECONFIG="path/to/mgmt-cluster-kubeconfig" CLUSTER_NAME="cluster_name"
In the
Clusterobject, ensure that themanagedfield in thespec.providerSpec.value.audit.auditdsection is set tofalse:kubectl --kubeconfig "${KUBECONFIG}" -n "${NAMESPACE}" get cluster "${CLUSTER_NAME}" -o jsonpath="{.spec.providerSpec.value.audit.auditd.managed}"
Otherwise, set
managedtofalsemanually.Using the same section, capture all auditd parameters, except
managed, for further use and store them securely:kubectl --kubeconfig "${KUBECONFIG}" -n "${NAMESPACE}" get cluster "${CLUSTER_NAME}" -oyaml | grep -A 15 auditd
For example:
auditd: backlogLimit: 4096 enabled: true enabledAtBoot: true managed: false
Using the
LABEL="<auditd-label-name>"variable, set a custom label for all machines of the cluster.for mname in $(kubectl --kubeconfig "${KUBECONFIG}" -n "${NAMESPACE}" get machine -oname); do kubectl --kubeconfig "${KUBECONFIG}" -n "${NAMESPACE}" patch "${mname}" --type=merge -p '{"metadata":{"labels":{"'"${LABEL}"'":"true"}}}' done
Verify that the label is set on all machines:
for mname in $(kubectl --kubeconfig "${KUBECONFIG}" -n "${NAMESPACE}" get machine -oname); do kubectl --kubeconfig "${KUBECONFIG}" -n "${NAMESPACE}" get "${mname}" -o jsonpath="{.metadata.labels['${LABEL}']}" done
Verify that the system output is
truefor all machines.Prepare and apply the
HostOSConfigurationobject:In the
machineSelectorfield, specify the label configured in the previous step.In the
valuesfield, specify the previously captured auditd parameters.In the
configsfield, specify the auditd module and its version.
Caution
The
customRulesX32andcustomRulesX64parameters are not present in the auditd module. Use thecustomRulesparameter of the module instead.For configuration details, see:
Verify that the object is applied using the
statusfield of theHostOSConfigurationobject:kubectl --kubeconfig "${KUBECONFIG}" -n "${NAMESPACE}" get hoc <hoc-object-name> -o jsonpath="{.status.configs[*].error}"
For a description of the
statusfields, see HostOSConfiguration status.Optional. Remove the migrated auditd parameters from the
Clusterobject:kubectl --kubeconfig "${KUBECONFIG}" -n "${NAMESPACE}" edit cluster "${CLUSTER_NAME}"
Leave the following fields only:
spec: providerSpec: value: audit: auditd: managed: false