Add rbac for calico policy controller
This commit is contained in:
parent
c1fd468687
commit
a035583f86
9 changed files with 73 additions and 15 deletions
|
@ -9,3 +9,4 @@
|
|||
state: "{{item.changed | ternary('latest','present') }}"
|
||||
with_items: "{{ canal_manifests.results }}"
|
||||
failed_when: canal_manifests|failed and "Error from server (AlreadyExists)" not in canal_manifests.msg
|
||||
when: inventory_hostname == groups['kube-master'][0]
|
||||
|
|
|
@ -8,3 +8,8 @@ calico_policy_controller_memory_requests: 64M
|
|||
# SSL
|
||||
calico_cert_dir: "/etc/calico/certs"
|
||||
canal_cert_dir: "/etc/canal/certs"
|
||||
|
||||
rbac_resources:
|
||||
- sa
|
||||
- clusterrole
|
||||
- clusterrolebinding
|
||||
|
|
|
@ -4,19 +4,27 @@
|
|||
when: kube_network_plugin == 'canal'
|
||||
tags: [facts, canal]
|
||||
|
||||
- name: Write calico-policy-controller yaml
|
||||
- name: Create calico-policy-controller manifests
|
||||
template:
|
||||
src: calico-policy-controller.yml.j2
|
||||
dest: "{{kube_config_dir}}/calico-policy-controller.yml"
|
||||
when: inventory_hostname == groups['kube-master'][0]
|
||||
tags: canal
|
||||
src: "{{item.file}}.j2"
|
||||
dest: "{{kube_config_dir}}/{{item.file}}"
|
||||
with_items:
|
||||
- {name: calico-policy-controller, file: calico-policy-controller.yml, type: rs}
|
||||
- {name: calico-policy-controller, file: calico-policy-sa.yml, type: sa}
|
||||
- {name: calico-policy-controller, file: calico-policy-cr.yml, type: clusterrole}
|
||||
- {name: calico-policy-controller, file: calico-policy-crb.yml, type: clusterrolebinding}
|
||||
register: calico_policy_manifests
|
||||
when:
|
||||
- rbac_enabled or item.type not in rbac_resources
|
||||
|
||||
- name: Start of Calico policy controller
|
||||
kube:
|
||||
name: "calico-policy-controller"
|
||||
name: "{{item.item.name}}"
|
||||
namespace: "{{ system_namespace }}"
|
||||
kubectl: "{{bin_dir}}/kubectl"
|
||||
filename: "{{kube_config_dir}}/calico-policy-controller.yml"
|
||||
namespace: "{{system_namespace}}"
|
||||
resource: "rs"
|
||||
resource: "{{item.item.type}}"
|
||||
filename: "{{kube_config_dir}}/{{item.item.file}}"
|
||||
state: "{{item.changed | ternary('latest','present') }}"
|
||||
with_items: "{{ calico_policy_manifests.results }}"
|
||||
failed_when: calico_policy_manifests|failed and "Error from server (AlreadyExists)" not in calico_policy_manifests.msg
|
||||
when: inventory_hostname == groups['kube-master'][0]
|
||||
tags: canal
|
||||
|
|
|
@ -21,6 +21,9 @@ spec:
|
|||
k8s-app: calico-policy
|
||||
spec:
|
||||
hostNetwork: true
|
||||
{% if rbac_enabled %}
|
||||
serviceAccountName: calico-policy-controller
|
||||
{% endif %}
|
||||
tolerations:
|
||||
- effect: NoSchedule
|
||||
operator: Exists
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
---
|
||||
kind: ClusterRole
|
||||
apiVersion: rbac.authorization.k8s.io/v1beta1
|
||||
metadata:
|
||||
name: calico-policy-controller
|
||||
namespace: {{ system_namespace }}
|
||||
rules:
|
||||
- apiGroups:
|
||||
- ""
|
||||
- extensions
|
||||
resources:
|
||||
- pods
|
||||
- namespaces
|
||||
- networkpolicies
|
||||
verbs:
|
||||
- watch
|
||||
- list
|
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
kind: ClusterRoleBinding
|
||||
apiVersion: rbac.authorization.k8s.io/v1beta1
|
||||
metadata:
|
||||
name: calico-policy-controller
|
||||
roleRef:
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
kind: ClusterRole
|
||||
name: calico-policy-controller
|
||||
subjects:
|
||||
- kind: ServiceAccount
|
||||
name: calico-policy-controller
|
||||
namespace: {{ system_namespace }}
|
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: calico-policy-controller
|
||||
namespace: {{ system_namespace }}
|
||||
labels:
|
||||
kubernetes.io/cluster-service: "true"
|
|
@ -32,20 +32,21 @@
|
|||
delegate_to: "{{groups['etcd'][0]}}"
|
||||
run_once: true
|
||||
|
||||
- name: Canal | Create canal node rbac configuration
|
||||
- name: Canal | Create canal node manifests
|
||||
template:
|
||||
src: "{{item.file}}.j2"
|
||||
dest: "{{kube_config_dir}}/{{item.file}}"
|
||||
with_items:
|
||||
- {name: canal-config, file: canal-config.yml, type: cm}
|
||||
- {name: canal-node, file: canal-node.yml, type: ds}
|
||||
- {name: canal-config, file: canal-config.yaml, type: cm}
|
||||
- {name: canal-node, file: canal-node.yaml, type: ds}
|
||||
- {name: canal, file: canal-node-sa.yml, type: sa}
|
||||
- {name: calico, file: canal-cr-calico.yml, type: clusterrole}
|
||||
- {name: flannel, file: canal-cr-flannel.yml, type: clusterrole}
|
||||
- {name: canal-calico, file: canal-cr-calico.yml, type: clusterrolebinding}
|
||||
- {name: canal-flannel, file: canal-cr-flannel.yml, type: clusterrolebinding}
|
||||
- {name: canal-calico, file: canal-crb-calico.yml, type: clusterrolebinding}
|
||||
- {name: canal-flannel, file: canal-crb-flannel.yml, type: clusterrolebinding}
|
||||
register: canal_manifests
|
||||
when:
|
||||
- inventory_hostname in groups['kube-master']
|
||||
- rbac_enabled or item.type not in rbac_resources
|
||||
|
||||
- name: Canal | Copy cni plugins from hyperkube
|
||||
|
|
|
@ -19,7 +19,9 @@ spec:
|
|||
k8s-app: canal-node
|
||||
spec:
|
||||
hostNetwork: true
|
||||
{% if rbac_enabled %}
|
||||
serviceAccountName: canal
|
||||
{% endif %}
|
||||
tolerations:
|
||||
- effect: NoSchedule
|
||||
operator: Exists
|
||||
|
|
Loading…
Reference in a new issue