2017-08-21 23:47:06 +00:00
|
|
|
---
|
2018-02-18 19:29:37 +00:00
|
|
|
reviewers:
|
2017-08-21 23:47:06 +00:00
|
|
|
- danwent
|
2018-11-24 16:17:45 +00:00
|
|
|
- aanm
|
2017-08-21 23:47:06 +00:00
|
|
|
title: Use Cilium for NetworkPolicy
|
2020-05-30 19:10:23 +00:00
|
|
|
content_type: task
|
2018-05-20 03:54:51 +00:00
|
|
|
weight: 20
|
2017-08-21 23:47:06 +00:00
|
|
|
---
|
|
|
|
|
2020-05-30 19:10:23 +00:00
|
|
|
<!-- overview -->
|
2017-08-21 23:47:06 +00:00
|
|
|
This page shows how to use Cilium for NetworkPolicy.
|
|
|
|
|
2020-01-13 12:35:36 +00:00
|
|
|
For background on Cilium, read the [Introduction to Cilium](https://docs.cilium.io/en/stable/intro).
|
2017-08-21 23:47:06 +00:00
|
|
|
|
2020-05-30 19:10:23 +00:00
|
|
|
|
|
|
|
## {{% heading "prerequisites" %}}
|
|
|
|
|
2017-08-21 23:47:06 +00:00
|
|
|
|
2018-05-05 16:00:51 +00:00
|
|
|
{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
|
2017-08-21 23:47:06 +00:00
|
|
|
|
|
|
|
|
2020-05-30 19:10:23 +00:00
|
|
|
|
|
|
|
<!-- steps -->
|
2017-08-21 23:47:06 +00:00
|
|
|
## Deploying Cilium on Minikube for Basic Testing
|
|
|
|
|
|
|
|
To get familiar with Cilium easily you can follow the
|
2020-01-13 12:35:36 +00:00
|
|
|
[Cilium Kubernetes Getting Started Guide](https://docs.cilium.io/en/stable/gettingstarted/minikube/)
|
2017-08-21 23:47:06 +00:00
|
|
|
to perform a basic DaemonSet installation of Cilium in minikube.
|
|
|
|
|
2020-01-13 12:35:36 +00:00
|
|
|
To start minikube, minimal version required is >= v1.3.1, run the with the
|
2019-02-15 05:50:21 +00:00
|
|
|
following arguments:
|
2017-08-21 23:47:06 +00:00
|
|
|
|
|
|
|
```shell
|
2019-03-07 09:31:05 +00:00
|
|
|
minikube version
|
|
|
|
```
|
|
|
|
```
|
2020-01-13 12:35:36 +00:00
|
|
|
minikube version: v1.3.1
|
2019-03-07 09:31:05 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
```shell
|
|
|
|
minikube start --network-plugin=cni --memory=4096
|
2018-11-24 16:17:45 +00:00
|
|
|
```
|
|
|
|
|
2020-01-13 12:35:36 +00:00
|
|
|
Mount the BPF filesystem:
|
|
|
|
|
|
|
|
```shell
|
|
|
|
minikube ssh -- sudo mount bpffs -t bpf /sys/fs/bpf
|
|
|
|
```
|
|
|
|
|
2019-02-15 05:50:21 +00:00
|
|
|
For minikube you can deploy this simple ''all-in-one'' YAML file that includes
|
2020-01-13 12:35:36 +00:00
|
|
|
DaemonSet configurations for Cilium as well as appropriate RBAC settings:
|
2018-11-24 16:17:45 +00:00
|
|
|
|
|
|
|
```shell
|
2020-06-16 14:16:39 +00:00
|
|
|
kubectl create -f https://raw.githubusercontent.com/cilium/cilium/v1.8/install/kubernetes/quick-install.yaml
|
2019-03-07 09:31:05 +00:00
|
|
|
```
|
|
|
|
```
|
2018-11-24 16:17:45 +00:00
|
|
|
configmap/cilium-config created
|
|
|
|
serviceaccount/cilium created
|
2020-01-13 12:35:36 +00:00
|
|
|
serviceaccount/cilium-operator created
|
|
|
|
clusterrole.rbac.authorization.k8s.io/cilium created
|
|
|
|
clusterrole.rbac.authorization.k8s.io/cilium-operator created
|
|
|
|
clusterrolebinding.rbac.authorization.k8s.io/cilium created
|
|
|
|
clusterrolebinding.rbac.authorization.k8s.io/cilium-operator created
|
|
|
|
daemonset.apps/cilium create
|
|
|
|
deployment.apps/cilium-operator created
|
2017-08-21 23:47:06 +00:00
|
|
|
```
|
|
|
|
|
2017-12-03 17:25:59 +00:00
|
|
|
The remainder of the Getting Started Guide explains how to enforce both L3/L4
|
|
|
|
(i.e., IP address + port) security policies, as well as L7 (e.g., HTTP) security
|
|
|
|
policies using an example application.
|
2017-08-21 23:47:06 +00:00
|
|
|
|
|
|
|
## Deploying Cilium for Production Use
|
|
|
|
|
|
|
|
For detailed instructions around deploying Cilium for production, see:
|
2020-09-15 02:57:40 +00:00
|
|
|
[Cilium Kubernetes Installation Guide](https://docs.cilium.io/en/stable/concepts/kubernetes/intro/)
|
2017-12-03 17:25:59 +00:00
|
|
|
This documentation includes detailed requirements, instructions and example
|
|
|
|
production DaemonSet files.
|
2017-08-21 23:47:06 +00:00
|
|
|
|
|
|
|
|
2020-05-30 19:10:23 +00:00
|
|
|
|
|
|
|
<!-- discussion -->
|
2017-08-21 23:47:06 +00:00
|
|
|
## Understanding Cilium components
|
|
|
|
|
2017-12-03 17:25:59 +00:00
|
|
|
Deploying a cluster with Cilium adds Pods to the `kube-system` namespace. To see
|
|
|
|
this list of Pods run:
|
2017-08-21 23:47:06 +00:00
|
|
|
|
|
|
|
```shell
|
|
|
|
kubectl get pods --namespace=kube-system
|
|
|
|
```
|
|
|
|
|
|
|
|
You'll see a list of Pods similar to this:
|
|
|
|
|
|
|
|
```console
|
2018-11-24 16:17:45 +00:00
|
|
|
NAME READY STATUS RESTARTS AGE
|
|
|
|
cilium-6rxbd 1/1 Running 0 1m
|
2017-08-21 23:47:06 +00:00
|
|
|
...
|
|
|
|
```
|
|
|
|
|
2020-01-13 12:35:36 +00:00
|
|
|
A `cilium` Pod runs on each node in your cluster and enforces network policy
|
2017-12-03 17:25:59 +00:00
|
|
|
on the traffic to/from Pods on that node using Linux BPF.
|
2017-08-21 23:47:06 +00:00
|
|
|
|
|
|
|
|
2020-05-30 19:10:23 +00:00
|
|
|
|
|
|
|
## {{% heading "whatsnext" %}}
|
|
|
|
|
2017-12-03 17:25:59 +00:00
|
|
|
Once your cluster is running, you can follow the
|
|
|
|
[Declare Network Policy](/docs/tasks/administer-cluster/declare-network-policy/)
|
|
|
|
to try out Kubernetes NetworkPolicy with Cilium.
|
|
|
|
Have fun, and if you have questions, contact us using the
|
|
|
|
[Cilium Slack Channel](https://cilium.herokuapp.com/).
|
2020-05-30 19:10:23 +00:00
|
|
|
|
2018-05-05 16:00:51 +00:00
|
|
|
|
2017-08-21 23:47:06 +00:00
|
|
|
|