Set ClusterFirstWithHostNet for Pods with hostnetwork: true

In kubernetes 1.6 ClusterFirstWithHostNet was added as an option. In
accordance to it kubelet will generate resolv.conf based on own
resolv.conf. However, this doesn't create 'options', thus the proper
solution requires some investigation.

This patch sets the same resolv.conf for kubelet as host

Signed-off-by: Sergii Golovatiuk <sgolovatiuk@mirantis.com>
This commit is contained in:
Sergii Golovatiuk 2017-03-28 16:33:07 +02:00
parent aaf272dbcd
commit 829b0948a3
6 changed files with 14 additions and 1 deletions

View file

@ -4,7 +4,7 @@
dest: "{{kube_config_dir}}/{{item.file}}" dest: "{{kube_config_dir}}/{{item.file}}"
with_items: with_items:
- {file: netchecker-agent-ds.yml, type: ds, name: netchecker-agent} - {file: netchecker-agent-ds.yml, type: ds, name: netchecker-agent}
- {file: netchecker-agent-hostnet-ds.yml, type: ds, name: netchecker-agent-hostnet} - {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-pod.yml, type: po, name: netchecker-server}
- {file: netchecker-server-svc.yml, type: svc, name: netchecker-service} - {file: netchecker-server-svc.yml, type: svc, name: netchecker-service}
register: manifests register: manifests

View file

@ -13,6 +13,9 @@ spec:
app: netchecker-agent-hostnet app: netchecker-agent-hostnet
spec: spec:
hostNetwork: True hostNetwork: True
{%- if kube_version | version_compare('v1.6', '>=') -%}
dnsPolicy: ClusterFirstWithHostNet
{%- endif -%}
containers: containers:
- name: netchecker-agent - name: netchecker-agent
image: "{{ agent_img }}" image: "{{ agent_img }}"

View file

@ -8,6 +8,9 @@ metadata:
kargo: v2 kargo: v2
spec: spec:
hostNetwork: true hostNetwork: true
{% if kube_version | version_compare('v1.6', '>=') %}
dnsPolicy: ClusterFirstWithHostNet
{% endif %}
containers: containers:
- name: kube-apiserver - name: kube-apiserver
image: {{ hyperkube_image_repo }}:{{ hyperkube_image_tag }} image: {{ hyperkube_image_repo }}:{{ hyperkube_image_tag }}

View file

@ -7,6 +7,9 @@ metadata:
k8s-app: kube-controller k8s-app: kube-controller
spec: spec:
hostNetwork: true hostNetwork: true
{%- if kube_version | version_compare('v1.6', '>=') -%}
dnsPolicy: ClusterFirstWithHostNet
{%- endif -%}
containers: containers:
- name: kube-controller-manager - name: kube-controller-manager
image: {{ hyperkube_image_repo }}:{{ hyperkube_image_tag }} image: {{ hyperkube_image_repo }}:{{ hyperkube_image_tag }}

View file

@ -7,6 +7,9 @@ metadata:
k8s-app: kube-scheduler k8s-app: kube-scheduler
spec: spec:
hostNetwork: true hostNetwork: true
{%- if kube_version | version_compare('v1.6', '>=') -%}
dnsPolicy: ClusterFirstWithHostNet
{%- endif -%}
containers: containers:
- name: kube-scheduler - name: kube-scheduler
image: {{ hyperkube_image_repo }}:{{ hyperkube_image_tag }} image: {{ hyperkube_image_repo }}:{{ hyperkube_image_tag }}

View file

@ -11,6 +11,7 @@
-v /etc/cni:/etc/cni:ro \ -v /etc/cni:/etc/cni:ro \
-v /opt/cni:/opt/cni:ro \ -v /opt/cni:/opt/cni:ro \
-v /etc/ssl:/etc/ssl:ro \ -v /etc/ssl:/etc/ssl:ro \
-v /etc/resolv.conf:/etc/resolv.conf \
{% for dir in ssl_ca_dirs -%} {% for dir in ssl_ca_dirs -%}
-v {{ dir }}:{{ dir }}:ro \ -v {{ dir }}:{{ dir }}:ro \
{% endfor -%} {% endfor -%}