{"id":32641,"date":"2019-10-31T21:48:11","date_gmt":"2019-10-31T18:48:11","guid":{"rendered":"https:\/\/prohoster.info\/blog\/vvedenie-v-setevye-politiki-kubernetes-dlya-spetsialistov-po-bezopasnosti\/"},"modified":"2019-10-31T21:48:11","modified_gmt":"2019-10-31T18:48:11","slug":"vvedenie-v-setevye-politiki-kubernetes-dlya-spetsialistov-po-bezopasnosti","status":"publish","type":"post","link":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/vvedenie-v-setevye-politiki-kubernetes-dlya-spetsialistov-po-bezopasnosti","title":{"rendered":"Introduction to Kubernetes Network Policies for Security Professionals","gt_translate_keys":[{"key":"rendered","format":"text"}]},"content":{"rendered":"<p><img decoding=\"async\" alt=\"Introduction to Kubernetes Network Policies for Security Professionals\" src=\"\/wp-content\/uploads\/2019\/04\/6972a1e1385463b1fcc723c09036a565.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\n<i><b>Note: translation.<\/b>: The author of the article, Reuven Harrison, has over 20 years of experience in software development and is currently the CTO and co-founder of Tufin, a company that creates security policy management solutions. While considering Kubernetes network policies as a powerful means for network segmentation within a cluster, he believes they are not as straightforward to implement in practice. This rather extensive material aims to enhance professionals' awareness of this issue and assist them in creating the necessary configurations.<\/i><noindex><a rel=\"nofollow\" name=\"habracut\"><\/a><\/noindex><\/p>\n<p>Today, many companies are increasingly choosing Kubernetes to run their applications. The interest in this software is so high that some even call Kubernetes 'the new operating system for data centers.' Gradually, Kubernetes (or k8s) is beginning to be seen as a critical part of the business that demands the organization of mature business processes, including network security.<\/p>\n<p>For security professionals grappling with working with Kubernetes, a real revelation may be the platform's default policy: allow everything.<\/p>\n<p>This guide will help to understand the internal workings of network policies, and how they differ from rules for traditional firewalls. It will also discuss some pitfalls and provide recommendations that will help secure applications in Kubernetes.<\/p>\n<h2>Kubernetes Network Policies<\/h2>\n<p>\nThe Kubernetes network policy mechanism allows the management of interactions between applications deployed on the platform at the network level (the third layer in the OSI model). Network policies lack some advanced features of modern firewalls, such as Layer 7 OSI control and threat detection; however, they provide a basic level of network security which serves as a decent starting point.<\/p>\n<h2>Network policies control communications between pods.<\/h2>\n<p>\nWorkloads in Kubernetes are distributed across pods, which consist of one or more containers deployed together. Kubernetes assigns an IP address to each pod that is accessible from other pods. Kubernetes network policies set access rights for groups of pods in the same way that security groups in the cloud are used to manage access to virtual machine instances.<\/p>\n<h2>Defining Network Policies<\/h2>\n<p>\nLike other Kubernetes resources, network policies are defined in YAML. In the example below, the application <code>balance<\/code> is granted access to <code>postgres<\/code>:<\/p>\n<pre><code class=\"plaintext\">apiVersion: networking.k8s.io\/v1\nkind: NetworkPolicy\nmetadata:\n  name: default.postgres\n  namespace: default\nspec:\n  podSelector:\n    matchLabels:\n      app: postgres\n  ingress:\n  - from:\n    - podSelector:\n        matchLabels:\n          app: balance\n  policyTypes:\n  - Ingress<\/code><\/pre>\n<p>\n<img decoding=\"async\" alt=\"Introduction to Kubernetes Network Policies for Security Professionals\" src=\"\/wp-content\/uploads\/2019\/04\/ff5857af2641e62558b035bab9c413dc.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\n<i>(<b>Note: translation.<\/b>: this screenshot, like all subsequent similar ones, was created not using native Kubernetes tools but with the Tufin Orca tool, developed by the company of the original article's author and mentioned at the end of the material.)<\/i><\/p>\n<p>To define your own network policy, basic knowledge of YAML is required. This language is based on indentation (using spaces, not tabs). An indented element belongs to the nearest indented element above it. A new list element begins with a dash, while all other elements appear as <i>key-value<\/i>.<\/p>\n<p>After describing the policy in YAML, use <noindex><a rel=\"nofollow\" href=\"https:\/\/kubernetes.io\/docs\/reference\/kubectl\/kubectl\/\">kubectl<\/a><\/noindex>, to create it in the cluster:<\/p>\n<pre><code class=\"bash\">kubectl create -f policy.yaml<\/code><\/pre>\n<p><\/p>\n<h2>Network Policy Specification<\/h2>\n<p>\nThe Kubernetes network policy specification includes four elements:<\/p>\n<ol>\n<li> <code>podSelector<\/code>specifies the pods affected by this policy (targets) \u2014 mandatory;<\/li>\n<li> <code>policyTypes<\/code>: specifies which types of policies are included: ingress and\/or egress - optional, but I recommend explicitly stating it in all cases;<\/li>\n<li> <code>ingress<\/code>: defines the allowed <b>incoming<\/b> traffic to target pods \u2014 optional;<\/li>\n<li> <code>egress<\/code>: defines the allowed <b>outgoing<\/b> traffic from target pods \u2014 optional.<\/li>\n<\/ol>\n<p>\nAn example borrowed from the Kubernetes website (I replaced <code>role<\/code> to <code>app<\/code>), shows how all four elements are used:<\/p>\n<pre><code class=\"plaintext\">apiVersion: networking.k8s.io\/v1\nkind: NetworkPolicy\nmetadata:\n  name: test-network-policy\n  namespace: default\nspec:\n  podSelector:    # &lt;&lt;&lt;\n    matchLabels:\n      app: db\n  policyTypes:    # &lt;&lt;&lt;\n  - Ingress\n  - Egress\n  ingress:        # &lt;&lt;&lt;\n  - from:\n    - ipBlock:\n        cidr: 172.17.0.0\/16\n        except:\n        - 172.17.1.0\/24\n    - namespaceSelector:\n        matchLabels:\n          project: myproject\n    - podSelector:\n        matchLabels:\n          role: frontend\n    ports:\n    - protocol: TCP\n      port: 6379\n  egress:         # &lt;&lt;&lt;\n  - to:\n    - ipBlock:\n        cidr: 10.0.0.0\/24\n    ports:\n    - protocol: TCP\n      port: 5978<\/code><\/pre>\n<p>\n<img decoding=\"async\" alt=\"Introduction to Kubernetes Network Policies for Security Professionals\" src=\"\/wp-content\/uploads\/2019\/04\/f01e748410564756d6272095093e52e2.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<img decoding=\"async\" alt=\"Introduction to Kubernetes Network Policies for Security Professionals\" src=\"\/wp-content\/uploads\/2019\/04\/997282073ee6b5c4d6b7af45cdc11295.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\nPlease note that not all four elements are required to be included. Only <code>podSelector<\/code>the other parameters can be optional.<\/p>\n<p>If omitted <code>policyTypes<\/code>, the policy will be interpreted as follows:<\/p>\n<ul>\n<li> By default, it is assumed to define the ingress side. If there are no explicit instructions in the policy, the system will assume that all traffic is denied.<\/li>\n<li> The behavior on the egress side will be determined by the presence or absence of the corresponding egress parameter.<\/li>\n<\/ul>\n<p>\nTo avoid errors, I recommend <b>always explicitly indicating <code>policyTypes<\/code><\/b>.<\/p>\n<p>According to the logic outlined above, if the parameters are <code>ingress<\/code> and\/or <code>egress<\/code> omitted, the policy will deny all traffic (see the 'Cleanup Rule' below).<\/p>\n<h2>The default policy is to allow<\/h2>\n<p>\nIf policies are not defined, Kubernetes by default allows all traffic. All pods can freely communicate with one another. While this may seem illogical from a security standpoint, remember that Kubernetes was originally created by developers with the goal of ensuring application interaction. Network policies were added later.<\/p>\n<h2>Namespaces<\/h2>\n<p>\nNamespaces are a mechanism for collaboration within Kubernetes. They are designed to isolate logical environments from each other, with data exchange between namespaces being allowed by default.<\/p>\n<p>Like most Kubernetes components, network policies exist within a specific namespace. In the block <code>metadata<\/code> you can specify which namespace the policy belongs to:<\/p>\n<pre><code class=\"plaintext\">apiVersion: networking.k8s.io\/v1\nkind: NetworkPolicy\nmetadata:\n  name: test-network-policy\n  namespace: my-namespace  # &lt;&lt;&lt;\nspec:\n...<\/code><\/pre>\n<p>\nIf the namespace in the metadata is not explicitly stated, the system will use the namespace specified in kubectl (default <code>namespace=default<\/code>):<\/p>\n<pre><code class=\"bash\">kubectl apply -n my-namespace -f namespace.yaml<\/code><\/pre>\n<p>\nI recommend <b>to explicitly indicate the namespace<\/b>, unless you are writing a policy intended for multiple namespaces at once.<\/p>\n<p><b>Main<\/b> element <code>podSelector<\/code> the policy will select pods from the namespace to which the policy belongs (it has no access to pods from another namespace).<\/p>\n<p>Similarly, podSelectors <b>in ingress and egress blocks<\/b> can only select pods from their own namespace, unless you combine them using <code>namespaceSelector<\/code> (which will be discussed in the section 'Filter by namespaces and pods').<\/p>\n<h2>Naming rules for policies<\/h2>\n<p>\nPolicy names are unique within a single namespace. Two policies with the same name cannot exist in the same namespace, but policies with the same names can exist in different namespaces. This is convenient when you want to reuse the same policy across multiple namespaces.<\/p>\n<p>I especially like one way of naming. It consists of combining the namespace name with the target pods. For example:<\/p>\n<pre><code class=\"plaintext\">apiVersion: networking.k8s.io\/v1\nkind: NetworkPolicy\nmetadata:\n  name: default.postgres  # &lt;&lt;&lt;&lt;\n  namespace: default\nspec:\n  podSelector:\n    matchLabels:\n      app: postgres\n  ingress:\n  - from:\n    - podSelector:\n        matchLabels:\n          app: admin\n  policyTypes:\n  - Ingress<\/code><\/pre>\n<p>\n<img decoding=\"async\" alt=\"Introduction to Kubernetes Network Policies for Security Professionals\" src=\"\/wp-content\/uploads\/2019\/04\/18318c320d6e37eeb01c51f251550639.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<\/p>\n<h2>Labels<\/h2>\n<p>\nCustom labels can be attached to Kubernetes objects such as pods and namespaces. Labels (<i>labels<\/i> \u2014 tags) are equivalent to tags in the cloud. Kubernetes network policies use labels to select <b>pods<\/b>, to which they apply:<\/p>\n<pre><code class=\"plaintext\">podSelector:\n  matchLabels:\n    role: db<\/code><\/pre>\n<p>\n\u2026 or <b>namespaces<\/b>, to which they apply. In this example, all pods in namespaces with matching labels are selected:<\/p>\n<pre><code class=\"plaintext\">namespaceSelector:\n  matchLabels:\n    project: myproject<\/code><\/pre>\n<p>\nOne caveat: when using <code>namespaceSelector<\/code> <b>make sure that the selected namespaces contain the necessary label<\/b>. Note that built-in namespaces, such as <code>default<\/code> and <code>kube-system<\/code>, do not contain labels by default.<\/p>\n<p>You can add a label to a namespace as follows:<\/p>\n<pre><code class=\"bash\">kubectl label namespace default namespace=default<\/code><\/pre>\n<p>\nNote that the namespace in the section <code>metadata<\/code> should refer to the actual name of the namespace, not to the label:<\/p>\n<pre><code class=\"plaintext\">apiVersion: networking.k8s.io\/v1\nkind: NetworkPolicy\nmetadata:\n  name: test-network-policy\n  namespace: default   # &lt;&lt;&lt;&lt;\nspec:\n...<\/code><\/pre>\n<p><\/p>\n<h2>Source and destination<\/h2>\n<p>\nFirewall policies consist of rules with sources and destinations. Kubernetes network policies are defined for a target set of pods to which they apply, and then set rules for inbound (ingress) and\/or outbound (egress) traffic. In our example, the target of the policy will be all pods in the namespace <code>default<\/code> with a label with the key <code>app<\/code> and value <code>Service meshes typically solve such problems using mTLS: certificates in this case serve as necessary identifiers.<\/code>:<\/p>\n<pre><code class=\"plaintext\">apiVersion: networking.k8s.io\/v1\nkind: NetworkPolicy\nmetadata:\n  name: test-network-policy\n  namespace: default\nspec:\n  podSelector:\n    matchLabels:\n      app: db   # &lt;&lt;&lt;\n  policyTypes:\n  - Ingress\n  - Egress\n  ingress:\n  - from:\n    - ipBlock:\n        cidr: 172.17.0.0\/16\n        except:\n        - 172.17.1.0\/24\n    - namespaceSelector:\n        matchLabels:\n          project: myproject\n    - podSelector:\n        matchLabels:\n          role: frontend\n    ports:\n    - protocol: TCP\n      port: 6379\n  egress:\n  - to:\n    - ipBlock:\n        cidr: 10.0.0.0\/24\n    ports:\n    - protocol: TCP\n      port: 5978<\/code><\/pre>\n<p>\n<img decoding=\"async\" alt=\"Introduction to Kubernetes Network Policies for Security Professionals\" src=\"\/wp-content\/uploads\/2019\/04\/5fcb3f78e26ae1ed5635541ad69ef69f.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<img decoding=\"async\" alt=\"Introduction to Kubernetes Network Policies for Security Professionals\" src=\"\/wp-content\/uploads\/2019\/04\/c753f559ecc3ba54f8b55e29851428c4.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\nSubsection <code>ingress<\/code> in this policy opens incoming traffic to the target pods. In other words, ingress acts as the source, and the target is the corresponding recipient. Similarly, egress is the recipient, while the target is its source.<\/p>\n<p><img decoding=\"async\" alt=\"Introduction to Kubernetes Network Policies for Security Professionals\" src=\"\/wp-content\/uploads\/2019\/04\/a0d865de57a7620849074424770832cd.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\n<i>This is equivalent to two rules for the firewall: Ingress \u2192 Target; Target \u2192 Egress.<\/i><\/p>\n<h2>Egress and DNS (important!)<\/h2>\n<p>\nBy limiting outgoing traffic, <b>pay special attention to DNS<\/b> \u2014 Kubernetes uses this service to map services to IP addresses. For example, the following policy will not work because you did not allow the application <code>balance<\/code> to access DNS:<\/p>\n<pre><code class=\"plaintext\">apiVersion: networking.k8s.io\/v1\nkind: NetworkPolicy\nmetadata:\n  name: default.balance\n  namespace: default\nspec:\n  podSelector:\n    matchLabels:\n      app: balance\n  egress:\n  - to:\n    - podSelector:\n        matchLabels:\n          app: postgres\n  policyTypes:\n  - Egress<\/code><\/pre>\n<p>\n<img decoding=\"async\" alt=\"Introduction to Kubernetes Network Policies for Security Professionals\" src=\"\/wp-content\/uploads\/2019\/04\/5857a44cc5e06de708f0d3b5b0f49628.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\nYou can fix it by allowing access to the DNS service:<\/p>\n<pre><code class=\"plaintext\">apiVersion: networking.k8s.io\/v1\nkind: NetworkPolicy\nmetadata:\n  name: default.balance\n  namespace: default\nspec:\n  podSelector:\n    matchLabels:\n      app: balance\n  egress:\n  - to:\n    - podSelector:\n        matchLabels:\n          app: postgres\n  - to:               # &lt;&lt;&lt;\n    ports:            # &lt;&lt;&lt;\n    - protocol: UDP   # &lt;&lt;&lt;\n      port: 53        # &lt;&lt;&lt;\n  policyTypes:\n  - Egress<\/code><\/pre>\n<p>\n<img decoding=\"async\" alt=\"Introduction to Kubernetes Network Policies for Security Professionals\" src=\"\/wp-content\/uploads\/2019\/04\/a396bb2ae94fca94c3b62aef2cb07552.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\nThe last element <code>to<\/code> \u2014 is empty, and therefore it indirectly selects <b>all pods in all namespaces<\/b>, allowing <code>balance<\/code> to send DNS queries to the corresponding Kubernetes service (which usually operates in the namespace <code>kube-system<\/code>).<\/p>\n<p>This approach works; however, it is <b>overly permissive and insecure<\/b>, as it allows sending DNS queries outside the cluster.<\/p>\n<p>You can improve it in three consecutive steps.<\/p>\n<p>1. Allow DNS queries only <b>inside<\/b> to the cluster by adding <code>namespaceSelector<\/code>:<\/p>\n<pre><code class=\"plaintext\">apiVersion: networking.k8s.io\/v1\nkind: NetworkPolicy\nmetadata:\n  name: default.balance\n  namespace: default\nspec:\n  podSelector:\n    matchLabels:\n      app: balance\n  egress:\n  - to:\n    - podSelector:\n        matchLabels:\n          app: postgres\n  - to:\n    - namespaceSelector: {} # &lt;&lt;\n    ports:\n    - protocol: UDP\n      port: 53\n  policyTypes:\n  - Egress<\/code><\/pre>\n<p>\n<img decoding=\"async\" alt=\"Introduction to Kubernetes Network Policies for Security Professionals\" src=\"\/wp-content\/uploads\/2019\/04\/5920a043229676e0780d691d302c5ade.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\n2. Allow DNS queries only within the namespace <code>kube-system<\/code>.<\/p>\n<p>You need to add a label to the namespace for this <code>kube-system<\/code>: <code>kubectl label namespace kube-system namespace=kube-system<\/code> \u2014 and include it in the policy using <code>namespaceSelector<\/code>:<\/p>\n<pre><code class=\"plaintext\">apiVersion: networking.k8s.io\/v1\nkind: NetworkPolicy\nmetadata:\n  name: default.balance\n  namespace: default\nspec:\n  podSelector:\n    matchLabels:\n      app: balance\n  egress:\n  - to:\n    - podSelector:\n        matchLabels:\n          app: postgres\n  - to:\n    - namespaceSelector:         # &lt;&lt;\n        matchLabels:             # &lt;&lt;\n          namespace: kube-system # &lt;&lt;\n    ports:\n    - protocol: UDP\n      port: 53\n  policyTypes:\n  - Egress<\/code><\/pre>\n<p>\n<img decoding=\"async\" alt=\"Introduction to Kubernetes Network Policies for Security Professionals\" src=\"\/wp-content\/uploads\/2019\/04\/2a1dd0975c58e6d277baffc7c3ac6e48.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\n3. Paranoids may go even further and restrict DNS queries to a specific DNS service within <code>kube-system<\/code>. The section 'Filter by namespaces and pods' will explain how to achieve this.<\/p>\n<p>Another option is to allow DNS at the namespace level. In this case, it won't need to be opened for every service:<\/p>\n<pre><code class=\"plaintext\">apiVersion: networking.k8s.io\/v1\nkind: NetworkPolicy\nmetadata:\n  name: default.dns\n  namespace: default\nspec:\n  podSelector: {} # &lt;&lt;\n  egress:\n  - to:\n    - namespaceSelector: {}\n    ports:\n    - protocol: UDP\n      port: 53\n  policyTypes:\n  - Egress<\/code><\/pre>\n<p>\nEmpty <code>podSelector<\/code> selects all pods in the namespace.<\/p>\n<p><img decoding=\"async\" alt=\"Introduction to Kubernetes Network Policies for Security Professionals\" src=\"\/wp-content\/uploads\/2019\/04\/5d6b627b69da980477b3910fbf4de6c1.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<\/p>\n<h2>First match and order of rules<\/h2>\n<p>\nIn conventional firewalls, the action ('Allow' or 'Deny') regarding a packet is determined by the first rule it satisfies. <b>In Kubernetes, the order of policies does not matter.<\/b><\/p>\n<p>By default, when no policies are set, communications between pods are allowed and they can freely exchange information. Once you start formulating policies, each pod impacted by at least one of them becomes isolated according to the disjunction (logical OR) of all policies that selected it. Pods not affected by any policy remain open.<\/p>\n<p>This behavior can be changed using a deny-all rule.<\/p>\n<h2>Deny-all rule<\/h2>\n<p>\nFirewall policies typically deny any traffic that is not explicitly allowed.<\/p>\n<p><b>In Kubernetes, there is no 'deny' action<\/b>, however, a similar effect can be achieved with a standard (allowing) policy by selecting an empty set of source pods (ingress):<\/p>\n<pre><code class=\"plaintext\">apiVersion: networking.k8s.io\/v1\nkind: NetworkPolicy\nmetadata:\n  name: deny-all\n  namespace: default\nspec:\n  podSelector: {}\n  policyTypes:\n  - Ingress<\/code><\/pre>\n<p>\n<img decoding=\"async\" alt=\"Introduction to Kubernetes Network Policies for Security Professionals\" src=\"\/wp-content\/uploads\/2019\/04\/8b3ced50ec5a1de70940d53f467966fe.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\nThis policy selects all pods in the namespace and leaves ingress undefined, prohibiting all incoming traffic.<\/p>\n<p>Similarly, you can restrict all outgoing traffic from the namespace:<\/p>\n<pre><code class=\"plaintext\">apiVersion: networking.k8s.io\/v1\nkind: NetworkPolicy\nmetadata:\n  name: deny-all-egress\n  namespace: default\nspec:\n  podSelector: {}\n  policyTypes:\n  - Egress<\/code><\/pre>\n<p>\n<img decoding=\"async\" alt=\"Introduction to Kubernetes Network Policies for Security Professionals\" src=\"\/wp-content\/uploads\/2019\/04\/be22e11efef0098f2665331c09d748f2.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\nNote that <b>any additional policies that allow traffic to pods in the namespace will take precedence over this rule<\/b> (similar to adding an allow rule before a deny in a firewall configuration).<\/p>\n<h2>Allow All (Any-Any-Any-Allow)<\/h2>\n<p>\nTo create an 'Allow All' policy, you need to supplement the above deny policy with an empty element <code>ingress<\/code>:<\/p>\n<pre><code class=\"plaintext\">apiVersion: networking.k8s.io\/v1\nkind: NetworkPolicy\nmetadata:\n  name: allow-all\n  namespace: default\nspec:\n  podSelector: {}\n  ingress: # &lt;&lt;&lt;\n  - {}     # &lt;&lt;&lt;\n  policyTypes:\n  - Ingress<\/code><\/pre>\n<p>\n<img decoding=\"async\" alt=\"Introduction to Kubernetes Network Policies for Security Professionals\" src=\"\/wp-content\/uploads\/2019\/04\/7322351493211388fe772b8dc270108d.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\nIt opens access from <b>all pods in all namespaces (and all IPs) to any pod in the namespace <code>default<\/code><\/b>. This behavior is enabled by default, so it usually does not need to be defined explicitly. However, it may sometimes be necessary to temporarily disable specific permissions for troubleshooting.<\/p>\n<p>The rule can be narrowed down to allow access only to <b>a specific set of pods<\/b> (<code>app:balance<\/code>) in the namespace <code>default<\/code>:<\/p>\n<pre><code class=\"plaintext\">apiVersion: networking.k8s.io\/v1\nkind: NetworkPolicy\nmetadata:\n  name: allow-all-to-balance\n  namespace: default\nspec:\n  podSelector:\n    matchLabels:\n      app: balance\n  ingress: \n  - {}\n  policyTypes:\n  - Ingress<\/code><\/pre>\n<p>\n<img decoding=\"async\" alt=\"Introduction to Kubernetes Network Policies for Security Professionals\" src=\"\/wp-content\/uploads\/2019\/04\/d8c9cb85003f489acec815d1c2b53497.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\nThe following policy allows all incoming (ingress) and outgoing (egress) traffic, including access to any IP outside the cluster:<\/p>\n<pre><code class=\"plaintext\">apiVersion: networking.k8s.io\/v1\nkind: NetworkPolicy\nmetadata:\n  name: allow-all\nspec:\n  podSelector: {}\n  ingress:\n  - {}\n  egress:\n  - {}\n  policyTypes:\n  - Ingress\n  - Egress<\/code><\/pre>\n<p>\n<img decoding=\"async\" alt=\"Introduction to Kubernetes Network Policies for Security Professionals\" src=\"\/wp-content\/uploads\/2019\/04\/2477f18d3d228f80bc5169d9ec3be2fc.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<img decoding=\"async\" alt=\"Introduction to Kubernetes Network Policies for Security Professionals\" src=\"\/wp-content\/uploads\/2019\/04\/3502b892713cdac8850e812b2eff3ea3.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<\/p>\n<h2>Combining multiple policies<\/h2>\n<p>\nPolicies combine using a logical OR at three levels; permissions for each pod are set based on the disjunction of all policies affecting it:<\/p>\n<p>1. In the fields <code>from<\/code> and <code>to<\/code> you can define three types of elements (all of which are combined using OR):<\/p>\n<ul>\n<li> <code>namespaceSelector<\/code> \u2014 selects the namespace in its entirety;<\/li>\n<li> <code>podSelector<\/code> \u2014 selects pods;<\/li>\n<li> <code>ipBlock<\/code> \u2014 selects a subnet.<\/li>\n<\/ul>\n<p>\nThe number of elements (even identical ones) in the subdivisions <code>from<\/code>\/<code>to<\/code> is not limited. All will be combined logically with OR.<\/p>\n<pre><code class=\"plaintext\">apiVersion: networking.k8s.io\/v1\nkind: NetworkPolicy\nmetadata:\n  name: default.postgres\n  namespace: default\nspec:\n  ingress:\n  - from:\n    - podSelector:\n        matchLabels:\n          app: indexer\n    - podSelector:\n        matchLabels:\n          app: admin\n  podSelector:\n    matchLabels:\n      app: postgres\n  policyTypes:\n  - Ingress<\/code><\/pre>\n<p>\n<img decoding=\"async\" alt=\"Introduction to Kubernetes Network Policies for Security Professionals\" src=\"\/wp-content\/uploads\/2019\/04\/717e745720f39260a8508fb2b2bb6f65.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\n2. Inside a policy section <code>ingress<\/code> can contain multiple elements <code>from<\/code> (united by logical OR). Similarly, the section <code>egress<\/code> can include multiple elements <code>to<\/code> (also united by disjunction):<\/p>\n<pre><code class=\"plaintext\">apiVersion: networking.k8s.io\/v1\nkind: NetworkPolicy\nmetadata:\n  name: default.postgres\n  namespace: default\nspec:\n  ingress:\n  - from:\n    - podSelector:\n        matchLabels:\n          app: indexer\n  - from:\n    - podSelector:\n        matchLabels:\n          app: admin\n  podSelector:\n    matchLabels:\n      app: postgres\n  policyTypes:\n  - Ingress<\/code><\/pre>\n<p>\n<img decoding=\"async\" alt=\"Introduction to Kubernetes Network Policies for Security Professionals\" src=\"\/wp-content\/uploads\/2019\/04\/b579e1f4b97acd92fb38cd6703aa1983.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\n3. Different policies are also combined using logical OR<\/p>\n<p>But there is one restriction when combining them, which <noindex><a rel=\"nofollow\" href=\"https:\/\/medium.com\/sainsburys-engineering\/considerations-with-k8s-networkpolicy-cee7eacf5469\">indicated<\/a><\/noindex> <noindex><a rel=\"nofollow\" href=\"https:\/\/medium.com\/@chriscooney\">Chris Cooney<\/a><\/noindex>: Kubernetes can only combine policies with different <code>policyTypes<\/code> (<code>Ingress<\/code> or <code>Egress<\/code>). Policies defining ingress (or egress) will overwrite each other.<\/p>\n<h2>Connection between namespaces<\/h2>\n<p>\nBy default, communication between namespaces is allowed. This can be altered using a restrictive policy, which will limit outgoing and\/or incoming traffic to a namespace (see \"Cleanup Rule\" above).<\/p>\n<p>By blocking access to a namespace (see \"Cleanup Rule\" above), you can make exceptions in the restrictive policy, allowing connections from a specific namespace with <code>namespaceSelector<\/code>:<\/p>\n<pre><code class=\"plaintext\">apiVersion: networking.k8s.io\/v1\nkind: NetworkPolicy\nmetadata:\n  name: database.postgres\n  namespace: database\nspec:\n  podSelector:\n    matchLabels:\n      app: postgres\n  ingress:\n  - from:\n    - namespaceSelector: # &lt;&lt;&lt;\n        matchLabels:\n          namespace: default\n  policyTypes:\n  - Ingress<\/code><\/pre>\n<p>\n<img decoding=\"async\" alt=\"Introduction to Kubernetes Network Policies for Security Professionals\" src=\"\/wp-content\/uploads\/2019\/04\/5a3d2baed1ff9b813ef0651fe500ad8a.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\nAs a result, all pods in the namespace <code>default<\/code> will gain access to pods <code>postgres<\/code> in the namespace <code>database<\/code>. But what if you want to grant access to <code>postgres<\/code> only specific pods in the namespace <code>default<\/code>?<\/p>\n<h2>Filtering by namespaces and pods<\/h2>\n<p>\nKubernetes version 1.11 and above allows combining operators <code>namespaceSelector<\/code> and <code>podSelector<\/code> using logical AND. It looks like this:<\/p>\n<pre><code class=\"plaintext\">apiVersion: networking.k8s.io\/v1\nkind: NetworkPolicy\nmetadata:\n  name: database.postgres\n  namespace: database\nspec:\n  podSelector:\n    matchLabels:\n      app: postgres\n  ingress:\n  - from:\n    - namespaceSelector:\n        matchLabels:\n          namespace: default\n      podSelector: # &lt;&lt;&lt;\n        matchLabels:\n          app: admin\n  policyTypes:\n  - Ingress<\/code><\/pre>\n<p>\n<img decoding=\"async\" alt=\"Introduction to Kubernetes Network Policies for Security Professionals\" src=\"\/wp-content\/uploads\/2019\/04\/e933e449d9f9c10505e45930d1477b2c.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\nWhy is this interpreted as AND instead of the usual OR?<\/p>\n<p>Note that <code>podSelector<\/code> It does not start with a dash. In YAML, this means that <code>podSelector<\/code> and the preceding one <code>namespaceSelector<\/code> belong to the same list item. Therefore, they are combined using logical AND.<\/p>\n<p>Adding a dash before <code>podSelector<\/code> will create a new list item that will be combined with the previous one <code>namespaceSelector<\/code> using a logical OR.<\/p>\n<p>To select pods with a specific label <b>across all namespaces<\/b>, enter empty <code>namespaceSelector<\/code>:<\/p>\n<pre><code class=\"plaintext\">apiVersion: networking.k8s.io\/v1\nkind: NetworkPolicy\nmetadata:\n  name: database.postgres\n  namespace: database\nspec:\n  podSelector:\n    matchLabels:\n      app: postgres\n  ingress:\n  - from:\n    - namespaceSelector: {}\n      podSelector:\n        matchLabels:\n          app: admin\n  policyTypes:\n  - Ingress<\/code><\/pre>\n<p>\n<img decoding=\"async\" alt=\"Introduction to Kubernetes Network Policies for Security Professionals\" src=\"\/wp-content\/uploads\/2019\/04\/e79e4a8067fa254f85fa8be105c3ad34.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<\/p>\n<h2>Multiple labels are combined with AND<\/h2>\n<p>\nRules for the firewall with multiple objects (hosts, networks, groups) are combined using logical OR. The following rule will trigger if the packet source matches <code>Host_1<\/code> OR <code>Host_2<\/code>:<\/p>\n<pre><code class=\"plaintext\">| Source | Destination | Service | Action |\n| ----------------------------------------|\n| Host_1 | Subnet_A    | HTTPS   | Allow  |\n| Host_2 |             |         |        |\n| ----------------------------------------|<\/code><\/pre>\n<p>\nConversely, in Kubernetes various labels in <code>podSelector<\/code> or <code>namespaceSelector<\/code> are combined with logical AND. For example, the following rule will select pods that have both labels <code>role=db<\/code> I can use <code>version=v2<\/code>:<\/p>\n<pre><code class=\"plaintext\">podSelector:\n  matchLabels:\n    role: db\n    version: v2<\/code><\/pre>\n<p>\nThe same logic applies to all types of selectors: policy target selectors, pod selectors, and namespace selectors.<\/p>\n<h2>Subnets and IP addresses (IPBlocks)<\/h2>\n<p>\nFor network segmentation, firewalls use VLANs, IP addresses, and subnets.<\/p>\n<p>In Kubernetes, IP addresses are assigned to pods automatically and can change often, so labels are used to select pods and namespaces in network policies.<\/p>\n<p>Subnets (<code>ipBlocks<\/code>) are used when managing incoming (ingress) or outgoing (egress) external (North-South) connections. For example, this policy opens up all pods from the namespace <code>default<\/code> access to the Google DNS service:<\/p>\n<pre><code class=\"plaintext\">apiVersion: networking.k8s.io\/v1\nkind: NetworkPolicy\nmetadata:\n  name: egress-dns\n  namespace: default\nspec:\n  podSelector: {}\n  policyTypes:\n  - Egress\n  egress:\n  - to:\n    - ipBlock:\n        cidr: 8.8.8.8\/32\n    ports:\n    - protocol: UDP\n      port: 53<\/code><\/pre>\n<p>\n<img decoding=\"async\" alt=\"Introduction to Kubernetes Network Policies for Security Professionals\" src=\"\/wp-content\/uploads\/2019\/04\/42e1194e28331e667a094f19c88e0934.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\nAn empty pod selector in this example means 'select all pods in the namespace.'<\/p>\n<p>This policy only allows access to 8.8.8.8; access to any other IP is denied. Thus, you essentially blocked access to the internal Kubernetes DNS service. If you want to open it, specify this explicitly.<\/p>\n<p>Usually <code>ipBlocks<\/code> and <code>podSelectors<\/code> are mutually exclusive, as internal pod IP addresses are not used in <code>ipBlocks<\/code>. Specifying <b>internal pod IPs<\/b>, you essentially allow connections to\/from pods with these addresses. In practice, you won\u2019t know which IP address to use, which is why they should not be used to select pods.<\/p>\n<p>As a counter-example, the following policy includes all IPs and, therefore, allows access to all other pods:<\/p>\n<pre><code class=\"plaintext\">apiVersion: networking.k8s.io\/v1\nkind: NetworkPolicy\nmetadata:\n  name: egress-any\n  namespace: default\nspec:\n  podSelector: {}\n  policyTypes:\n  - Egress\n  egress:\n  - to:\n    - ipBlock:\n        cidr: 0.0.0.0\/0<\/code><\/pre>\n<p>\n<img decoding=\"async\" alt=\"Introduction to Kubernetes Network Policies for Security Professionals\" src=\"\/wp-content\/uploads\/2019\/04\/d99dfdead1c96b071b1643cb5c572878.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\nYou can open access only to external IPs, excluding internal pod IP addresses. For example, if your pod subnet is 10.16.0.0\/14:<\/p>\n<pre><code class=\"plaintext\">apiVersion: networking.k8s.io\/v1\nkind: NetworkPolicy\nmetadata:\n  name: egress-any\n  namespace: default\nspec:\n  podSelector: {}\n  policyTypes:\n  - Egress\n  egress:\n  - to:\n    - ipBlock:\n        cidr: 0.0.0.0\/0\n        except:\n        - 10.16.0.0\/14<\/code><\/pre>\n<p>\n<img decoding=\"async\" alt=\"Introduction to Kubernetes Network Policies for Security Professionals\" src=\"\/wp-content\/uploads\/2019\/04\/b157cfe0f1cd4677cf0defd9fdfa8a13.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<\/p>\n<h2>Ports and protocols<\/h2>\n<p>\nTypically, pods listen on a single port. This means you can simply omit port numbers in policies and leave everything at default. However, it is recommended to make policies as restrictive as possible, so in some cases, specifying ports can still be done:<\/p>\n<pre><code class=\"plaintext\">apiVersion: networking.k8s.io\/v1\nkind: NetworkPolicy\nmetadata:\n  name: default.postgres\n  namespace: default\nspec:\n  ingress:\n  - from:\n    - podSelector:\n        matchLabels:\n          app: indexer\n    - podSelector:\n        matchLabels:\n          app: admin\n    ports:             # &lt;&lt;&lt;\n      - port: 443      # &lt;&lt;&lt;\n        protocol: TCP  # &lt;&lt;&lt;\n      - port: 80       # &lt;&lt;&lt;\n        protocol: TCP  # &lt;&lt;&lt;\n  podSelector:\n    matchLabels:\n      app: postgres\n  policyTypes:\n  - Ingress<\/code><\/pre>\n<p>\n<img decoding=\"async\" alt=\"Introduction to Kubernetes Network Policies for Security Professionals\" src=\"\/wp-content\/uploads\/2019\/04\/4c778cd46c54e2ae0f4527ffa9e1e740.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\nNote that the selector <code>ports<\/code> applies to all elements within the block <code>to<\/code> or <code>from<\/code>, which contains it. To specify different ports for different sets of elements, break down <code>ingress<\/code> or <code>egress<\/code> into several subsections with <code>to<\/code> or <code>from<\/code> and explicitly list your ports in each:<\/p>\n<pre><code class=\"plaintext\">apiVersion: networking.k8s.io\/v1\nkind: NetworkPolicy\nmetadata:\n  name: default.postgres\n  namespace: default\nspec:\n  ingress:\n  - from:\n    - podSelector:\n        matchLabels:\n          app: indexer\n    ports:             # &lt;&lt;&lt;\n     - port: 443       # &lt;&lt;&lt;\n       protocol: TCP   # &lt;&lt;&lt;\n  - from:\n    - podSelector:\n        matchLabels:\n          app: admin\n    ports:             # &lt;&lt;&lt;\n     - port: 80        # &lt;&lt;&lt;\n       protocol: TCP   # &lt;&lt;&lt;\n  podSelector:\n    matchLabels:\n      app: postgres\n  policyTypes:\n  - Ingress<\/code><\/pre>\n<p>\n<img decoding=\"async\" alt=\"Introduction to Kubernetes Network Policies for Security Professionals\" src=\"\/wp-content\/uploads\/2019\/04\/b9ac1d8af491e992cac0be184005a278.png\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\nDefault port behavior:<\/p>\n<ul>\n<li> If you completely omit the port definitions (<code>ports<\/code>), it means all protocols and all ports;<\/li>\n<li> If you omit the protocol definition (<code>protocol<\/code>), it means TCP;<\/li>\n<li> If you omit the port definition (<code>port<\/code>), it means all ports.<\/li>\n<\/ul>\n<p>\nBest practice: do not rely on default values; explicitly specify what you need.<\/p>\n<p>Please note that you need to use the ports of pods, not services (more on this in the next paragraph).<\/p>\n<h2>Are policies defined for pods or services?<\/h2>\n<p>\nTypically, pods in Kubernetes communicate with each other through services \u2014 a virtual load balancer that redirects traffic to the pods implementing the service. One might think that network policies control access to services, but that is not the case. <b>Kubernetes network policies work with pod ports, not services.<\/b><\/p>\n<p>For example, if a service listens on port 80 but redirects traffic to port 8080 of its pods, the network policy must specify 8080.<\/p>\n<p>This mechanism can be considered suboptimal: if the internal structure of a service (whose ports are listened to by pods) changes, the network policies will need to be updated.<\/p>\n<p>A new architectural approach using Service Mesh <i>(for example, see about Istio below \u2014 note from the translator)<\/i> addresses this issue.<\/p>\n<h2>Is it necessary to specify both Ingress and Egress?<\/h2>\n<p>\nThe short answer is yes; for pod A to communicate with pod B, it must be allowed to create an outgoing connection (for this, an egress policy should be configured), and pod B must be able to accept an incoming connection (for this, an ingress policy is required, respectively).<\/p>\n<p>However, in practice, one can rely on a default policy that allows connections in one or both directions.<\/p>\n<p>If a certain pod<b>source<\/b> is selected by one or more <b>egress<\/b>-policies, the restrictions imposed on it will be determined by their disjunction. In this case, it will be necessary to explicitly allow connection to pod-<b>the recipient<\/b>. If a pod is not selected by any policy, its outgoing (egress) traffic is allowed by default.<\/p>\n<p>Similarly, the fate of the pod-<b>the recipient<\/b>, selected by one or more <b>ingress<\/b>-policies will be determined by their disjunction. In this case, it is necessary to explicitly allow it to receive traffic from the source pod. If the pod is not selected by any policy, all incoming (ingress) traffic to it is allowed by default.<\/p>\n<p>See the section 'Stateful or Stateless' below.<\/p>\n<h2>Logs<\/h2>\n<p>\nKubernetes network policies do not log traffic. This complicates determining whether a policy is working correctly and significantly hinders analysis in the security domain.<\/p>\n<h2>Control over traffic to external services<\/h2>\n<p>\nKubernetes network policies do not allow specifying a full domain name (DNS) in egress sections. This fact leads to significant inconvenience when trying to restrict traffic to external recipients who lack a fixed IP address (such as aws.com).<\/p>\n<h2>Policy Check<\/h2>\n<p>\nFirewalls will alert you or may even refuse to accept an incorrect policy. Kubernetes also conducts some verification. When setting a network policy through kubectl, Kubernetes may claim that it is invalid and refuse to accept it. In other cases, Kubernetes will accept the policy and fill in missing details. These can be viewed using the command:<\/p>\n<pre><code class=\"plaintext\">kubernetes get networkpolicy  -o yaml<\/code><\/pre>\n<p>\nNote that the Kubernetes validation system is not infallible and may overlook certain types of errors.<\/p>\n<h2>Execution<\/h2>\n<p>\nKubernetes does not implement network policies on its own; it acts merely as an API gateway, placing the burden of control on an underlying system known as the Container Networking Interface (CNI). Setting policies in a Kubernetes cluster without specifying the appropriate CNI is akin to creating policies on a firewall management server without subsequently installing them on the firewalls. You must ensure that a suitable CNI is in place or, in the case of cloud-hosted Kubernetes platforms, <i>(a list of providers can be found <noindex>here<\/noindex> \u2014 editor\u2019s note)<\/i>, enabling network policies that will set up the CNI for you.<\/p>\n<p>Be aware that Kubernetes will not alert you if you set a network policy without the appropriate supporting CNI.<\/p>\n<h3>Stateful or Stateless?<\/h3>\n<p>\nAll Kubernetes CNIs I have encountered maintain state (for instance, Calico uses Linux conntrack). This allows a pod to receive replies to its initiated TCP connection without needing to establish it anew. However, I am not aware of any Kubernetes standard that guarantees statefulness.<\/p>\n<h2>Advanced Security Policy Management<\/h2>\n<p>\nHere are some ways to increase the effectiveness of security policy enforcement in Kubernetes:<\/p>\n<ol>\n<li> The architectural pattern Service Mesh uses sidecar containers to provide detailed telemetry and control over service-level traffic. An example can be taken from <noindex><a rel=\"nofollow\" href=\"https:\/\/istio.io\/\">Istio<\/a><\/noindex>.<\/li>\n<li> Some CNI providers have enhanced their tools to extend beyond Kubernetes network policies.<\/li>\n<li> <noindex><a rel=\"nofollow\" href=\"https:\/\/www.tufin.com\/products\/tufin-orca\">Tufin Orca<\/a><\/noindex> provides visibility and automation for Kubernetes network policies.<\/li>\n<\/ol>\n<p>\nThe Tufin Orca package manages Kubernetes network policies (and serves as the source for the screenshots provided above).<\/p>\n<h2>Additional information<\/h2>\n<p><\/p>\n<ul>\n<li> <noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/ahmetb\/kubernetes-network-policy-recipes\">Examples of network policies prepared by Ahmet Alp Balkan from GKE<\/a><\/noindex>;<\/li>\n<li> <noindex><a rel=\"nofollow\" href=\"https:\/\/kubernetes.io\/docs\/concepts\/services-networking\/network-policies\/\">Documentation from the official Kubernetes website<\/a><\/noindex>;<\/li>\n<li> <noindex><a rel=\"nofollow\" href=\"https:\/\/sookocheff.com\/post\/kubernetes\/understanding-kubernetes-networking-model\/\">Guideline for the Kubernetes networking model<\/a><\/noindex>;<\/li>\n<li> <noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/Tufin\/test-network-policies\">Script for validating network policies<\/a><\/noindex>.<\/li>\n<\/ul>\n<p><\/p>\n<h2>Conclusion<\/h2>\n<p>\nKubernetes network policies offer a decent set of tools for segmenting clusters; however, they are often unintuitive and contain many nuances. I believe the complexity often leads to errors in the policies of many existing clusters. Possible solutions to this issue are automating policy definitions or applying other segmentation tools.<\/p>\n<p>I hope this guide helps clarify some questions and resolve issues you may encounter.<\/p>\n<h2>P.S. from the translator<\/h2>\n<p>\nAlso read in our blog:<\/p>\n<ul>\n<li> \"Back to Microservices with Istio\": <noindex><a rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/company\/flant\/blog\/438426\/\">Part 1 (Getting to Know the Main Features)<\/a><\/noindex>, <noindex><a rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/company\/flant\/blog\/440378\/\">Part 2 (Routing, Traffic Management)<\/a><\/noindex>, <noindex><a rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/company\/flant\/blog\/443668\/\">part 3 (security)<\/a><\/noindex>;<\/li>\n<li> Illustrated guide to networking in Kubernetes: <noindex><a rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/company\/flant\/blog\/346304\/\">parts 1 and 2 (network model, overlay networks)<\/a><\/noindex>, <noindex><a rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/company\/flant\/blog\/433382\/\">part 3 (services and traffic handling)<\/a><\/noindex>;<\/li>\n<li> \u00ab<noindex><a rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/company\/flant\/blog\/440504\/\">Note: The topic of Docker security is perhaps one of the eternal issues in the modern IT world. Therefore, without further ado, we present the translation of another collection of relevant recommendations.<\/a><\/noindex>\u00bb;<\/li>\n<li> \u00ab<noindex><a rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/company\/flant\/blog\/436300\/\">9 best practices for ensuring security in Kubernetes<\/a><\/noindex>\u00bb;<\/li>\n<li> \u00ab<noindex><a rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/company\/flant\/blog\/417905\/\">11 Ways to (Not) Become a Victim of Hacking in Kubernetes<\/a><\/noindex>\u00bb.<\/li>\n<\/ul>\n<p>Source: <a content=\"nofollow\" rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/company\/flant\/blog\/443190\/\">habr.com<\/a><\/p>","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"excerpt":{"rendered":"<p>\u041f\u0440\u0438\u043c. \u043f\u0435\u0440\u0435\u0432.: \u0410\u0432\u0442\u043e\u0440 \u0441\u0442\u0430\u0442\u044c\u0438 \u2014 Reuven Harrison \u2014 \u0438\u043c\u0435\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 20 \u043b\u0435\u0442 \u043e\u043f\u044b\u0442\u0430 \u0432 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0433\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f, \u0430 \u043d\u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u0438\u0439 \u0434\u0435\u043d\u044c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u043e\u043c \u0438 \u0441\u043e\u0443\u0447\u0440\u0435\u0434\u0438\u0442\u0435\u043b\u0435\u043c \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 Tufin, \u0441\u043e\u0437\u0434\u0430\u044e\u0449\u0435\u0439 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0430\u043c\u0438 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438. \u0420\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u044f \u0441\u0435\u0442\u0435\u0432\u044b\u0435 \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0438 Kubernetes \u043a\u0430\u043a \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u043e\u0449\u043d\u043e\u0435 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e \u0434\u043b\u044f \u0441\u0435\u0433\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0441\u0435\u0442\u0438 \u0432 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0435, \u043e\u043d \u0432 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u0441\u0447\u0438\u0442\u0430\u0435\u0442, \u0447\u0442\u043e \u043e\u043d\u0438 [&hellip;]<\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"author":1,"featured_media":24432,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[688],"tags":[],"class_list":["post-32641","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-administrirovanie"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.2 - aioseo.com -->\n\t<meta name=\"description\" content=\"\u041f\u0440\u0438\u043c.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Yuri Gagarin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/vvedenie-v-setevye-politiki-kubernetes-dlya-spetsialistov-po-bezopasnosti\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.2\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"\ud83e\udd47\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0441\u0435\u0442\u0435\u0432\u044b\u0435 \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0438 Kubernetes \u0434\u043b\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u043e\u0432 \u043f\u043e \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 | ProHoster\" \/>\n\t\t<meta property=\"og:description\" content=\"\u041f\u0440\u0438\u043c.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/vvedenie-v-setevye-politiki-kubernetes-dlya-spetsialistov-po-bezopasnosti\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:width\" content=\"350\" \/>\n\t\t<meta property=\"og:image:height\" content=\"350\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2019-10-31T18:48:11+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2019-10-31T18:48:11+00:00\" \/>\n\t\t<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"\ud83e\udd47Introduction to Kubernetes Network Policies for Security Professionals | ProHoster","description":"Example.","canonical_url":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/vvedenie-v-setevye-politiki-kubernetes-dlya-spetsialistov-po-bezopasnosti","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":null,"og:locale":"en_US","og:site_name":"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b","og:type":"article","og:title":"\ud83e\udd47\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0441\u0435\u0442\u0435\u0432\u044b\u0435 \u043f\u043e\u043b\u0438\u0442\u0438\u043a\u0438 Kubernetes \u0434\u043b\u044f \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u043e\u0432 \u043f\u043e \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 | ProHoster","og:description":"\u041f\u0440\u0438\u043c.","og:url":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/vvedenie-v-setevye-politiki-kubernetes-dlya-spetsialistov-po-bezopasnosti","og:image":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:secure_url":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:width":350,"og:image:height":350,"article:published_time":"2019-10-31T18:48:11+00:00","article:modified_time":"2019-10-31T18:48:11+00:00","article:publisher":"https:\/\/www.facebook.com\/prohoster","article:author":"https:\/\/www.facebook.com\/prohoster"},"aioseo_meta_data":{"post_id":"32641","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"seo_analyzer_scan_date":"2026-01-21 11:53:20","breadcrumb_settings":null,"limit_modified_date":false,"reviewed_by":null,"ai":null,"created":"2021-03-01 02:55:23","updated":"2026-01-21 11:53:20","focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"gt_translate_keys":[{"key":"link","format":"url"}],"_links":{"self":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/32641","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/comments?post=32641"}],"version-history":[{"count":0,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/32641\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/media\/24432"}],"wp:attachment":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/media?parent=32641"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/categories?post=32641"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/tags?post=32641"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}