Mitigate Issues by Creating Custom Clusters
For issues that can be mitigated, create patch files with the mitigations, then create a cluster kustomization that references these patch files, and, lastly, create a new cluster based on the kustomization file
1. Create Patch Files with CIS Benchmark Mitigations
All files you create in this and the following sections must be present in the same directory.
Establish a name for the cluster you will create by setting the
CLUSTER_NAME
environment variable:Replace the placeholder
<name_of_the_cluster>
with the actual name you want to use.CODEexport CLUSTER_NAME=<name_of_the_cluster>
Create CIS patch files for the issues you want to mitigate. Here are all issues that you can mitigate:
2. Create a Cluster Kustomization
Create a cluster kustomization that references the CIS patch files you created in the previous section.
The kustomization.yaml
file you create in this section must be present in the same directory as the CIS patch files.
Prerequisite
Refer to Customizing CAPI Components for a Cluster to get familiarized with the customization procedure and options. We will use similar terms in this page.
Create Customization
Create a cluster YAML using the DKP CLI, modify any arguments as necessary:
CODEdkp create cluster aws --cluster-name=${CLUSTER_NAME} \ --dry-run \ --output=yaml \ > ${CLUSTER_NAME}.yaml
Create a
kustomization.yaml
file to include patches for each of the CIS mitigations.In this example, we use the CIS-1.2.18 patch, but you can include all mitigation files you created in the first section.
YAMLcat <<EOF > kustomization.yaml apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization bases: - ${CLUSTER_NAME}.yaml patches: - cis-1.2.18-patch.yaml #- Add more CIS patch files here. EOF
3. Create a Cluster with the Kustomization
The CIS patch, kustomization.yaml
, and ${CLUSTER_NAME}.yaml
files must be present in the same directory.
1. Create a Bootstrap Cluster. Ensure that the bootstrap cluster has been created for the desired provider:
Run the following command to apply the customizations and create a new cluster:
CODEkubectl create -k .
Monitor and watch the cluster creation.