cadvisor pod using kubectl commands added 94/3494/1
authorSrinivasan Selvam <srinivasan.s.n@huawei.com>
Wed, 20 May 2020 19:09:46 +0000 (00:39 +0530)
committerSrinivasan Selvam <srinivasan.s.n@huawei.com>
Wed, 20 May 2020 19:11:06 +0000 (00:41 +0530)
cadvisor using helm removed

Signed-off-by: Srinivasan Selvam <srinivasan.s.n@huawei.com>
Change-Id: I32047eff773737c061164e8a3af3809a0c6041a1

ocd/infra/playbooks/ealt-all-uninstall.yml
ocd/infra/playbooks/ealt-all.yml
ocd/infra/playbooks/roles/cAdvisor/files/values.yaml [deleted file]
ocd/infra/playbooks/roles/cAdvisor/tasks/install.yml [deleted file]
ocd/infra/playbooks/roles/cadvisor/files/dep.yaml [new file with mode: 0644]
ocd/infra/playbooks/roles/cadvisor/tasks/install.yml [new file with mode: 0644]
ocd/infra/playbooks/roles/cadvisor/tasks/main.yml [moved from ocd/infra/playbooks/roles/cAdvisor/tasks/main.yml with 100% similarity]
ocd/infra/playbooks/roles/cadvisor/tasks/uninstall.yml [moved from ocd/infra/playbooks/roles/cAdvisor/tasks/uninstall.yml with 62% similarity]

index 4ca3365..fd60c20 100644 (file)
@@ -32,7 +32,7 @@
 
   roles:
   - rabbitmq
-  - cAdvisor
+  - cadvisor
   - prometheus
   - helm
   - k3s
index 1e7964a..43a6ef9 100644 (file)
@@ -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 (file)
index a27be11..0000000
+++ /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 (file)
index 8c49f6a..0000000
+++ /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 (file)
index 0000000..aaf38b4
--- /dev/null
@@ -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 (file)
index 0000000..e6ead6c
--- /dev/null
@@ -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'
 # 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'