diff options
author | Michal Zegan <m.zegan@samsung.com> | 2019-04-23 16:34:58 +0200 |
---|---|---|
committer | Petr OspalĂ˝ <p.ospaly@partner.samsung.com> | 2019-05-17 08:09:57 +0000 |
commit | 119f760bc517ca037fbbc90bc741902c75c4696c (patch) | |
tree | e91d80624ebee447338721aaaef2820ec19bbf2f | |
parent | fe49ee9006e9396c79f90365b9e814ee70c9fcee (diff) |
Add setup for kubectl and helm
the kubeconfig is copied from the cluster config directory to ~/.kube/config.
Also, the playbook runs kubectl and helm roles to install tools.
Change-Id: I29ee98f6502bbb7923b1ae6812dd642ca206dbce
Issue-ID: OOM-1778
Signed-off-by: Petr OspalĂ˝ <p.ospaly@partner.samsung.com>
Signed-off-by: Michal Zegan <m.zegan@samsung.com>
-rw-r--r-- | ansible/rke.yml | 2 | ||||
-rw-r--r-- | ansible/roles/kubectl/defaults/main.yml | 3 | ||||
-rw-r--r-- | ansible/roles/kubectl/tasks/main.yml | 10 | ||||
-rw-r--r-- | ansible/roles/rancher/defaults/main.yml | 2 | ||||
-rw-r--r-- | ansible/roles/rancher/tasks/rancher_server.yml | 10 | ||||
-rw-r--r-- | ansible/roles/rancher/templates/kube_config.j2 (renamed from ansible/roles/kubectl/templates/kube_config.j2) | 0 | ||||
-rw-r--r-- | ansible/roles/rke/defaults/main.yml | 2 | ||||
-rw-r--r-- | ansible/roles/rke/tasks/rke_deploy.yml | 12 |
8 files changed, 28 insertions, 13 deletions
diff --git a/ansible/rke.yml b/ansible/rke.yml index 81e964d9..e0d6dcf1 100644 --- a/ansible/rke.yml +++ b/ansible/rke.yml @@ -24,3 +24,5 @@ - role: rke vars: mode: deploy + - kubectl + - helm diff --git a/ansible/roles/kubectl/defaults/main.yml b/ansible/roles/kubectl/defaults/main.yml index 78c15c75..b922fb58 100644 --- a/ansible/roles/kubectl/defaults/main.yml +++ b/ansible/roles/kubectl/defaults/main.yml @@ -1,5 +1,2 @@ --- kubectl_bin_dir: /usr/local/bin -kube_directory: ~/.kube -# Defaulting to rancher setup -kube_server: "https://{{ ansible_host }}:8080/r/projects/{{ k8s_env_id | mandatory }}/kubernetes:6443"
\ No newline at end of file diff --git a/ansible/roles/kubectl/tasks/main.yml b/ansible/roles/kubectl/tasks/main.yml index 9ecb5c44..7c77c3c5 100644 --- a/ansible/roles/kubectl/tasks/main.yml +++ b/ansible/roles/kubectl/tasks/main.yml @@ -5,13 +5,3 @@ dest: "{{ kubectl_bin_dir }}/kubectl" remote_src: true mode: 0755 - -- name: Ensure .kube directory exists - file: - path: "{{ kube_directory }}" - state: directory - -- name: Create kube config - template: - src: kube_config.j2 - dest: "{{ kube_directory }}/config" diff --git a/ansible/roles/rancher/defaults/main.yml b/ansible/roles/rancher/defaults/main.yml index 6d354e6e..e4e12d23 100644 --- a/ansible/roles/rancher/defaults/main.yml +++ b/ansible/roles/rancher/defaults/main.yml @@ -4,6 +4,8 @@ rancher_remove_other_env: true rancher_redeploy_k8s_env: true rancher_cluster_health_state: healthy rancher_cluster_health_check_retries: 30 +kube_directory: ~/.kube +kube_server: "https://{{ ansible_host }}:8080/r/projects/{{ k8s_env_id | mandatory }}/kubernetes:6443" rancher: # The following variables can be set via the UI under advanced/settings. # All of these affect tables in the cattle db and are uninteresting diff --git a/ansible/roles/rancher/tasks/rancher_server.yml b/ansible/roles/rancher/tasks/rancher_server.yml index a0893b0b..f467ff3f 100644 --- a/ansible/roles/rancher/tasks/rancher_server.yml +++ b/ansible/roles/rancher/tasks/rancher_server.yml @@ -93,3 +93,13 @@ data: option: audit_log.purge.after.seconds value: "{{ rancher.audit_log_purge_after_seconds }}" + +- name: Ensure .kube directory exists + file: + path: "{{ kube_directory }}" + state: directory + +- name: Create kube config + template: + src: kube_config.j2 + dest: "{{ kube_directory }}/config" diff --git a/ansible/roles/kubectl/templates/kube_config.j2 b/ansible/roles/rancher/templates/kube_config.j2 index 586c59d4..586c59d4 100644 --- a/ansible/roles/kubectl/templates/kube_config.j2 +++ b/ansible/roles/rancher/templates/kube_config.j2 diff --git a/ansible/roles/rke/defaults/main.yml b/ansible/roles/rke/defaults/main.yml index 3e1c26a6..cbf03b74 100644 --- a/ansible/roles/rke/defaults/main.yml +++ b/ansible/roles/rke/defaults/main.yml @@ -2,8 +2,10 @@ rke_binary: rke rke_username: rke rke_bin_dir: /usr/local/bin +kube_config_dir: "{{ ansible_env.HOME }}/.kube" cluster_config_dir: "{{ app_data_path }}/cluster" rke: + # rke (rancher) images etcd: rancher/coreos-etcd:v3.2.24-rancher1 alpine: rancher/rke-tools:v0.1.27 nginx_proxy: rancher/rke-tools:v0.1.27 diff --git a/ansible/roles/rke/tasks/rke_deploy.yml b/ansible/roles/rke/tasks/rke_deploy.yml index 7b3e2510..9983d08a 100644 --- a/ansible/roles/rke/tasks/rke_deploy.yml +++ b/ansible/roles/rke/tasks/rke_deploy.yml @@ -3,3 +3,15 @@ command: "{{ rke_bin_dir }}/rke up --config cluster.yml" args: chdir: "{{ cluster_config_dir }}" + +- name: Ensure .kube directory is present + file: + path: "{{ kube_config_dir }}" + state: directory + +- name: Setup kubeconfig + copy: + src: "{{ cluster_config_dir }}/kube_config_cluster.yml" + dest: "{{ kube_config_dir }}/config" + remote_src: true + mode: 0755 |