summaryrefslogtreecommitdiff
path: root/roles/kubernetes/addons/metrics-server/tasks/main.yml
blob: 0c7fbdccb33c8040a15617051652a4fc90e9b603 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
---
- name: deploy metrics-server addon
  run_once: true
  delegate_to: "{{ groups['_kubernetes_primary_controlplane_node_'] | first }}"
  block:
  - name: create base directory for metrics-server addon
    file:
      path: /etc/kubernetes/addons/metrics-server
      state: directory

    ## you may download these using the following command:
    # wget -O components.{{ kubernetes_metrics_server_version }}.yml  https://github.com/kubernetes-sigs/metrics-server/releases/download/v{{ kubernetes_metrics_server_version }}/components.yaml
  - name: copy base config for metrics-server
    copy:
      src: "components.{{ kubernetes_metrics_server_version }}.yml"
      dest: /etc/kubernetes/addons/metrics-server/upstream.yml

  - name: generate kustomization for metrics-server
    template:
      src: "kustomization.yml.j2"
      dest: /etc/kubernetes/addons/metrics-server/kustomization.yml

  - name: check if metrics-server is already installed
    check_mode: no
    command: kubectl --kubeconfig /etc/kubernetes/admin.conf diff -k /etc/kubernetes/addons/metrics-server
    failed_when: false
    changed_when: false
    register: kube_metrics_server_diff_result

  - debug:
      var: kube_metrics_server_diff_result

  - name: install metrics-server onto the cluster
    when: kube_metrics_server_diff_result.rc != 0
    command: kubectl --kubeconfig /etc/kubernetes/admin.conf apply -k /etc/kubernetes/addons/metrics-server