c12s-kubespray/roles/kubernetes/client/tasks/main.yml
Matthew Mosesohn a43e0d3f95 Switch to Kubernetes v1.16.0 (#5189)
* Switch to Kubernetes v1.16.0

Change-Id: I5d6a9528b2d443750fc5e031aff15ad3ffead158

* Fix download localhost cached file path

Change-Id: I65e79b70e3d1b37265ebc60f41b460cf4b0a0d47

* fix kubeadm etcd for v1.16

Change-Id: I6888a00fd48b530a38b0b31c4095492476af42d2

* disable tf packet jobs

Change-Id: I075c4666547fdea4c50ec04864f38e2cfaa79154

* Disable contiv packet jobs. Fix kube-router

Change-Id: I3170e8789e60711d4cee8faf65f2094480b79b8d

* bump sonobuoy version

Change-Id: Ib946905629c7c53ed88f08fb2f41c454457a0097
2019-10-02 02:21:07 -07:00

94 lines
2.8 KiB
YAML

---
- name: Set external kube-apiserver endpoint
set_fact:
external_apiserver_address: >-
{%- if loadbalancer_apiserver is defined and loadbalancer_apiserver.address is defined -%}
{{ loadbalancer_apiserver.address }}
{%- else -%}
{{ kube_apiserver_access_address }}
{%- endif -%}
external_apiserver_port: >-
{%- if loadbalancer_apiserver is defined and loadbalancer_apiserver.address is defined and loadbalancer_apiserver.port is defined -%}
{{ loadbalancer_apiserver.port|default(kube_apiserver_port) }}
{%- else -%}
{{ kube_apiserver_port }}
{%- endif -%}
tags:
- facts
- name: Create kube config dir for current/ansible become user
file:
path: "{{ ansible_env.HOME | default('/root') }}/.kube"
mode: "0700"
state: directory
- name: Copy admin kubeconfig to current/ansible become user home
copy:
src: "{{ kube_config_dir }}/admin.conf"
dest: "{{ ansible_env.HOME | default('/root') }}/.kube/config"
remote_src: yes
mode: "0600"
backup: yes
- name: Create kube artifacts dir
file:
path: "{{ artifacts_dir }}"
mode: "0750"
state: directory
delegate_to: localhost
become: no
run_once: yes
when: kubeconfig_localhost|default(false)
- name: Wait for k8s apiserver
wait_for:
host: "{{ kube_apiserver_access_address }}"
port: "{{ kube_apiserver_port }}"
timeout: 180
# NOTE(mattymo): Please forgive this workaround
- name: Generate admin kubeconfig with external api endpoint
shell: >-
mkdir -p {{ kube_config_dir }}/external_kubeconfig &&
{{ bin_dir }}/kubeadm
init phase
kubeconfig admin
--kubeconfig-dir {{ kube_config_dir }}/external_kubeconfig
--cert-dir {{ kube_cert_dir }}
--apiserver-advertise-address {{ external_apiserver_address }}
--apiserver-bind-port {{ external_apiserver_port }}
>/dev/null && cat {{ kube_config_dir }}/external_kubeconfig/admin.conf &&
rm -rf {{ kube_config_dir }}/external_kubeconfig
environment: "{{ proxy_env }}"
run_once: yes
register: admin_kubeconfig
- name: Write admin kubeconfig on ansible host
copy:
content: "{{ admin_kubeconfig.stdout }}"
dest: "{{ artifacts_dir }}/admin.conf"
mode: 0640
delegate_to: localhost
become: no
run_once: yes
when: kubeconfig_localhost|default(false)
- name: Copy kubectl binary to ansible host
synchronize:
src: "{{ bin_dir }}/kubectl"
dest: "{{ artifacts_dir }}/kubectl"
become: no
run_once: yes
when: kubectl_localhost|default(false)
- name: create helper script kubectl.sh on ansible host
copy:
content: |
#!/bin/bash
${BASH_SOURCE%/*}/kubectl --kubeconfig=${BASH_SOURCE%/*}/admin.conf $@
dest: "{{ artifacts_dir }}/kubectl.sh"
mode: 0755
become: no
run_once: yes
delegate_to: localhost
when: kubectl_localhost|default(false) and kubeconfig_localhost|default(false)