diff options
author | Christian Pointner <equinox@spreadspace.org> | 2023-03-12 03:38:19 +0100 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2023-03-12 03:38:19 +0100 |
commit | ce5ce9fc80c81a059243db830d3df992813d332f (patch) | |
tree | 638120bbe7e9124fb08cfedafda4024e2c0bf701 /roles/kubernetes/addons | |
parent | kubernetes/addon/cert-amanger: convert to kustomize (diff) |
kubernetes/addon/metrics-server: convert to kustomize
Diffstat (limited to 'roles/kubernetes/addons')
-rw-r--r-- | roles/kubernetes/addons/metrics-server/files/components.0.6.1.yml (renamed from roles/kubernetes/addons/metrics-server/templates/components.0.6.1.yml.j2) | 3 | ||||
-rw-r--r-- | roles/kubernetes/addons/metrics-server/files/components.0.6.2.yml (renamed from roles/kubernetes/addons/metrics-server/templates/components.0.6.2.yml.j2) | 3 | ||||
-rw-r--r-- | roles/kubernetes/addons/metrics-server/tasks/main.yml | 20 | ||||
-rw-r--r-- | roles/kubernetes/addons/metrics-server/templates/kustomization.yml.j2 | 15 |
4 files changed, 32 insertions, 9 deletions
diff --git a/roles/kubernetes/addons/metrics-server/templates/components.0.6.1.yml.j2 b/roles/kubernetes/addons/metrics-server/files/components.0.6.1.yml index d99a9d7c..81296ded 100644 --- a/roles/kubernetes/addons/metrics-server/templates/components.0.6.1.yml.j2 +++ b/roles/kubernetes/addons/metrics-server/files/components.0.6.1.yml @@ -134,11 +134,10 @@ spec: - args: - --cert-dir=/tmp - --secure-port=4443 - - --kubelet-insecure-tls - --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname - --kubelet-use-node-status-port - --metric-resolution=15s - image: registry.k8s.io/metrics-server/metrics-server:v0.6.1 + image: k8s.gcr.io/metrics-server/metrics-server:v0.6.1 imagePullPolicy: IfNotPresent livenessProbe: failureThreshold: 3 diff --git a/roles/kubernetes/addons/metrics-server/templates/components.0.6.2.yml.j2 b/roles/kubernetes/addons/metrics-server/files/components.0.6.2.yml index bedbd9cc..b1787ae4 100644 --- a/roles/kubernetes/addons/metrics-server/templates/components.0.6.2.yml.j2 +++ b/roles/kubernetes/addons/metrics-server/files/components.0.6.2.yml @@ -134,11 +134,10 @@ spec: - args: - --cert-dir=/tmp - --secure-port=4443 - - --kubelet-insecure-tls - --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname - --kubelet-use-node-status-port - --metric-resolution=15s - image: registry.k8s.io/metrics-server/metrics-server:v0.6.2 + image: k8s.gcr.io/metrics-server/metrics-server:v0.6.2 imagePullPolicy: IfNotPresent livenessProbe: failureThreshold: 3 diff --git a/roles/kubernetes/addons/metrics-server/tasks/main.yml b/roles/kubernetes/addons/metrics-server/tasks/main.yml index 79bf1cf1..0c7fbdcc 100644 --- a/roles/kubernetes/addons/metrics-server/tasks/main.yml +++ b/roles/kubernetes/addons/metrics-server/tasks/main.yml @@ -8,18 +8,28 @@ path: /etc/kubernetes/addons/metrics-server state: directory - - name: copy config for metrics-server + ## 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: "components.{{ kubernetes_metrics_server_version }}.yml.j2" - dest: /etc/kubernetes/addons/metrics-server/config.yml + 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 -f /etc/kubernetes/addons/metrics-server/config.yml + 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 -f /etc/kubernetes/addons/metrics-server/config.yml + command: kubectl --kubeconfig /etc/kubernetes/admin.conf apply -k /etc/kubernetes/addons/metrics-server diff --git a/roles/kubernetes/addons/metrics-server/templates/kustomization.yml.j2 b/roles/kubernetes/addons/metrics-server/templates/kustomization.yml.j2 new file mode 100644 index 00000000..536dac9b --- /dev/null +++ b/roles/kubernetes/addons/metrics-server/templates/kustomization.yml.j2 @@ -0,0 +1,15 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - upstream.yml + +patches: + - target: + kind: Deployment + namespace: kube-system + name: metrics-server + patch: |- + - op: add + path: /spec/template/spec/containers/0/args/- + value: '--kubelet-insecure-tls' |