From 2ab365825f0b64ff5426be2b8a8662b43e83de9b Mon Sep 17 00:00:00 2001 From: Sergii Golovatiuk Date: Fri, 14 Apr 2017 10:49:16 +0200 Subject: [PATCH] Reschedule netchecker-server in case of HW failure. Pod opbject is not reschedulable by kubernetes. It means that if node with netchecker-server goes down, netchecker-server won't be scheduled somewhere. This commit changes the type of netchecker-server to Deployment, so netchecker-server will be scheduled on other nodes in case of failures. --- .../ansible/tasks/netchecker.yml | 2 +- .../netchecker-server-deployment.yml.j2 | 33 +++++++++++++++++++ .../templates/netchecker-server-pod.yml.j2 | 28 ---------------- 3 files changed, 34 insertions(+), 29 deletions(-) create mode 100644 roles/kubernetes-apps/ansible/templates/netchecker-server-deployment.yml.j2 delete mode 100644 roles/kubernetes-apps/ansible/templates/netchecker-server-pod.yml.j2 diff --git a/roles/kubernetes-apps/ansible/tasks/netchecker.yml b/roles/kubernetes-apps/ansible/tasks/netchecker.yml index b9047a1e2..aae75d091 100644 --- a/roles/kubernetes-apps/ansible/tasks/netchecker.yml +++ b/roles/kubernetes-apps/ansible/tasks/netchecker.yml @@ -5,7 +5,7 @@ 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-pod.yml.j2, type: po, 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] diff --git a/roles/kubernetes-apps/ansible/templates/netchecker-server-deployment.yml.j2 b/roles/kubernetes-apps/ansible/templates/netchecker-server-deployment.yml.j2 new file mode 100644 index 000000000..6c52352fb --- /dev/null +++ b/roles/kubernetes-apps/ansible/templates/netchecker-server-deployment.yml.j2 @@ -0,0 +1,33 @@ +apiVersion: apps/v1beta1 +kind: Deployment +metadata: + name: netchecker-server +spec: + replicas: 1 + template: + metadata: + name: netchecker-server + labels: + app: netchecker-server + namespace: {{ netcheck_namespace }} + spec: + containers: + - name: netchecker-server + image: "{{ server_img }}" + env: + imagePullPolicy: {{ k8s_image_pull_policy }} + resources: + limits: + cpu: {{ netchecker_server_cpu_limit }} + memory: {{ netchecker_server_memory_limit }} + requests: + cpu: {{ netchecker_server_cpu_requests }} + memory: {{ netchecker_server_memory_requests }} + ports: + - containerPort: 8081 + hostPort: 8081 + args: + - "-v=5" + - "-logtostderr" + - "-kubeproxyinit" + - "-endpoint=0.0.0.0:8081" diff --git a/roles/kubernetes-apps/ansible/templates/netchecker-server-pod.yml.j2 b/roles/kubernetes-apps/ansible/templates/netchecker-server-pod.yml.j2 deleted file mode 100644 index 06aea406a..000000000 --- a/roles/kubernetes-apps/ansible/templates/netchecker-server-pod.yml.j2 +++ /dev/null @@ -1,28 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - name: netchecker-server - labels: - app: netchecker-server - namespace: {{ netcheck_namespace }} -spec: - containers: - - name: netchecker-server - image: "{{ server_img }}" - env: - imagePullPolicy: {{ k8s_image_pull_policy }} - resources: - limits: - cpu: {{ netchecker_server_cpu_limit }} - memory: {{ netchecker_server_memory_limit }} - requests: - cpu: {{ netchecker_server_cpu_requests }} - memory: {{ netchecker_server_memory_requests }} - ports: - - containerPort: 8081 - hostPort: 8081 - args: - - "-v=5" - - "-logtostderr" - - "-kubeproxyinit" - - "-endpoint=0.0.0.0:8081"