Skip to content

Commit

Permalink
Enable Audit Logs for Tinkerbell
Browse files Browse the repository at this point in the history
  • Loading branch information
tatlat committed Oct 3, 2023
1 parent 5428b97 commit cd16b0f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
23 changes: 23 additions & 0 deletions pkg/providers/tinkerbell/config/template-cp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,28 @@ spec:
{{- if .apiserverExtraArgs }}
apiServer:
extraArgs:
audit-policy-file: /etc/kubernetes/audit-policy.yaml
audit-log-path: /var/log/kubernetes/api-audit.log
audit-log-maxage: "30"
audit-log-maxbackup: "10"
audit-log-maxsize: "512"
{{ .apiserverExtraArgs.ToYaml | indent 10 }}
{{- end }}
extraVolumes:
{{- if (eq .format "bottlerocket") }}
- hostPath: /var/lib/kubeadm/audit-policy.yaml
{{- else }}
- hostPath: /etc/kubernetes/audit-policy.yaml
{{- end }}
mountPath: /etc/kubernetes/audit-policy.yaml
name: audit-policy
pathType: File
readOnly: true
- hostPath: /var/log/kubernetes
mountPath: /var/log/kubernetes
name: audit-log-dir
pathType: DirectoryOrCreate
readOnly: false
{{- if .awsIamAuth}}
extraVolumes:
- hostPath: /var/lib/kubeadm/aws-iam-authenticator/
Expand Down Expand Up @@ -316,6 +336,9 @@ spec:
owner: root:root
path: /var/lib/kubeadm/aws-iam-authenticator/pki/key.pem
{{- end}}
{{ .auditPolicy | indent 8 }}
owner: root:root
path: /etc/kubernetes/audit-policy.yaml
{{- if (ne .format "bottlerocket") }}
{{- if .proxyConfig }}
- content: |
Expand Down
6 changes: 6 additions & 0 deletions pkg/providers/tinkerbell/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,12 @@ func buildTemplateMapCP(
"cpSkipLoadBalancerDeployment": clusterSpec.Cluster.Spec.ControlPlaneConfiguration.SkipLoadBalancerDeployment,
}

auditPolicy, err := common.GetAuditPolicy(clusterSpec.Cluster.Spec.KubernetesVersion)
if err != nil {
return nil, err
}
values["auditPolicy"] = auditPolicy

if clusterSpec.Cluster.Spec.ControlPlaneConfiguration.UpgradeRolloutStrategy != nil {
values["upgradeRolloutStrategy"] = true
values["maxSurge"] = clusterSpec.Cluster.Spec.ControlPlaneConfiguration.UpgradeRolloutStrategy.RollingUpdate.MaxSurge
Expand Down

0 comments on commit cd16b0f

Please sign in to comment.