From e664a0215eeb4c20c9f9870385f2415ed6c317f7 Mon Sep 17 00:00:00 2001 From: okozachenko Date: Thu, 28 May 2020 16:04:38 +0300 Subject: [PATCH] Add addons args in ensure-kubernetes role Minikube provides addons and we can enable specific addons by passing the --addons arg when using minikube cli Change-Id: I8d10e3a3dde1070b5c79406285035dacb59dddc8 --- roles/ensure-kubernetes/README.rst | 5 +++++ roles/ensure-kubernetes/defaults/main.yaml | 1 + roles/ensure-kubernetes/tasks/minikube.yaml | 14 +++++++++++--- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/roles/ensure-kubernetes/README.rst b/roles/ensure-kubernetes/README.rst index aaf75a16d..22348ac92 100644 --- a/roles/ensure-kubernetes/README.rst +++ b/roles/ensure-kubernetes/README.rst @@ -23,3 +23,8 @@ An ansible role to install kubernetes. Which kubernetes runtime to use; values are ``docker`` or ``cri-o``. + +.. zuul:rolevar:: ensure_kubernetes_minikube_addons + :default: [] + + List of addons to configure in k8s. Use this to enable the addons. \ No newline at end of file diff --git a/roles/ensure-kubernetes/defaults/main.yaml b/roles/ensure-kubernetes/defaults/main.yaml index d9cc6f4fb..1bc8767f9 100644 --- a/roles/ensure-kubernetes/defaults/main.yaml +++ b/roles/ensure-kubernetes/defaults/main.yaml @@ -1,4 +1,5 @@ install_kubernetes_with_cluster: True minikube_version: latest minikube_dns_resolvers: [] +ensure_kubernetes_minikube_addons: [] kubernetes_runtime: docker diff --git a/roles/ensure-kubernetes/tasks/minikube.yaml b/roles/ensure-kubernetes/tasks/minikube.yaml index 51e44274f..08361d61c 100644 --- a/roles/ensure-kubernetes/tasks/minikube.yaml +++ b/roles/ensure-kubernetes/tasks/minikube.yaml @@ -38,7 +38,7 @@ - name: Default args set_fact: - minikube_args: "" + extra_args: "" - name: Configure dns options if set block: @@ -49,12 +49,20 @@ mode: "0444" - name: Set extra kube setttings set_fact: - minikube_args: "--extra-config=kubelet.resolv-conf={{ ansible_user_dir }}/.minikube/k8s_resolv.conf" + extra_args: "--extra-config=kubelet.resolv-conf={{ ansible_user_dir }}/.minikube/k8s_resolv.conf" when: minikube_dns_resolvers|length>0 - name: Start Minikube become: yes - command: "/tmp/minikube start --v=7 --vm-driver=none --container-runtime={{ kubernetes_runtime }} {{ minikube_args }}" + command: >- + /tmp/minikube start + --v=7 + --vm-driver=none + --container-runtime={{ kubernetes_runtime }} + {{ extra_args }} + {% for _addon in ensure_kubernetes_minikube_addons %} + --addons={{ _addon }} + {% endfor %} environment: MINIKUBE_WANTUPDATENOTIFICATION: false MINIKUBE_WANTREPORTERRORPROMPT: false