Browse Source

run netchecker-server with list pods

pull/1382/head
jwfang 7 years ago
parent
commit
a8e6a0763d
7 changed files with 42 additions and 4 deletions
  1. 4
      roles/kubernetes-apps/ansible/defaults/main.yml
  2. 2
      roles/kubernetes-apps/ansible/tasks/main.yml
  3. 8
      roles/kubernetes-apps/ansible/tasks/netchecker.yml
  4. 9
      roles/kubernetes-apps/ansible/templates/netchecker-server-clusterrole.yml.j2
  5. 13
      roles/kubernetes-apps/ansible/templates/netchecker-server-clusterrolebinding.yml.j2
  6. 3
      roles/kubernetes-apps/ansible/templates/netchecker-server-deployment.yml.j2
  7. 7
      roles/kubernetes-apps/ansible/templates/netchecker-server-sa.yml.j2

4
roles/kubernetes-apps/ansible/defaults/main.yml

@ -41,7 +41,7 @@ netchecker_server_memory_requests: 64M
etcd_cert_dir: "/etc/ssl/etcd/ssl"
canal_cert_dir: "/etc/canal/certs"
kubedns_rbac_resources:
rbac_resources:
- sa
- clusterrole
- clusterrolebinding
- sa

2
roles/kubernetes-apps/ansible/tasks/main.yml

@ -23,7 +23,7 @@
register: manifests
when:
- dns_mode != 'none' and inventory_hostname == groups['kube-master'][0]
- rbac_enabled or item.type not in kubedns_rbac_resources
- rbac_enabled or item.type not in rbac_resources
tags: dnsmasq
# see https://github.com/kubernetes/kubernetes/issues/45084, only needed for "old" kube-dns

8
roles/kubernetes-apps/ansible/tasks/netchecker.yml

@ -5,10 +5,15 @@
with_items:
- {file: netchecker-agent-ds.yml.j2, type: ds, name: netchecker-agent}
- {file: netchecker-agent-hostnet-ds.yml.j2, type: ds, name: netchecker-agent-hostnet}
- {file: netchecker-server-sa.yml.j2, type: sa, name: netchecker-server}
- {file: netchecker-server-clusterrole.yml.j2, type: clusterrole, name: netchecker-server}
- {file: netchecker-server-clusterrolebinding.yml.j2, type: clusterrolebinding, name: netchecker-server}
- {file: netchecker-server-deployment.yml.j2, type: po, name: netchecker-server}
- {file: netchecker-server-svc.yml.j2, type: svc, name: netchecker-service}
register: manifests
when: inventory_hostname == groups['kube-master'][0]
when:
- inventory_hostname == groups['kube-master'][0]
- rbac_enabled or item.type not in rbac_resources
#FIXME: remove if kubernetes/features#124 is implemented
- name: Kubernetes Apps | Purge old Netchecker daemonsets
@ -31,4 +36,5 @@
filename: "{{kube_config_dir}}/{{item.item.file}}"
state: "{{item.changed | ternary('latest','present') }}"
with_items: "{{ manifests.results }}"
failed_when: manifests|failed and "Error from server (AlreadyExists)" not in manifests.msg
when: inventory_hostname == groups['kube-master'][0]

9
roles/kubernetes-apps/ansible/templates/netchecker-server-clusterrole.yml.j2

@ -0,0 +1,9 @@
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: netchecker-server
namespace: {{ netcheck_namespace }}
rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["list"]

13
roles/kubernetes-apps/ansible/templates/netchecker-server-clusterrolebinding.yml.j2

@ -0,0 +1,13 @@
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: netchecker-server
namespace: {{ netcheck_namespace }}
subjects:
- kind: ServiceAccount
name: netchecker-server
namespace: {{ netcheck_namespace }}
roleRef:
kind: ClusterRole
name: netchecker-server
apiGroup: rbac.authorization.k8s.io

3
roles/kubernetes-apps/ansible/templates/netchecker-server-deployment.yml.j2

@ -31,3 +31,6 @@ spec:
- "-logtostderr"
- "-kubeproxyinit"
- "-endpoint=0.0.0.0:8081"
{% if rbac_enabled %}
serviceAccountName: netchecker-server
{% endif %}

7
roles/kubernetes-apps/ansible/templates/netchecker-server-sa.yml.j2

@ -0,0 +1,7 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: netchecker-server
namespace: {{ netcheck_namespace }}
labels:
kubernetes.io/cluster-service: "true"
Loading…
Cancel
Save