Skip to content

Commit db6af8d

Browse files
Merge pull request #1099 from caseydavenport/policy-controller-go
Golang policy controller docs
2 parents 5e91462 + 28422d6 commit db6af8d

File tree

4 files changed

+22
-73
lines changed

4 files changed

+22
-73
lines changed

master/getting-started/kubernetes/installation/hosted/calico.yaml

-9
Original file line numberDiff line numberDiff line change
@@ -295,15 +295,6 @@ spec:
295295
configMapKeyRef:
296296
name: calico-config
297297
key: etcd_cert
298-
# The location of the Kubernetes API. Use the default Kubernetes
299-
# service for API access.
300-
- name: K8S_API
301-
value: "https://kubernetes.default:443"
302-
# Since we're running in the host namespace and might not have KubeDNS
303-
# access, configure the container's /etc/hosts to resolve
304-
# kubernetes.default to the correct service clusterIP.
305-
- name: CONFIGURE_ETC_HOSTS
306-
value: "true"
307298
volumeMounts:
308299
# Mount in the etcd TLS secrets.
309300
- mountPath: /calico-secrets

master/getting-started/kubernetes/installation/hosted/kubeadm/1.5/calico.yaml

-9
Original file line numberDiff line numberDiff line change
@@ -288,12 +288,3 @@ spec:
288288
configMapKeyRef:
289289
name: calico-config
290290
key: etcd_endpoints
291-
# The location of the Kubernetes API. Use the default Kubernetes
292-
# service for API access.
293-
- name: K8S_API
294-
value: "https://kubernetes.default:443"
295-
# Since we're running in the host namespace and might not have KubeDNS
296-
# access, configure the container's /etc/hosts to resolve
297-
# kubernetes.default to the correct service clusterIP.
298-
- name: CONFIGURE_ETC_HOSTS
299-
value: "true"

master/getting-started/kubernetes/installation/policy-controller.yaml

-11
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,3 @@ spec:
4141
# your etcd cluster.
4242
- name: ETCD_ENDPOINTS
4343
value: "<ETCD_ENDPOINTS>"
44-
# Location of the Kubernetes API - this shouldn't need to be
45-
# changed so long as it is used in conjunction with
46-
# CONFIGURE_ETC_HOSTS="true".
47-
- name: K8S_API
48-
value: "https://kubernetes.default:443"
49-
# Configure /etc/hosts within the container to resolve
50-
# the kubernetes.default Service to the correct clusterIP
51-
# using the environment provided by the kubelet.
52-
# This removes the need for KubeDNS to resolve the Service.
53-
- name: CONFIGURE_ETC_HOSTS
54-
value: "true"

master/reference/policy-controller/configuration.md

+22-44
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Configuring the Calico policy controller
33
---
44

5-
The policy controller is primarily configured through environment variables. When running
5+
The policy controller is primarily configured through environment variables. When running
66
the policy controller as a Kubernetes pod, this is accomplished through the pod manifest `env`
77
section.
88

@@ -13,57 +13,35 @@ section.
1313
The policy controller supports the following environment variables to configure
1414
etcd access:
1515

16-
* `ETCD_ENDPOINTS`: The list of etcd nodes in your cluster. e.g `http://10.0.0.1:2379,http://10.0.0.2:2379`
17-
* `ETCD_CA_CERT_FILE`: The full path to the CA certificate file for the Certificate Authority that signed the etcd server key/certificate pair.
18-
* `ETCD_CERT_FILE`: The full path to the client certificate file for accessing the etcd cluster.
19-
* `ETCD_KEY_FILE`: The full path to the client key file for accessing the etcd cluster.
16+
| Environment | Description | Schema |
17+
| ------------- | ----------- | ------ |
18+
| `ETCD_ENDPOINTS` | The list of etcd nodes in your cluster. e.g `http://10.0.0.1:2379,http://10.0.0.2:2379`
19+
| `ETCD_CA_CERT_FILE` | The full path to the CA certificate file for the Certificate Authority that signed the etcd server key/certificate pair. | path
20+
| `ETCD_CERT_FILE` | The full path to the client certificate file for accessing the etcd cluster. | path
21+
| `ETCD_KEY_FILE` | The full path to the client key file for accessing the etcd cluster. | path
2022

21-
> **Note**: When running etcd with TLS enabled, the addresses in
22-
> `ETCD_ENDPOINTS` must be hostname values such as `etcd-host:2379`,
23-
> NOT IP addresses.
24-
{: .alert .alert-info}
23+
The `*_FILE` variables are _paths_ to the corresponding certificates/keys. As such, when the policy controller is running as a Kubernetes pod, you
24+
must ensure that the files exist within the pod. This is usually done in one of two ways:
2525

26-
The `*_FILE` variables are _paths_ to the corresponding certificates / keys. As such, when the policy controller is running as a Kubernetes pod, you
27-
must ensure that the files exist within the pod. This is usually done in one of two ways:
28-
29-
* Mount the certificates from the host. This requires that the certs be present on the host that the policy controller is scheduled to / running on.
26+
* Mount the certificates from the host. This requires that the certs be present on the host running the policy controller.
3027
* Use Kubernetes [Secrets](http://kubernetes.io/docs/user-guide/secrets/) to mount the certificates into the Pod as files.
3128

3229
### Configuring Kubernetes API access
3330

34-
The policy controller must access the Kubernetes API in order to learn about NetworkPolicy, Pod, and Namespace events.
35-
36-
The following environment variables are useful for configuring API access:
37-
38-
* `K8S_API`: The location of the Kubernetes API, including transport and port. e.g `https://kubernetes.default:443`
39-
* `CONFIGURE_ETC_HOSTS`: Whether or not the policy controller should configure its /etc/hosts file to resolve the Kubernetes Service clusterIP. When "true", the policy controller will resolve `kubernetes.default` to the configured clusterIP of the Kubernetes API.
40-
41-
It is recommended to use the following configuration for API access:
42-
43-
```
44-
- name: K8S_API
45-
value: "https://kubernetes.default:443"
46-
- name: CONFIGURE_ETC_HOSTS
47-
value: "true"
48-
```
49-
50-
## The leader election container
31+
The policy controller must have read access to the Kubernetes API in order to monitor NetworkPolicy, Pod, and Namespace events.
5132

52-
The leader election container is an optional sidecar container which performs leader election using the Kubernetes API.
53-
This ensures that only a single instance of the policy controller is ever active.
54-
55-
The leader election container is only recommended when running the policy controller as a static pod in a multi-master deployment.
56-
57-
However, it is instead recommended to use a `ReplicaSet` with a single replica to ensure that one instance
58-
will always be running without need for leader election.
59-
60-
### Kubernetes API access
61-
62-
The leader election container also needs Kubernetes API access, which can be configured through a `kubeconfig` file placed in
63-
the root directory of the container. This can be done by mounting a file from the host, or using Kubernetes [ConfigMap resources](http://kubernetes.io/docs/user-guide/configmap/).
33+
When running the policy controller as a self-hosted Kubernetes Pod, Kubernetes API access is [configured automatically][in-cluster-config] and
34+
no additional configuration is required. However, the controller also supports an explicit [kubeconfig][kubeconfig] file override to
35+
configure API access if needed.
6436

6537
### Other configuration
6638

67-
* `LOG_LEVEL`: Supports the standard Python log levels. e.g. `LOG_LEVEL=debug`, defaults to `info`
39+
The following environment variables can be used to configure the policy controller.
40+
41+
| Environment | Description | Schema |
42+
| ------------- | ----------- | ------ |
43+
| `LOG_LEVEL` | Minimum log level to be displayed. | debug, info, warning, error |
44+
| `KUBECONFIG` | Path to a kubeconfig file for kubernetes API access | path |
6845

69-
More information on leader election can be found in the [kubernetes/contrib](https://github.com/kubernetes/contrib/tree/master/election#simple-leader-election-with-kubernetes-and-docker) repository.
46+
[in-cluster-config]: https://kubernetes.io/docs/tasks/access-application-cluster/access-cluster/#accessing-the-api-from-a-pod
47+
[kubeconfig]: https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/

0 commit comments

Comments
 (0)