From 54c48ccd3caa038632c4d43b5a71a37ce91a0f8b Mon Sep 17 00:00:00 2001 From: Srinivasan Selvam Date: Thu, 21 May 2020 00:39:46 +0530 Subject: [PATCH] cadvisor pod using kubectl commands added cadvisor using helm removed Signed-off-by: Srinivasan Selvam Change-Id: I32047eff773737c061164e8a3af3809a0c6041a1 --- ocd/infra/playbooks/ealt-all-uninstall.yml | 2 +- ocd/infra/playbooks/ealt-all.yml | 1 + .../playbooks/roles/cAdvisor/files/values.yaml | 3 - .../playbooks/roles/cAdvisor/tasks/install.yml | 48 ------------ ocd/infra/playbooks/roles/cadvisor/files/dep.yaml | 91 ++++++++++++++++++++++ .../playbooks/roles/cadvisor/tasks/install.yml | 24 ++++++ .../roles/{cAdvisor => cadvisor}/tasks/main.yml | 0 .../{cAdvisor => cadvisor}/tasks/uninstall.yml | 25 ++---- 8 files changed, 124 insertions(+), 70 deletions(-) delete mode 100644 ocd/infra/playbooks/roles/cAdvisor/files/values.yaml delete mode 100644 ocd/infra/playbooks/roles/cAdvisor/tasks/install.yml create mode 100644 ocd/infra/playbooks/roles/cadvisor/files/dep.yaml create mode 100644 ocd/infra/playbooks/roles/cadvisor/tasks/install.yml rename ocd/infra/playbooks/roles/{cAdvisor => cadvisor}/tasks/main.yml (100%) rename ocd/infra/playbooks/roles/{cAdvisor => cadvisor}/tasks/uninstall.yml (62%) diff --git a/ocd/infra/playbooks/ealt-all-uninstall.yml b/ocd/infra/playbooks/ealt-all-uninstall.yml index 4ca3365..fd60c20 100644 --- a/ocd/infra/playbooks/ealt-all-uninstall.yml +++ b/ocd/infra/playbooks/ealt-all-uninstall.yml @@ -32,7 +32,7 @@ roles: - rabbitmq - - cAdvisor + - cadvisor - prometheus - helm - k3s diff --git a/ocd/infra/playbooks/ealt-all.yml b/ocd/infra/playbooks/ealt-all.yml index 1e7964a..43a6ef9 100644 --- a/ocd/infra/playbooks/ealt-all.yml +++ b/ocd/infra/playbooks/ealt-all.yml @@ -69,6 +69,7 @@ - rabbitmq - prometheus - kubeconfig + - cadvisor - hosts: mepautomate become: yes diff --git a/ocd/infra/playbooks/roles/cAdvisor/files/values.yaml b/ocd/infra/playbooks/roles/cAdvisor/files/values.yaml deleted file mode 100644 index a27be11..0000000 --- a/ocd/infra/playbooks/roles/cAdvisor/files/values.yaml +++ /dev/null @@ -1,3 +0,0 @@ -image: - repository: unibaktr/cadvisor - tag: v0.36.0 diff --git a/ocd/infra/playbooks/roles/cAdvisor/tasks/install.yml b/ocd/infra/playbooks/roles/cAdvisor/tasks/install.yml deleted file mode 100644 index 8c49f6a..0000000 --- a/ocd/infra/playbooks/roles/cAdvisor/tasks/install.yml +++ /dev/null @@ -1,48 +0,0 @@ -# Copyright 2020 Huawei Technologies Co., Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - ---- -- name: check if cadvisor is already installed - shell: - cmd: helm status cadvisor - register: result - failed_when: false - no_log: True - -- debug: - msg: cAdvisor is already present - when: result.rc == 0 - -- meta: end_play - when: result.rc == 0 - -- name: "Add helm repo" - command: helm repo add code-chris https://code-chris.github.io/helm-charts - when: result is failed - -- name: "Update helm repo" - command: helm repo update - when: result is failed - -- name: copy values.yaml to host - copy: - src: values.yaml - dest: /tmp/cAdvisor/ - when: result is failed - -- name: "Installing cAdvisor" -# yamllint disable rule:line-length - command: helm install cadvisor code-chris/cadvisor -f /tmp/cAdvisor/values.yaml -# yamllint disable rule:line-length - when: result is failed diff --git a/ocd/infra/playbooks/roles/cadvisor/files/dep.yaml b/ocd/infra/playbooks/roles/cadvisor/files/dep.yaml new file mode 100644 index 0000000..aaf38b4 --- /dev/null +++ b/ocd/infra/playbooks/roles/cadvisor/files/dep.yaml @@ -0,0 +1,91 @@ +# Copyright 2020 Huawei Technologies Co., Ltd. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +# cadvisor pod +--- +apiVersion: v1 +kind: Pod +metadata: + name: cadvisor + namespace: default + labels: + app: cadvisor + annotations: + seccomp.security.alpha.kubernetes.io/pod: 'docker/default' +spec: + containers: + - image: unibaktr/cadvisor:v0.36.0 + imagePullPolicy: Always + name: cadvisor-pod + ports: + - containerPort: 8080 + hostPort: 8081 + protocol: TCP + resources: + requests: + memory: 200Mi + cpu: 150m + limits: + memory: 2000Mi + cpu: 300m + volumeMounts: + - mountPath: /rootfs + name: rootfs + readOnly: true + # yamllint disable-line rule:key-duplicates + volumeMounts: + - mountPath: /var/run + name: varrun + readOnly: true + # yamllint disable-line rule:key-duplicates + volumeMounts: + - mountPath: /sys + name: sys + readOnly: true + # yamllint disable-line rule:key-duplicates + volumeMounts: + - mountPath: /var/lib/docker + name: varlibdocker + readOnly: true + # yamllint disable-line rule:key-duplicates + volumeMounts: + - mountPath: /dev/disk + name: devdisk + readOnly: true + terminationGracePeriodSeconds: 30 + volumes: + - name: rootfs + hostPath: + path: / + # yamllint disable-line rule:key-duplicates + volumes: + - name: varrun + hostPath: + path: /var/run + # yamllint disable-line rule:key-duplicates + volumes: + - name: sys + hostPath: + path: /sys + # yamllint disable-line rule:key-duplicates + volumes: + - name: varlibdocker + hostPath: + path: /var/lib/docker + # yamllint disable-line rule:key-duplicates + volumes: + - name: devdisk + hostPath: + path: /dev/disk diff --git a/ocd/infra/playbooks/roles/cadvisor/tasks/install.yml b/ocd/infra/playbooks/roles/cadvisor/tasks/install.yml new file mode 100644 index 0000000..e6ead6c --- /dev/null +++ b/ocd/infra/playbooks/roles/cadvisor/tasks/install.yml @@ -0,0 +1,24 @@ +# Copyright 2020 Huawei Technologies Co., Ltd. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- +- name: copy deploy folder to mep node to install mepserver + copy: + src: dep.yaml + dest: /tmp/cadvisor/ + +- name: Installation of cadvisor + shell: + cmd: kubectl apply -f /tmp/cadvisor/dep.yaml + ignore_errors: 'True' diff --git a/ocd/infra/playbooks/roles/cAdvisor/tasks/main.yml b/ocd/infra/playbooks/roles/cadvisor/tasks/main.yml similarity index 100% rename from ocd/infra/playbooks/roles/cAdvisor/tasks/main.yml rename to ocd/infra/playbooks/roles/cadvisor/tasks/main.yml diff --git a/ocd/infra/playbooks/roles/cAdvisor/tasks/uninstall.yml b/ocd/infra/playbooks/roles/cadvisor/tasks/uninstall.yml similarity index 62% rename from ocd/infra/playbooks/roles/cAdvisor/tasks/uninstall.yml rename to ocd/infra/playbooks/roles/cadvisor/tasks/uninstall.yml index 53a7e62..93e6b7d 100644 --- a/ocd/infra/playbooks/roles/cAdvisor/tasks/uninstall.yml +++ b/ocd/infra/playbooks/roles/cadvisor/tasks/uninstall.yml @@ -13,25 +13,14 @@ # limitations under the License. --- - -- name: check if cadvisor is installed before deleting +- name: check if cadvisor is installed before removing shell: - cmd: helm status cadvisor + cmd: kubectl get pods | grep cadvisor register: result - failed_when: false - no_log: True - -- debug: - msg: cAdvisor is not present - when: result.rc == 2 - -- meta: end_play - when: result.rc == 2 + ignore_errors: 'True' -- name: "If cAdvisor present, then list helm ls" - command: helm ls - when: result is succeeded - -- name: "Uninstall cadvisor" - command: helm delete cadvisor +- name: Uninstallation of cadvisor + shell: + cmd: kubectl delete -f /tmp/cadvisor/dep.yaml when: result is succeeded + ignore_errors: 'True' -- 2.16.6