From 2670eefcd498597d098499f23f05777342797f22 Mon Sep 17 00:00:00 2001 From: Sergii Golovatiuk Date: Tue, 28 Mar 2017 16:33:07 +0200 Subject: [PATCH] Refactoring resolv.conf - Renaming templates for netchecker - Add dnsPolicy: ClusterFirstWithHostNet to kube-proxy Signed-off-by: Sergii Golovatiuk --- .../ansible/tasks/netchecker.yml | 8 ++-- ...gent-ds.yml => netchecker-agent-ds.yml.j2} | 0 .../netchecker-agent-hostnet-ds.yml.j2 | 39 +++++++++++++++++++ ...r-pod.yml => netchecker-server-pod.yml.j2} | 0 ...r-svc.yml => netchecker-server-svc.yml.j2} | 0 .../kube-controller-manager.manifest.j2 | 4 +- .../manifests/kube-scheduler.manifest.j2 | 4 +- .../manifests/kube-proxy.manifest.j2 | 3 ++ 8 files changed, 50 insertions(+), 8 deletions(-) rename roles/kubernetes-apps/ansible/templates/{netchecker-agent-ds.yml => netchecker-agent-ds.yml.j2} (100%) create mode 100644 roles/kubernetes-apps/ansible/templates/netchecker-agent-hostnet-ds.yml.j2 rename roles/kubernetes-apps/ansible/templates/{netchecker-server-pod.yml => netchecker-server-pod.yml.j2} (100%) rename roles/kubernetes-apps/ansible/templates/{netchecker-server-svc.yml => netchecker-server-svc.yml.j2} (100%) diff --git a/roles/kubernetes-apps/ansible/tasks/netchecker.yml b/roles/kubernetes-apps/ansible/tasks/netchecker.yml index f3c7ac1df..b9047a1e2 100644 --- a/roles/kubernetes-apps/ansible/tasks/netchecker.yml +++ b/roles/kubernetes-apps/ansible/tasks/netchecker.yml @@ -3,10 +3,10 @@ src: "{{item.file}}" dest: "{{kube_config_dir}}/{{item.file}}" with_items: - - {file: netchecker-agent-ds.yml, type: ds, name: netchecker-agent} - - {file: netchecker-agent-hostnet-ds.j2, type: ds, name: netchecker-agent-hostnet} - - {file: netchecker-server-pod.yml, type: po, name: netchecker-server} - - {file: netchecker-server-svc.yml, type: svc, name: netchecker-service} + - {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-pod.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] diff --git a/roles/kubernetes-apps/ansible/templates/netchecker-agent-ds.yml b/roles/kubernetes-apps/ansible/templates/netchecker-agent-ds.yml.j2 similarity index 100% rename from roles/kubernetes-apps/ansible/templates/netchecker-agent-ds.yml rename to roles/kubernetes-apps/ansible/templates/netchecker-agent-ds.yml.j2 diff --git a/roles/kubernetes-apps/ansible/templates/netchecker-agent-hostnet-ds.yml.j2 b/roles/kubernetes-apps/ansible/templates/netchecker-agent-hostnet-ds.yml.j2 new file mode 100644 index 000000000..13a966c80 --- /dev/null +++ b/roles/kubernetes-apps/ansible/templates/netchecker-agent-hostnet-ds.yml.j2 @@ -0,0 +1,39 @@ +apiVersion: extensions/v1beta1 +kind: DaemonSet +metadata: + labels: + app: netchecker-agent-hostnet + name: netchecker-agent-hostnet + namespace: {{ netcheck_namespace }} +spec: + template: + metadata: + name: netchecker-agent-hostnet + labels: + app: netchecker-agent-hostnet + spec: + hostNetwork: True +{% if kube_version | version_compare('v1.6', '>=') %} + dnsPolicy: ClusterFirstWithHostNet +{% endif %} + containers: + - name: netchecker-agent + image: "{{ agent_img }}" + env: + - name: MY_POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + args: + - "-v=5" + - "-alsologtostderr=true" + - "-serverendpoint=netchecker-service:8081" + - "-reportinterval={{ agent_report_interval }}" + imagePullPolicy: {{ k8s_image_pull_policy }} + resources: + limits: + cpu: {{ netchecker_agent_cpu_limit }} + memory: {{ netchecker_agent_memory_limit }} + requests: + cpu: {{ netchecker_agent_cpu_requests }} + memory: {{ netchecker_agent_memory_requests }} diff --git a/roles/kubernetes-apps/ansible/templates/netchecker-server-pod.yml b/roles/kubernetes-apps/ansible/templates/netchecker-server-pod.yml.j2 similarity index 100% rename from roles/kubernetes-apps/ansible/templates/netchecker-server-pod.yml rename to roles/kubernetes-apps/ansible/templates/netchecker-server-pod.yml.j2 diff --git a/roles/kubernetes-apps/ansible/templates/netchecker-server-svc.yml b/roles/kubernetes-apps/ansible/templates/netchecker-server-svc.yml.j2 similarity index 100% rename from roles/kubernetes-apps/ansible/templates/netchecker-server-svc.yml rename to roles/kubernetes-apps/ansible/templates/netchecker-server-svc.yml.j2 diff --git a/roles/kubernetes/master/templates/manifests/kube-controller-manager.manifest.j2 b/roles/kubernetes/master/templates/manifests/kube-controller-manager.manifest.j2 index c214719a3..477d6a64f 100644 --- a/roles/kubernetes/master/templates/manifests/kube-controller-manager.manifest.j2 +++ b/roles/kubernetes/master/templates/manifests/kube-controller-manager.manifest.j2 @@ -7,9 +7,9 @@ metadata: k8s-app: kube-controller spec: hostNetwork: true -{%- if kube_version | version_compare('v1.6', '>=') -%} +{% if kube_version | version_compare('v1.6', '>=') %} dnsPolicy: ClusterFirstWithHostNet -{%- endif -%} +{% endif %} containers: - name: kube-controller-manager image: {{ hyperkube_image_repo }}:{{ hyperkube_image_tag }} diff --git a/roles/kubernetes/master/templates/manifests/kube-scheduler.manifest.j2 b/roles/kubernetes/master/templates/manifests/kube-scheduler.manifest.j2 index 77d34288b..7431ddf3d 100644 --- a/roles/kubernetes/master/templates/manifests/kube-scheduler.manifest.j2 +++ b/roles/kubernetes/master/templates/manifests/kube-scheduler.manifest.j2 @@ -7,9 +7,9 @@ metadata: k8s-app: kube-scheduler spec: hostNetwork: true -{%- if kube_version | version_compare('v1.6', '>=') -%} +{% if kube_version | version_compare('v1.6', '>=') %} dnsPolicy: ClusterFirstWithHostNet -{%- endif -%} +{% endif %} containers: - name: kube-scheduler image: {{ hyperkube_image_repo }}:{{ hyperkube_image_tag }} diff --git a/roles/kubernetes/node/templates/manifests/kube-proxy.manifest.j2 b/roles/kubernetes/node/templates/manifests/kube-proxy.manifest.j2 index 2dbcf74d1..745c671d8 100644 --- a/roles/kubernetes/node/templates/manifests/kube-proxy.manifest.j2 +++ b/roles/kubernetes/node/templates/manifests/kube-proxy.manifest.j2 @@ -7,6 +7,9 @@ metadata: k8s-app: kube-proxy spec: hostNetwork: true +{% if kube_version | version_compare('v1.6', '>=') %} + dnsPolicy: ClusterFirstWithHostNet +{% endif %} containers: - name: kube-proxy image: {{ hyperkube_image_repo }}:{{ hyperkube_image_tag }}