summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Shrewsbury <shrewsbury.dave@gmail.com>2018-09-27 13:57:50 -0400
committerDavid Shrewsbury <shrewsbury.dave@gmail.com>2018-10-31 15:49:20 -0400
commit230a0f6cc2e483aca5789929ab0bd06b38454099 (patch)
tree6394acf39792bff5a2aa153a3cfdaa48ddb56b83
parenta01a13e49b6b3b254faf20383a9c04e50378f4e9 (diff)
Add role to install kubernetes
Optionally, and by default, installs a Minikube cluster that runs locally. Change-Id: Ie6d0b73e6b3bdb77eee133a5f663133fd037aba0
Notes
Notes (review): Code-Review+2: Andreas Jaeger <jaegerandi@gmail.com> Code-Review+2: Tobias Henkel <tobias.henkel@bmw.de> Workflow+1: Tobias Henkel <tobias.henkel@bmw.de> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Mon, 05 Nov 2018 12:48:55 +0000 Reviewed-on: https://review.openstack.org/605823 Project: openstack-infra/zuul-jobs Branch: refs/heads/master
-rw-r--r--roles/install-kubernetes/README.rst8
-rw-r--r--roles/install-kubernetes/defaults/main.yaml1
-rw-r--r--roles/install-kubernetes/tasks/main.yaml21
-rw-r--r--roles/install-kubernetes/tasks/minikube.yaml48
4 files changed, 78 insertions, 0 deletions
diff --git a/roles/install-kubernetes/README.rst b/roles/install-kubernetes/README.rst
new file mode 100644
index 0000000..ea0d962
--- /dev/null
+++ b/roles/install-kubernetes/README.rst
@@ -0,0 +1,8 @@
1An ansible role to install kubernetes.
2
3**Role Variables**
4
5.. zuul:rolevar:: install_kubernetes_with_cluster
6 :default: True
7
8 If true, installs a Minikube cluster.
diff --git a/roles/install-kubernetes/defaults/main.yaml b/roles/install-kubernetes/defaults/main.yaml
new file mode 100644
index 0000000..19ff90d
--- /dev/null
+++ b/roles/install-kubernetes/defaults/main.yaml
@@ -0,0 +1 @@
install_kubernetes_with_cluster: True
diff --git a/roles/install-kubernetes/tasks/main.yaml b/roles/install-kubernetes/tasks/main.yaml
new file mode 100644
index 0000000..445f71c
--- /dev/null
+++ b/roles/install-kubernetes/tasks/main.yaml
@@ -0,0 +1,21 @@
1- name: Install apt key
2 become: yes
3 apt_key:
4 url: "https://packages.cloud.google.com/apt/doc/apt-key.gpg"
5 state: present
6
7- name: Add kubernetes repo
8 become: yes
9 apt_repository:
10 repo: deb http://apt.kubernetes.io/ kubernetes-xenial main
11 state: present
12
13- name: Install kubernetes packages
14 become: yes
15 apt:
16 name: kubectl
17 update_cache: yes
18
19- name: Run cluster tasks
20 include_tasks: minikube.yaml
21 when: install_kubernetes_with_cluster
diff --git a/roles/install-kubernetes/tasks/minikube.yaml b/roles/install-kubernetes/tasks/minikube.yaml
new file mode 100644
index 0000000..d0c2f50
--- /dev/null
+++ b/roles/install-kubernetes/tasks/minikube.yaml
@@ -0,0 +1,48 @@
1- name: Check for Minikube install
2 stat:
3 path: /tmp/minikube
4 register: stat_result
5
6- name: Download Minikube
7 get_url:
8 url: https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
9 dest: /tmp/minikube
10 mode: 0755
11 when: stat_result.stat.exists == False
12
13- name: Run install-docker role
14 include_role:
15 name: install-docker
16
17- name: Create .kube directory
18 file:
19 path: "{{ ansible_user_dir }}/.kube"
20 state: directory
21 mode: 0755
22
23- name: Create .kube/config file
24 file:
25 path: "{{ ansible_user_dir }}/.kube/config"
26 state: touch
27 mode: 0644
28
29- name: Create .minikube directory
30 file:
31 path: "{{ ansible_user_dir }}/.minikube"
32 state: directory
33 mode: 0755
34
35- name: Start Minikube
36 become: yes
37 command: /tmp/minikube --vm-driver=none start
38 environment:
39 MINIKUBE_WANTUPDATENOTIFICATION: false
40 MINIKUBE_WANTREPORTERRORPROMPT: false
41 MINIKUBE_WANTNONEDRIVERWARNING: false
42 MINIKUBE_WANTKUBECTLDOWNLOADMSG: false
43 CHANGE_MINIKUBE_NONE_USER: true
44 MINIKUBE_HOME: "{{ ansible_user_dir }}"
45 KUBECONFIG: "{{ ansible_user_dir }}/.kube/config"
46
47- name: Get cluster info
48 command: kubectl cluster-info