-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add possibility to enable network policy via Calico network controller
The requirements for network policy feature are described here [1]. In order to enable it, appropriate configuration must be provided to the CNI plug in and Calico policy controller must be set up. Beside that corresponding extensions needed to be enabled in k8s API. Now to turn on the feature user can define `enable_network_policy` customization variable for Ansible. [1] http://kubernetes.io/docs/user-guide/networkpolicies/
- Loading branch information
Artem Roma
committed
Oct 10, 2016
1 parent
8c8d978
commit 3919d66
Showing
5 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
roles/kubernetes-apps/ansible/tasks/calico-policy-controller.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
- name: Write calico-policy-controller yaml | ||
template: src=calico-policy-controller.yml.j2 dest=/etc/kubernetes/calico-policy-controller.yml | ||
when: inventory_hostname == groups['kube-master'][0] | ||
|
||
|
||
- name: Start of Calico policy controller | ||
kube: | ||
kubectl: "{{bin_dir}}/kubectl" | ||
filename: /etc/kubernetes/calico-policy-controller.yml | ||
when: inventory_hostname == groups['kube-master'][0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
roles/kubernetes-apps/ansible/templates/calico-policy-controller.yml.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
apiVersion: extensions/v1beta1 | ||
kind: ReplicaSet | ||
metadata: | ||
name: calico-policy-controller | ||
namespace: kube-system | ||
labels: | ||
k8s-app: calico-policy | ||
kubernetes.io/cluster-service: "true" | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
kubernetes.io/cluster-service: "true" | ||
k8s-app: calico-policy | ||
template: | ||
metadata: | ||
name: calico-policy-controller | ||
namespace: kube-system | ||
labels: | ||
kubernetes.io/cluster-service: "true" | ||
k8s-app: calico-policy | ||
spec: | ||
hostNetwork: true | ||
containers: | ||
- name: calico-policy-controller | ||
image: calico/kube-policy-controller:latest | ||
env: | ||
- name: ETCD_ENDPOINTS | ||
value: "{{ etcd_endpoint }}" | ||
# Location of the Kubernetes API - this shouldn't need to be | ||
# changed so long as it is used in conjunction with | ||
# CONFIGURE_ETC_HOSTS="true". | ||
- name: K8S_API | ||
value: "https://kubernetes.default:443" | ||
# Configure /etc/hosts within the container to resolve | ||
# the kubernetes.default Service to the correct clusterIP | ||
# using the environment provided by the kubelet. | ||
# This removes the need for KubeDNS to resolve the Service. | ||
- name: CONFIGURE_ETC_HOSTS | ||
value: "true" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters