From fc7905653e32b7e951a7a36f287b827fd537fe0d Mon Sep 17 00:00:00 2001
From: Matthew Mosesohn <mmosesohn@mirantis.com>
Date: Mon, 4 Sep 2017 11:30:18 +0300
Subject: [PATCH] Add socat for CoreOS when using host deploy kubelet (#1575)

---
 roles/download/defaults/main.yml             | 7 +++++++
 roles/kubernetes/node/meta/main.yml          | 6 +++++-
 roles/kubernetes/node/tasks/install_host.yml | 6 ++++++
 3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/roles/download/defaults/main.yml b/roles/download/defaults/main.yml
index 25a335915..2c4000866 100644
--- a/roles/download/defaults/main.yml
+++ b/roles/download/defaults/main.yml
@@ -60,6 +60,8 @@ hyperkube_image_repo: "quay.io/coreos/hyperkube"
 hyperkube_image_tag: "{{ kube_version }}_coreos.0"
 pod_infra_image_repo: "gcr.io/google_containers/pause-amd64"
 pod_infra_image_tag: "{{ pod_infra_version }}"
+install_socat_image_repo: "xueshanf/install-socat"
+install_socat_image_tag: "latest"
 netcheck_version: "v1.0"
 netcheck_agent_img_repo: "quay.io/l23network/k8s-netchecker-agent"
 netcheck_agent_tag: "{{ netcheck_version }}"
@@ -194,6 +196,11 @@ downloads:
     repo: "{{ pod_infra_image_repo }}"
     tag: "{{ pod_infra_image_tag }}"
     sha256: "{{ pod_infra_digest_checksum|default(None) }}"
+  install_socat:
+    container: true
+    repo: "{{ install_socat_image_repo }}"
+    tag: "{{ install_socat_image_tag }}"
+    sha256: "{{ install_socat_digest_checksum|default(None) }}"
   nginx:
     container: true
     repo: "{{ nginx_image_repo }}"
diff --git a/roles/kubernetes/node/meta/main.yml b/roles/kubernetes/node/meta/main.yml
index 12a7d73b7..f0656e571 100644
--- a/roles/kubernetes/node/meta/main.yml
+++ b/roles/kubernetes/node/meta/main.yml
@@ -6,6 +6,10 @@ dependencies:
   - role: download
     file: "{{ downloads.pod_infra }}"
     tags: [download, kubelet]
+  - role: download
+    file: "{{ downloads.install_socat }}"
+    tags: [download, kubelet]
+    when: ansible_os_family in ['CoreOS', 'Container Linux by CoreOS']
   - role: kubernetes/secrets
     tags: k8s-secrets
   - role: download
@@ -33,4 +37,4 @@ dependencies:
     tags: [download, dnsmasq]
   - role: download
     file: "{{ downloads.kubednsautoscaler }}"
-    tags: [download, dnsmasq]
\ No newline at end of file
+    tags: [download, dnsmasq]
diff --git a/roles/kubernetes/node/tasks/install_host.yml b/roles/kubernetes/node/tasks/install_host.yml
index e80b20498..9f1523ffe 100644
--- a/roles/kubernetes/node/tasks/install_host.yml
+++ b/roles/kubernetes/node/tasks/install_host.yml
@@ -8,3 +8,9 @@
   changed_when: false
   tags: [hyperkube, upgrade]
   notify: restart kubelet
+
+- name: install | Copy socat wrapper for Container Linux
+  command: "{{ docker_bin_dir }}/docker run --rm -v {{ bin_dir }}:/opt/bin {{ install_socat_image_repo }}:{{ install_socat_image_tag }}"
+  args:
+    creates: "{{ bin_dir }}/socat"
+  when: ansible_os_family in ['CoreOS', 'Container Linux by CoreOS']
-- 
GitLab