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
|
2018-05-05 16:00:51 +00:00
|
|
|
content_template: templates/task
|
2018-05-20 03:54:51 +00:00
|
|
|
weight: 20
|
2017-08-21 23:47:06 +00:00
|
|
|
---
|
|
|
|
|
2018-05-05 16:00:51 +00:00
|
|
|
{{% capture overview %}}
|
2017-08-21 23:47:06 +00:00
|
|
|
This page shows how to use Cilium for NetworkPolicy.
|
|
|
|
|
2018-11-24 16:17:45 +00:00
|
|
|
For background on Cilium, read the [Introduction to Cilium](https://cilium.readthedocs.io/en/stable/intro).
|
2018-05-05 16:00:51 +00:00
|
|
|
{{% /capture %}}
|
2017-08-21 23:47:06 +00:00
|
|
|
|
2018-05-05 16:00:51 +00:00
|
|
|
{{% capture 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
|
|
|
|
2018-05-05 16:00:51 +00:00
|
|
|
{{% /capture %}}
|
2017-08-21 23:47:06 +00:00
|
|
|
|
2018-05-05 16:00:51 +00:00
|
|
|
{{% capture 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
|
2018-11-24 16:17:45 +00:00
|
|
|
[Cilium Kubernetes Getting Started Guide](https://cilium.readthedocs.io/en/stable/gettingstarted/minikube/)
|
2017-08-21 23:47:06 +00:00
|
|
|
to perform a basic DaemonSet installation of Cilium in minikube.
|
|
|
|
|
2019-02-15 05:50:21 +00:00
|
|
|
To start minikube, minimal version required is >= v0.33.1, run the with the
|
|
|
|
following arguments:
|
2017-08-21 23:47:06 +00:00
|
|
|
|
|
|
|
```shell
|
2019-03-07 09:31:05 +00:00
|
|
|
minikube version
|
|
|
|
```
|
|
|
|
```
|
2019-02-15 05:50:21 +00:00
|
|
|
minikube version: v0.33.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
|
|
|
```
|
|
|
|
|
2019-02-15 05:50:21 +00:00
|
|
|
For minikube you can deploy this simple ''all-in-one'' YAML file that includes
|
|
|
|
DaemonSet configurations for Cilium, and the necessary configurations to connect
|
|
|
|
to the etcd instance deployed in minikube as well as appropriate RBAC settings:
|
2018-11-24 16:17:45 +00:00
|
|
|
|
|
|
|
```shell
|
2019-05-07 11:51:42 +00:00
|
|
|
kubectl create -f https://raw.githubusercontent.com/cilium/cilium/v1.5/examples/kubernetes/1.14/cilium-minikube.yaml
|
2019-03-07 09:31:05 +00:00
|
|
|
```
|
|
|
|
```
|
2018-11-24 16:17:45 +00:00
|
|
|
configmap/cilium-config created
|
|
|
|
daemonset.apps/cilium created
|
|
|
|
clusterrolebinding.rbac.authorization.k8s.io/cilium created
|
|
|
|
clusterrole.rbac.authorization.k8s.io/cilium created
|
|
|
|
serviceaccount/cilium 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:
|
2019-02-15 05:50:21 +00:00
|
|
|
[Cilium Kubernetes Installation Guide](https://cilium.readthedocs.io/en/stable/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
|
|
|
|
2018-05-05 16:00:51 +00:00
|
|
|
{{% /capture %}}
|
2017-08-21 23:47:06 +00:00
|
|
|
|
2018-05-05 16:00:51 +00:00
|
|
|
{{% capture 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
|
|
|
...
|
|
|
|
```
|
|
|
|
|
|
|
|
There are two main components to be aware of:
|
|
|
|
|
2017-12-03 17:25:59 +00:00
|
|
|
- One `cilium` Pod runs on each node in your cluster and enforces network policy
|
|
|
|
on the traffic to/from Pods on that node using Linux BPF.
|
2018-11-24 16:17:45 +00:00
|
|
|
- For production deployments, Cilium should leverage a key-value store
|
2019-02-15 05:50:21 +00:00
|
|
|
(e.g., etcd). The [Cilium Kubernetes Installation Guide](https://cilium.readthedocs.io/en/stable/kubernetes/intro/)
|
2018-11-24 16:17:45 +00:00
|
|
|
will provide the necessary steps on how to install this required key-value
|
|
|
|
store as well how to configure it in Cilium.
|
2017-08-21 23:47:06 +00:00
|
|
|
|
2018-05-05 16:00:51 +00:00
|
|
|
{{% /capture %}}
|
2017-08-21 23:47:06 +00:00
|
|
|
|
2018-05-05 16:00:51 +00:00
|
|
|
{{% capture 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/).
|
2018-05-05 16:00:51 +00:00
|
|
|
{{% /capture %}}
|
|
|
|
|
2017-08-21 23:47:06 +00:00
|
|
|
|