Примеры использования политик безопасности
- Пример сетевой политики безопасности для веб-приложения, разрешающей входящие HTTP и HTTPS запросы, а также исходящий в postgresSQL:
apiVersion: neuvector.com/v1
kind: NvSecurityRule
metadata:
name: web-app-security
namespace: production
spec:
target:
policymode: Protect
selector:
name: nv.web-app.production
criteria:
- key: service
value: web-app.production
op: "="
- key: domain
value: production
op: "="
ingress:
- action: allow
name: allow-http
selector:
name: ingress-controller
criteria:
- key: service
value: nginx-ingress
op: "="
ports: tcp/80,tcp/443
applications:
- HTTP
- SSL
egress:
- action: allow
name: allow-database
selector:
name: nv.database.production
criteria:
- key: service
value: database.production
op: "="
ports: tcp/5432
applications:
- PostgreSQL
- Пример глобальной политики, запрещающей SSH-доступ ко всем контейнерам в кластере.
apiVersion: neuvector.com/v1
kind: NvClusterSecurityRule
metadata:
name: global-ssh-restriction
namespace: neuvector
spec:
target:
selector:
name: containers
criteria:
- key: container
value: "*"
op: "="
ingress:
- action: deny
name: deny-external-ssh
selector:
name: external
criteria: []
ports: tcp/22
applications:
- SSH
process:
- action: deny
name: ssh
path: /bin/ssh
- Пример политики, блокирующей развёртывание в системные пространства имён:
apiVersion: neuvector.com/v1
kind: NvAdmissionControlSecurityRule
metadata:
name: local
namespace: neuvector
spec:
config:
enable: true
mode: protect
client_mode: service
rules:
- action: deny
criteria:
- name: namespace
op: containsAny
path: namespace
value: "kube-system,kube-public"
comment: "Блокировка развертываний в системные пространства имен"
- Пример переиспользуемой группы, на данную группу можно будет ссылаться в политиках через target:
apiVersion: neuvector.com/v1
kind: NvGroupDefinition
metadata:
name: production-web-services
namespace: neuvector
spec:
selector:
name: nv.web-services.production
comment: "Группа веб-сервисов production"
criteria:
- key: service
value: web-services.production
op: "="
- key: domain
value: production
op: "="