kube-enforcer
A Helm chart for the Aqua KubeEnforcer
About this chart
Aqua KubeEnforcer Helm Charts
This page provides instructions for using Helm charts to configure and deploy the Aqua KubeEnforcer.
Contents
- Aqua KubeEnforcer Helm Charts
- Contents
- Trivy Operator
- Prerequisites
- Container registry credentials
- Clone the GitHub repository with the charts
- Conncet to Aqua Saas / Gateway via proxy
- Configure TLS authentication between the KubeEnforcer and the API Server
- How to use cert-manager to configure TLS authentication between the KubeEnforcer and the API Server
- Deploy the Helm chart
- Deploy the KubeEnforcer with Trivy Operator from a Helm private repository
- Configuration for discovery
- Configuration for performing kube-bench scans
- 4. Configuring KubeEnforcer mTLS with Gateway/Envoy
- Create Root CA (Done once)
- Create the certificate key and certificate for kube-enforcer
- Create secrets with generated certs and change
values.yamlas mentioned below
- Configuration for KubeEnforcer Advance deployment
- NetworkPolicy (optional)
- Configuration for KubeEnforcer with cert-manager
- Integrate Kube-Enforcer with Hashicorp Vault to Load Token
- Argo Rollouts support
- Configurable Variables
- Issues and feedback
Trivy Operator
Trivy Operator is the default security scanner for KubeEnforcer in this chart version. The chart enables Trivy Operator by default and keeps Starboard disabled unless you explicitly switch.
:exclamation: Only one operator should be enabled per deployment. Use either
trivy.enabled=trueorstarboard.enabled=true.
An important part of Kubernetes security is the evaluation of workload compliance results with respect to Kubernetes Assurance Policies, and preventing the deployment of non-compliant workloads; see Admission control for Kubernetes containers.
When Trivy Operator is deployed, it assesses workload compliance throughout the lifecycle of the workloads. This enables the KubeEnforcer to:
- Re-evaluate workload compliance during workload runtime, taking any workload and policy changes into account
- Reflect the results of compliance evaluation in the Aqua UI at all times, not only when workloads are created
When Trivy Operator is not deployed, the KubeEnforcer will check workloads for compliance only when the workloads are started.
Prerequisites
Container registry credentials
Link
Clone the GitHub repository with the charts
git clone https://github.com/aquasecurity/aqua-helm.git
cd aqua-helm/
Conncet to Aqua Saas / Gateway via proxy
Aqua Enforcers can use http proxies for their communication. The http proxy must support gRPC, TLS/SSL inspection is not recommended.
To configure a proxy set http_proxy, https_proxy and no_proxy in extraEnvironmentVars
extraEnvironmentVars:
http_proxy: http://proxy01.proxy.svc.cluster.local:8080
https_proxy: http://proxy01.proxy.svc.cluster.local:8080
no_proxy: .svc.cluster.local
As Kube Enforcer need to communicate with the KubeAPI, make sure no_proxy is configured to by pass the proxy. Use a comma separated list of IPs, FQDN or FQDN suffixes.
If you deploy the Aqua Enforcer enforcer.enabled=true with this chart, make sure you set the environment variables accordingly in the enforcer section.
If networkPolicy.enabled=true, egress to the proxy is not covered by gatewayEgressCidrs / gatewayNamespace (those are pinned to global.gateway.port, not the proxy's port) or by the default ports on additionalEgressCidrs. Configure networkPolicy.proxyNamespace + optional networkPolicy.proxyPodLabels for an in-cluster proxy, or networkPolicy.proxyEgressCidrs for an external/node-level proxy; both require networkPolicy.proxyPort (the proxy's listening port, e.g. 8080 for http://proxy01.proxy.svc.cluster.local:8080 above). On CNIs such as Calico, reaching an in-cluster proxy via its Service ClusterIP does not work under NetworkPolicy egress (DNAT happens before policy evaluation) — use proxyNamespace + proxyPodLabels, or the proxy pod/node IP CIDR via proxyEgressCidrs, instead. See NetworkPolicy (optional).
Configure TLS authentication between the KubeEnforcer and the API Server
You need to enable TLS authentication from the API Server to the KubeEnforcer. Perform these steps:
Create TLS certificates which are signed by the local CA certificate. We will pass these certificates with a Helm command to enable TLS authentication between the KubeEnforcer and the API Server to receive events from the ValidatingWebhookConfiguration for Image Assurance functionality.
You can generate these certificates by executing the script:
./kube-enforcer/gen-certs.sh
You can also use your own certificates without generating new ones for TLS authentication. All you need is a root CA certificate, a certificate signed by a CA, and a certificate key.
You can configure the certificates generated from the above script or own certificates in the values.yaml file.
You need to encode the certificates into base64 for ca.crt, server.crt and server.key using this command:
cat <ca.crt> | base64 | tr -d '\n'
cat <server.crt> | base64 | tr -d '\n'
cat <server.key> | base64 | tr -d '\n'
Provide the certificates previously obtained in the fields of the values.yaml file, as indicated here:
certsSecret:
create: true
name: aqua-kube-enforcer-certs
serverCertificate: "<base64_encoded_server.crt>"
serverKey: "<base64_encoded_server.key>"
webhooks:
caBundle: "<base64_encoded_ca.crt>"
How to use cert-manager to configure TLS authentication between the KubeEnforcer and the API Server
If you are planning to create and manage your self-signed certificates using cert-manger,
You need set webhook.certManager to be true and add annotations
webhooks:
certManager: true
validatingWebhook:
annotations:
cert-manager.io/inject-ca-from: < namespace >/< certsSecret.name >
mutatingWebhook:
annotations:
cert-manager.io/inject-ca-from: < namespace >/< certsSecret.name >
Deploy the Helm chart
Deploy the KubeEnforcer with Trivy Operator from a Helm private repository
-
Add Aqua Helm Repository
helm repo add aqua-helm https://helm.aquasec.com helm repo update -
(Optional) Update the Helm charts
values.yamlfile with your environment's custom values, registry secret, Aqua Server (console) credentials, and TLS certificates. This eliminates the need to pass the parameters to the Helm command. Then run one of the following commands to deploy the relevant services. -
Check for available chart versions either from Changelog or by running the below command
helm search repo aqua-helm/kube-enforcer --versions -
Choose either 4a or 4b:
4a. To deploy the KubeEnforcer on the same cluster as the Aqua Server (console), run this command on that cluster:
helm upgrade --install --namespace aqua kube-enforcer aqua-helm/kube-enforcer4b. Multi-cluster: To deploy the KubeEnforcer in a different cluster:
First, create a namespace on that cluster named
aqua:kubectl create namespace aquaNext, copy the content from Values.yaml, make the respective changes, and run the following command:
helm upgrade --install --namespace aqua kube-enforcer aqua-helm/kube-enforcer --values values.yaml --version <> -
Optional flags:
| Flag | Description |
|---|---|
| --namespace | defaults to aqua |
| --aquaSecret.kubeEnforcerToken | defaults to "ke-token"; you can obtain the KubeEnforcer token from Aqua Enterprise under the Enforcers screen in the default/custom KubeEnforcer group, or you can manually approve KubeEnforcer authentication from Aqua Enterprise under the default/custom KubeEnforcer group in the Enforcers screen. |
Configuration for discovery
To perform discovery on the cluster, the KubeEnforcer needs a dedicated ClusterRole with get, list, and watch permissions on pods, secrets, nodes, namespaces, deployments, ReplicaSets, ReplicationControllers, StatefulSets, DaemonSets, jobs, CronJobs, ClusterRoles, ClusterRoleBindings, and ComponentStatuses`.
Configuration for performing kube-bench scans
To perform kube-bench scans in the cluster, the KubeEnforcer needs:
- A dedicated role in the
aquanamespace withget,list, andwatchpermissions onpods/log createanddeletepermissions on jobscreateanddeletepermissions on pods(Only for Openshift platform)
4. Configuring KubeEnforcer mTLS with Gateway/Envoy
By default, deploying Aqua Enterprise configures TLS-based encrypted communication, using self-signed certificates, between Aqua components. If you want to use self-signed certificates to establish mTLS between kube-enforcer and gateway/envoy use the below instructions to generate rootCA and component certificates
Note: mTLS communication and setup is only supported for self-hosted Aqua. It is not supported for Aqua ESE and Aqua SAAS
Create Root CA (Done once)
Important: The rootCA certificate used to generate the certificates for aqua server/gateway/envoy, use the same rootCA to generate kube-enforcer certificates.
Create the certificate key and certificate for kube-enforcer
1. Create component key:
openssl genrsa -out aqua_kube-enforcer.key 2048
2. Create the signing (csr):
The certificate signing request is where you specify the details for the certificate you want to generate. This request will be processed by the owner of the Root key (you in this case since you create it earlier) to generate the certificate.
Important: Please mind that while creating the signing request is important to specify the Common Name providing the IP address or domain name for the service, otherwise the certificate cannot be verified.
- Generating aqua_kube-enforcer csr:
openssl req -new -sha256 -key aqua_kube-enforcer.key \
-subj "/C=US/ST=MA/O=aqua/CN=aqua-kube-enforcer" \
-out aqua_kube-enforcer.csr
3. Verify the CSR content:
- verify the generated csr content(optional)
openssl req -in aqua_kube-enforcer.csr -noout -text
4. Generate the certificate using the component csr and key along with the CA Root key:
openssl x509 -req -in aqua_kube-enforcer.csr -CA rootCA.crt -CAkey rootCA.key -CAcreateserial -out aqua_kube-enforcer.crt -days 500 -sha256
5. Verify the certificate content:
- verify the generated certificate content(optional)
openssl x509 -in aqua_kube-enforcer.crt -text -noout
Create secrets with generated certs and change values.yaml as mentioned below
- Create Kubernetes secret for kube-enforcer using the generated SSL certificates.
# Example:
# Change < certificate filenames > respectively
kubectl create secret generic ke-mtls-certs --from-file aqua_kube-enforcer.key --from-file aqua_kube-enforcer.crt --from-file rootCA.crt -n aqua
- Enable
TLS.enabledtotruein values.yaml - Add the certificates secret name
TLS.secretNamein values.yaml - Add respective certificate file names to
TLS.publicKey_fileName,TLS.privateKey_fileNameandTLS.rootCA_fileName(Add rootCA if certs are self-signed) in values.yaml - For enabling mTLS/TLS connect
Deploy kube-enforcer with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has kube-enforcer on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartkube-enforcer is pinned at v2022.4.86 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply