Install Using Helm
For Ingress NGINX Ingress Controller with open-appsec the following method is recommended if you have an advanced understanding of Kubernetes topics and wish to have very granular controls using CRDs. For simplified installation you can alternatively use the available installation tool, see here.
For Kong and Apache APISIX with open-appsec follow the instructions for installation using Helm below.
A new installation flow using Helm is now available in beta, which will in the future replace the flow described on this page, you find the documentation and installation steps here: Install Using Helm - new flow (beta)
This new flow will also provide option to use new, improved version of CRDs which provides more options in declaratively, locally managed deployments.
For integration with Kong there's also a new Lua-based attachment plugin available now (in beta), you find the deployment instructions here: Install With Helm using Webhook
Prerequisites
Kubernetes 1.16.0+ cluster with RBAC enabled with Cluster admin permissions
Helm 3 Package Manager installed on your local machine
The
kubectlandwgetcommand-line tools installed on your bastion or platform that you use to access the Kubernetes clusterYou have understanding of Kubernetes Ingress and either have a deployed Ingress or know how to configure one.
Installation
Step 1: Download the Helm chart
Run the following command to obtain the latest helm chart:
wget https://downloads.openappsec.io/packages/helm-charts/nginx-ingress/open-appsec-k8s-nginx-ingress-latest.tgzRun the following command to obtain the latest helm chart:
wget https://downloads.openappsec.io/packages/helm-charts/kong/open-appsec-k8s-kong-latest.tgzRun the following command to obtain the latest helm chart:
wget https://downloads.openappsec.io/packages/helm-charts/apisix/open-appsec-k8s-apisix-latest.tgzStep 2: Install open-appsec Helm Chart and CRDs (Custom Resource Definitions)
Run the following command to install open-appsec together with Ingress NGINX Ingress Controller, Kong API Gateway, or Apache APISIX API Gateway and create the open-appsec CRDs which add new K8s resource-types that will be used later for defining the protection policies, log settings, exceptions, user response and more.
helm install open-appsec-k8s-nginx-ingress-latest.tgz \
--name-template=open-appsec \
--set appsec.mode=standalone \
--set controller.ingressClass=appsec-nginx \
--set controller.ingressClassResource.name=appsec-nginx \
--set controller.ingressClassResource.controllerValue="k8s.io/appsec-nginx" \
--set appsec.persistence.enabled=false \
--set controller.service.externalTrafficPolicy=Local \
--set appsec.userEmail="<your-email-address>" \
--set appsec.agentToken= \
-n appsec --create-namespaceThis installs Ingress NGINX Ingress Controller with open-appsec into a new namespace "appsec" in local management mode (stand-alone).
helm install open-appsec-k8s-kong-latest.tgz \
--name-template=open-appsec \
--set appsec.mode=standalone \
--set ingressController.ingressClass=appsec-kong \
--set appsec.persistence.enabled=false \
--set appsec.userEmail="<your-email-address>" \
--set appsec.agentToken= \
-n appsec --create-namespaceThis installs Kong with open-appsec into a new namespace "appsec" in local management mode (stand-alone).
helm install open-appsec-k8s-apisix-latest.tgz \
--name-template=appsec-apisix \
--set appsec.mode=standalone \
--set rbac.create=true \
--set service.type=LoadBalancer \
--set appsec.persistence.enabled=false \
--set ingress-controller.enabled=true \
--set ingress-controller.config.kubernetes.ingressClass=appsec-apisix \
--set appsec.userEmail="<your-email-address>" \
--set appsec.agentToken= \
--create-namespace \
-n appsec-apisixThis installs APISIX with open-appsec into a new namespace "appsec-apisix" in local management mode (stand-alone).
Optional open-appsec helm install parameters
helm install parameters-n <namespace>: select a namespace name that will include the open-appsec and NGINX ingress controller resources, please use theappsecnamespace.--create-namespace: create namespace if it doesn't exist--name-template: name of your deployment, used for pod naming (optional)--set appsec.userEmail: allows you to associate your email address with your specific deployment by replacing<your-email-address>with your own email address.This allows us to provide you easy assistance in case of any issues you might have with your specific deployment in the future and also to provide you information proactively regarding open-appsec in general or regarding your specific deployment. This is an optional parameter and can be removed. If we send automatic emails there will also be an opt-out option included for receiving similar communication in the future.
--set appsec.persistence.enabled: persistent volume includes machine learning information, if this is set to false then machine learning information is lost when the appsec container is stopped/restarted.true: default is truefalse
If this value is set to true (default, when not overriding with
false) you must also specifyappsec.persistence.learning.storageClass--set appsec.persistence.learning.storageClass: Specify storage class to be used for the learning pod. Note: storageClass name specified here must support ReadWriteMany (like AWS EFS or Azure Files).--set appsec.mode: Configure if the deployment is connected to the central management WebUI (SaaS)standalone: use this only for standalone deployment (locally managed via CRDs with no connection to central management WebUI (SaaS))managed: use this for connection to central management WebUI (SaaS), when this is setappsec.agentTokenmust be provided as well.
--set appsec.agentToken: set the deployment profile token from central management WebUI (SaaS) to connect your open-appsec deployment to the central WebUI (SaaS), also make sure to setappsec.modetomanagedwhen you provide the token, see here how to get the token: create a profile in web UI.--set controller.ingressClassResource.name: specify unique ingress class name, default is 'appsec-nginx'--set controller.ingressClassResource.controllerValue: default is 'k8s.io/appsec-nginx'--set controller.service.externalTrafficPolicy=Localrequired for Azure.
For additional available configuration values please check the values.yaml within the downloaded Helm chart and the Ingress NGINX documentation available here.
-n <namespace>: select a namespace name that will include the open-appsec and Kong gateway resources, please use theappsecnamespace.--create-namespace: create namespace if it doesn't exist--name-template: name of your deployment, used for pod naming (optional)--set appsec.userEmail: allows you to associate your email address with your specific deployment by replacing<your-email-address>with your own email address.This allows us to provide you easy assistance in case of any issues you might have with your specific deployment in the future and also to provide you information proactively regarding open-appsec in general or regarding your specific deployment. This is an optional parameter and can be removed. If we send automatic emails there will also be an opt-out option included for receiving similar communication in the future.
--set appsec.persistence.enabled: persistent volume includes machine learning information, if this is set to false then machine learning information is lost when the appsec container is stopped/restarted.true: default is truefalse
If this value is set to true (default, when not overriding with
false) you must also specifyappsec.persistence.learning.storageClass--set appsec.persistence.learning.storageClass: Specify storage class to be used for the learning pod. Note: storageClass name specified here must support ReadWriteMany (like AWS EFS or Azure Files).--set appsec.mode: Configure if the deployment is connected to the central management WebUI (SaaS)standalone: use this only for standalone deployment (locally managed via CRDs with no connection to central management WebUI (SaaS))managed: use this for connection to central management WebUI (SaaS), when this is setappsec.agentTokenmust be provided as well.
--set appsec.agentToken: set the deployment profile token from central management WebUI (SaaS) to connect your open-appsec deployment to the central WebUI (SaaS), also make sure to setappsec.modetomanagedwhen you provide the token, see here how to get the token: create a profile in web UI.--set kind: select deployment typeAppSec: Installs open-appsec and Kong as K8s Deployment (default, recommended for most scenarios) Note: If required, in this mode you can also switch to Daemonset using by additionally settingdeployment.daemonsettotrue)AppSecStateful: Installs open-appsec and Kong as a K8s StatefulSetVanilla: (for debugging purposes only) installs just regular Kong based on the Helm chart without open-appsec. Note: This can be useful when debugging if a potential issue with the Kong deployment is caused by open-appsec or not.NOTE: If
Vanillamode is used, then the Kong/Kong Gateway image specified underimage.repository/image.tagis being used, instead of the open-appsec specific Kong/Kong Gateway image specified here:appsec.kong.image.repository/appsec.kong.image.tag
--set ingressController.ingressClass: specify desired ingress class name
For additional available configuration values please check the values.yaml within the downloaded Helm chart and the Kong documentation available here.
-n <namespace>: select a namespace name that will include the open-appsec and Kong gateway resources, please use theappsecnamespace.--create-namespace: create namespace if it doesn't exist--name-template: name of your deployment, used for pod naming (optional)--set appsec.userEmail: allows you to associate your email address with your specific deployment by replacing<your-email-address>with your own email address.This allows us to provide you easy assistance in case of any issues you might have with your specific deployment in the future and also to provide you information proactively regarding open-appsec in general or regarding your specific deployment. This is an optional parameter and can be removed. If we send automatic emails there will also be an opt-out option included for receiving similar communication in the future.
--set appsec.persistence.enabled: persistent volume includes machine learning information, if this is set to false then machine learning information is lost when the appsec container is stopped/restarted.true: default is truefalse
If this value is set to true (default, when not overriding with
false) you must also specifyappsec.persistence.learning.storageClass--set appsec.persistence.learning.storageClass: Specify storage class to be used for the learning pod. Note: storageClass name specified here must support ReadWriteMany (like AWS EFS or Azure Files)--set appsec.mode: Configure if the deployment is connected to the central management WebUI (SaaS)standalone: use this only for standalone deployment (locally managed via CRDs with no connection to central management WebUI (SaaS))managed: use this for connection to central management WebUI (SaaS), when this is setappsec.agentTokenmust be provided as well.
--set appsec.agentToken: set the deployment profile token from central management WebUI (SaaS) to connect your open-appsec deployment to the central WebUI (SaaS), also make sure to setappsec.modetomanagedwhen you provide the token, see here how to get the token: create a profile in web UI.--set ingressController.ingressClass: specify desired ingress class name
For additional available configuration values please check the values.yaml within the downloaded Helm chart and the APISIX documentation available here.
Step 3: Validate that open-appsec is installed and running
kubectl get pods -n appsecThe READY column should show 2/2 for the ingress controller pod and 1/1 for the learning deployment and shared storage deployment pods.
kubectl get pods -n appsecThe READY column typically shows 3/3 (or 2/2 if e.g. Kong is deployed without the Kong ingress controller) for the kong pod and 1/1 for the learning deployment and shared storage deployment pods.
kubectl get pods -n appsec-apisixThe READY column should show 2/2 for the ingress controller pod and 1/1 for the learning deployment and shared storage deployment pods.
Step 4: Setup options
Here's the available options:
NGINX Ingress Controller Option 1: Add protection to existing running Ingress
open-appsec implements K8s ingress resources serving as an NGINX ingress controller with multi-layered Web App & API protection functionalities.
If you use today an NGINX Ingress, you can easily update your existing K8S ingress resource to use open-appsec ingress. Once you apply the change, the ingress will reload and traffic will be protected.
This is a good approach for a lab, staging or non critical production environments.
a. Create an open-appsec policy resource
First you must create a K8s open-appsec policy resource. There's multiple alternative ways to create a policy:
Use the available configuration tool as explained here to easily create a policy resource.
Run the following commands to create the "open-appsec-best-practice-policy" resource in K8s:
kubectl apply -f https://downloads.openappsec.io/resources/open-appsec-policy.yaml -n appsec-nginxCreate your own custom policy, here you find all details.
b. Find out the name of your relevant ingress resource:
kubectl get ing -Ac. Edit the ingress resource:
kubectl edit ing/<ingress name> -n <ingress namespace>d. Change the ingressClassname to use open-appsec:
spec: ingressClassName: appsec-nginxe. Add this annotations to activate open-appsec:
openappsec.io/policy: open-appsec-best-practice-policyMake sure to use the correct name for the open-appsec policy resource which you created above.
NGINX Ingress Controller Option 2: Run a new protected Ingress in parallel
open-appsec implements K8s ingress resources serving as an NGINX ingress controller with multi-layered Web App & API protection functionalities.
Duplicate your existing ingress rules and run a new ingress, side by side with your existing one. Once you are happy with the result, you can change your DNS setting to point to the new, protected, ingress and take down the existing ("old") ingress.
This option allows you to test that all services are properly accessible via the new ingress, without worrying about traffic disruption.
a. Create an open-appsec policy resource
First you must create a K8s open-appsec policy resource. There's multiple alternative ways to create a policy:
Use the available configuration tool as explained here to easily create a policy resource.
Run the following commands to create the "open-appsec-best-practice-policy" in K8s:
kubectl apply -f https://downloads.openappsec.io/resources/open-appsec-policy.yaml -n appsec-nginxCreate your own custom policy, here you find all details.
b. Find out the name of your ingress resource by running:
kubectl get ing -Ac. Duplicate your current ingress configuration:
kubectl get ingress <ingress name> -n <namespace> -o json | jq 'del(.metadata.resourceVersion,.metadata.uid,.metadata.selfLink,.metadata.creationTimestamp,.status,.metadata.generation,.metadata.ownerReferences)' | yq eval - -P > protected-ingress.yamld. Edit the ingress YAML:
vi protected-ingress.yamle. Set a resource name for your new protected ingress, for example:
name: appsec-<existing ingress name>f. Change the ingressClassname to use open-appsec:
ingressClassName: appsec-nginxg. Add this annotations to activate open-appsec in detect or prevent mode:
openappsec.io/policy: open-appsec-best-practice-policyh. Apply the new ingress:
kubectl apply -f protected-ingress.yamlKong Gateway: Add protection to existing Ingress resource
open-appsec will secure traffic integrating directly with the Kong Gateway container, as this allows open-appsec to also inspect HTTPS traffic terminated at the Kong Gateway.
In order for traffic to reach your API Gateway you can use the Kong Controller as an Ingress Controller alongside Kong API Gateway (Kong Controller will be deployed by default within the same pod as Kong Gateway as an additional container, but is an optional component). Alternatively you can use another ingress controller of your choice.
If you use today an Ingress for proxying traffic to your Kong Gateway, you can easily update your existing K8S ingress resource to secure it's traffic with open-appsec. Once you apply the change, the ingress will reload and traffic will be protected.
Note: Having an Ingress Resource defined for traffic to Kong Gateway is mandatory for being able to protect the traffic with open-appsec, as the open-appsec policy resource has to be linked to an ingress resource via an annotation, see below steps. Additional options will be provided in the future.
a. Create an open-appsec policy resource
First you must create a K8s open-appsec policy resource. There's multiple alternative ways to create a policy:
Use the available configuration tool as explained here to easily create a policy resource.
Run the following commands to create the "open-appsec-best-practice-policy" in K8s:
kubectl apply -f https://downloads.openappsec.io/resources/open-appsec-policy.yaml -n appsec-nginxCreate your own custom policy, here you find all details.
b. Find out the name of your relevant ingress resource:
kubectl get ing -Ac. Edit the ingress resource:
kubectl edit ing/<ingress name> -n <ingress namespace>d. Change the ingressClassname to use open-appsec:
spec: ingressClassName: appsec-konge. Add this annotation to activate open-appsec:
openappsec.io/policy: open-appsec-best-practice-policyAPISIX Gateway: Add protection to existing Ingress resource
open-appsec will secure traffic integrating directly with the APISIX Gateway container, as this allows open-appsec to also inspect HTTPS traffic terminated at the APISIX Gateway.
In order for traffic to reach your API Gateway you can use the APISIX Ingress Controller as an Ingress Controller alongside APISIX API Gateway.
If you use today an Ingress for proxying traffic to your APISIX Gateway, you can easily update your existing K8S ingress resource to secure it's traffic with open-appsec. Once you apply the change, the ingress will reload and traffic will be protected.
a. Create an open-appsec policy resource
First you must create a K8s open-appsec policy resource. There's multiple alternative ways to create a policy:
Use the available configuration tool as explained here to easily create a policy resource.
Run the following commands to create the "open-appsec-best-practice-policy" resource in K8s:
kubectl apply -f https://downloads.openappsec.io/resources/open-appsec-policy.yaml -n appsec-apisixb. Find out the name of your relevant ingress resource:
kubectl get ing -Ac. Edit the ingress resource:
kubectl edit ing/<ingress name> -n <ingress namespace>d. Change the ingressClassname to use open-appsec:
spec: ingressClassName: appsec-apisixe. Add this annotations to activate open-appsec:
openappsec.io/policy: open-appsec-best-practice-policyMake sure to use the correct name for the open-appsec policy resource which you created above.
Step 5: Validate that open-appsec works
Your existing or new Ingress is now running and you can try it out!
Generate some traffic to one of the services defined in your ingress.
Run this command to see logs:
Note the name of the ingress nginx pod by running:
kubectl get pods -n appsecShow the logs of the open-appsec agent container by running:
kubectl logs [ingress nginx pod name] -c open-appsec -n appsecNote the name of the Kong pod by running:
kubectl get pods -n appsecShow the logs of the open-appsec agent container by running:
kubectl logs [kong pod name] -c open-appsec -n appsecNote the name of the apisix gateway pod by running:
kubectl get pods -n appsec-apisixShow the logs of the open-appsec agent container by running:
kubectl logs [apisix gateway pod name] -c open-appsec -n appsec-apisixStep 6: Point your DNS to the New Ingress
After testing that your services are reachable, you can point your public DNS record to the new ingress.
In case of a problem, at any time, you can either switch open-appsec off while running the same ingress code, or change your DNS back.
Learn how to define your policies, set exception and other advanced configuration:
Configuration Using CRDsLast updated
Was this helpful?