RELEASE and DEPLOY Phase

Deployment can be of infrastructure or application; however, we should scan our deployment files. We can also add a manual trigger where the pipeline waits for external user validation before proceeding to the next stage, or it can be an automated trigger.

Static scan of Kubernetes manifest file or Helm chart

It is always a good practice to scan your Kubernetes deployment or Helm chart before deploying. We can use Checkovarrow-up-right to scans Kubernetes manifests and identifies security and configuration issues. It also supports Helm chart scanning. We can also use terrascanarrow-up-right and kubeLinterarrow-up-right to scan the Kubernetes manifest.

docker run -t -v $(pwd):/output bridgecrew/checkov -f /output/keycloak-deploy.yml -o json
# For Helm
docker run -t -v $(pwd):/output bridgecrew/checkov -d /output/ --framework helm -o json

Pre-deploy policy check Kubernete manifest YAML file

Kyvernoarrow-up-right adds an extra layer of security where only the allowed type of manifest is deployed onto kubernetes, otherwise, it will reject or we can set validationFailureAction to audit which only logs the policy violation message for reporting. Kubewardenarrow-up-right and Gatekeeperarrow-up-right are alternative tools available to enforce policies on Kubernetes CRD.

Here is a simple Kyverno policyarrow-up-right to disallow the image’s latest tagarrow-up-right.

kube-bench for CIS scan

kube-bencharrow-up-right checks whether Kubernetes is deployed securely by running the checks documented in the CIS Kubernetes Benchmark. We can deploy kube-bencharrow-up-right as a Job that runs daily and consume its report in CI/CD to pass or fail the pipeline based on the level of severity.

kubectl apply -f eks-job.yaml
kubectl logs kube-bench-pod-name

IaC scanning:

terraform init
terraform plan -out tf.plan
terraform show -json tf.plan | jq '.' > tf.json
checkov -f tf.json

After scanning for Kubernetes deployment and kube-bench we can deploy our application.

Last updated