Sfoglia il codice sorgente

monitoring resources

Grega Bremec 7 mesi fa
parent
commit
8e13f90e12

+ 63 - 0
labs/monitoring/apps/account-app.yaml

@@ -0,0 +1,63 @@
+apiVersion: v1
+kind: List
+metadata: {}
+items:
+- apiVersion: apps/v1
+  kind: Deployment
+  metadata:
+    creationTimestamp: null
+    labels:
+      app: frontend
+    name: frontend
+  spec:
+    replicas: 10
+    selector:
+      matchLabels:
+        app: frontend
+    strategy: {}
+    template:
+      metadata:
+        creationTimestamp: null
+        labels:
+          app: frontend
+      spec:
+        containers:
+        - image: registry.ocp4.example.com:8443/redhattraining/hello-world-nginx:v1.0
+          name: hello-world-nginx
+          resources:
+            requests:
+              cpu: 50m
+              memory: 20Mi
+  status: {}
+- apiVersion: v1
+  kind: Service
+  metadata:
+    creationTimestamp: null
+    labels:
+      app: frontend
+    name: frontend
+  spec:
+    ports:
+    - port: 8080
+      protocol: TCP
+      targetPort: 8080
+    selector:
+      app: frontend
+  status:
+    loadBalancer: {}
+- apiVersion: route.openshift.io/v1
+  kind: Route
+  metadata:
+    creationTimestamp: null
+    labels:
+      app: frontend
+    name: frontend
+  spec:
+    port:
+      targetPort: 8080
+    to:
+      kind: ""
+      name: frontend
+      weight: null
+  status:
+    ingress: null

+ 65 - 0
labs/monitoring/apps/budget-app.yaml

@@ -0,0 +1,65 @@
+apiVersion: v1
+kind: List
+metadata: {}
+items:
+  - apiVersion: apps/v1
+    kind: Deployment
+    metadata:
+      labels:
+        app: budget-app
+      name: budget-app
+    spec:
+      replicas: 1
+      selector:
+        matchLabels:
+          app: budget-app
+      template:
+        metadata:
+          labels:
+            app: budget-app
+        spec:
+          containers:
+          - image: registry.ocp4.example.com:8443/redhattraining/loadtest:v1.0
+            name: budget-app
+            readinessProbe:
+              failureThreshold: 3
+              httpGet:
+                path: /api/loadtest/v1/healthz
+                port: 8080
+                scheme: HTTP
+              periodSeconds: 10
+              successThreshold: 1
+              timeoutSeconds: 1
+            resources:
+              requests:
+                cpu: 100m
+              limits:
+                cpu: 500m
+
+  - apiVersion: v1
+    kind: Service
+    metadata:
+      labels:
+        app: budget-app
+      name: budget-app
+    spec:
+      ports:
+      - port: 8080
+        protocol: TCP
+        targetPort: 8080
+      selector:
+        app: budget-app
+
+  - apiVersion: route.openshift.io/v1
+    kind: Route
+    metadata:
+      labels:
+        app: budget-app
+      name: budget-app
+    spec:
+      host: budget.apps.ocp4.example.com
+      port:
+        targetPort: 8080
+      to:
+        kind: Service
+        name: budget-app

+ 67 - 0
labs/monitoring/apps/budget-test.yaml

@@ -0,0 +1,67 @@
+apiVersion: v1
+kind: List
+metadata: {}
+items:
+- apiVersion: apps/v1
+  kind: Deployment
+  metadata:
+    creationTimestamp: null
+    labels:
+      app: budget-test
+    name: budget-test
+  spec:
+    replicas: 1
+    selector:
+      matchLabels:
+        app: budget-test
+    strategy: {}
+    template:
+      metadata:
+        creationTimestamp: null
+        labels:
+          app: budget-test
+      spec:
+        containers:
+        - image: registry.ocp4.example.com:8443/redhattraining/hello-world-nginx:v1.0
+          name: hello-world-nginx
+          resources:
+            requests:
+              cpu: 25m
+              memory: 20Mi
+            limits:
+              cpu: 100m
+              memory: 50Mi
+  status: {}
+- apiVersion: v1
+  kind: Service
+  metadata:
+    creationTimestamp: null
+    labels:
+      app: budget-test
+    name: budget-test
+  spec:
+    ports:
+    - port: 8080
+      protocol: TCP
+      targetPort: 8080
+    selector:
+      app: budget-test
+  status:
+    loadBalancer: {}
+- apiVersion: route.openshift.io/v1
+  kind: Route
+  metadata:
+    creationTimestamp: null
+    labels:
+      app: budget-test
+    name: budget-test
+  spec:
+    host: budget-test-monitor.apps.ocp4.example.com
+    port:
+      targetPort: 8080
+    to:
+      kind: ""
+      name: budget-test
+      weight: null
+  status:
+    ingress: null

+ 197 - 0
labs/monitoring/apps/exoplanets.yaml

@@ -0,0 +1,197 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  annotations:
+  labels:
+    app: exoplanets-db
+  name: exoplanets-db
+spec:
+  progressDeadlineSeconds: 600
+  replicas: 1
+  revisionHistoryLimit: 10
+  selector:
+    matchLabels:
+      app: exoplanets-db
+  strategy:
+    rollingUpdate:
+      maxSurge: 25%
+      maxUnavailable: 25%
+    type: RollingUpdate
+  template:
+    metadata:
+      labels:
+        app: exoplanets-db
+    spec:
+      containers:
+      - env:
+        - name: POSTGRESQL_ADMIN_PASSWORD
+          valueFrom:
+            secretKeyRef:
+              key: POSTGRESQL_ADMIN_PASSWORD
+              name: exoplanets
+        - name: POSTGRESQL_DATABASE
+          valueFrom:
+            secretKeyRef:
+              key: POSTGRESQL_DATABASE
+              name: exoplanets
+        - name: POSTGRESQL_MAX_CONNECTIONS
+          valueFrom:
+            secretKeyRef:
+              key: POSTGRESQL_MAX_CONNECTIONS
+              name: exoplanets
+        - name: POSTGRESQL_PASSWORD
+          valueFrom:
+            secretKeyRef:
+              key: POSTGRESQL_PASSWORD
+              name: exoplanets
+        - name: POSTGRESQL_USER
+          valueFrom:
+            secretKeyRef:
+              key: POSTGRESQL_USER
+              name: exoplanets
+        image: registry.ocp4.example.com:8443/rhel9/postgresql-13
+        imagePullPolicy: IfNotPresent
+        name: postgresql-13
+        ports:
+        - containerPort: 5432
+          protocol: TCP
+        resources:
+          requests:
+            cpu: 25m
+            memory: 50Mi
+          limits:
+            cpu: 100m
+            memory: 250Mi
+        terminationMessagePath: /dev/termination-log
+        terminationMessagePolicy: File
+      dnsPolicy: ClusterFirst
+      restartPolicy: Always
+      schedulerName: default-scheduler
+      securityContext: {}
+      terminationGracePeriodSeconds: 30
+
+---
+apiVersion: v1
+data:
+  POSTGRESQL_ADMIN_PASSWORD: cG9zdGdyZXM=
+  POSTGRESQL_DATABASE: ZGF0YWJhc2U=
+  POSTGRESQL_MAX_CONNECTIONS: MTAwMA==
+  POSTGRESQL_PASSWORD: cGFzc3dvcmQ=
+  POSTGRESQL_USER: dXNlcg==
+kind: Secret
+metadata:
+  name: exoplanets
+type: Opaque
+
+---
+apiVersion: v1
+kind: Service
+metadata:
+  labels:
+    app: exoplanets-db
+  name: exoplanets-db
+spec:
+  ports:
+  - port: 5432
+    protocol: TCP
+    targetPort: 5432
+  selector:
+    app: exoplanets-db
+status:
+  loadBalancer: {}
+
+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  annotations:
+  labels:
+    app: exoplanets-app
+  name: exoplanets-app
+spec:
+  progressDeadlineSeconds: 600
+  replicas: 1
+  revisionHistoryLimit: 10
+  selector:
+    matchLabels:
+      app: exoplanets-app
+  strategy:
+    rollingUpdate:
+      maxSurge: 25%
+      maxUnavailable: 25%
+    type: RollingUpdate
+  template:
+    metadata:
+      labels:
+        app: exoplanets-app
+    spec:
+      containers:
+      - env:
+        - name: DB_PORT
+          value: '5432'
+        - name: DB_HOST
+          value: exoplanets-db
+        - name: DB_NAME
+          valueFrom:
+            secretKeyRef:
+              key: POSTGRESQL_DATABASE
+              name: exoplanets
+        - name: DB_PASSWORD
+          valueFrom:
+            secretKeyRef:
+              key: POSTGRESQL_PASSWORD
+              name: exoplanets
+        - name: DB_USER
+          valueFrom:
+            secretKeyRef:
+              key: POSTGRESQL_USER
+              name: exoplanets
+        image: registry.ocp4.example.com:8443/redhattraining/exoplanets:v1.0
+        imagePullPolicy: IfNotPresent
+        name: exoplanets
+        ports:
+        - containerPort: 5432
+          protocol: TCP
+        resources:
+          requests:
+            cpu: 25m
+            memory: 50Mi
+          limits:
+            cpu:  100m
+            memory: 250Mi
+        terminationMessagePath: /dev/termination-log
+        terminationMessagePolicy: File
+      dnsPolicy: ClusterFirst
+      restartPolicy: Always
+      schedulerName: default-scheduler
+      terminationGracePeriodSeconds: 30
+
+---
+apiVersion: v1
+kind: Service
+metadata:
+  labels:
+    app: exoplanets-app
+  name: exoplanets-app
+spec:
+  ports:
+  - port: 8080
+    protocol: TCP
+    targetPort: 8080
+  selector:
+    app: exoplanets-app
+
+---
+apiVersion: route.openshift.io/v1
+kind: Route
+metadata:
+  labels:
+    app: exoplanets-app
+  name: exoplanets
+spec:
+  host: exoplanets.apps.ocp4.example.com
+  port:
+    targetPort: 8080
+  to:
+    kind: ''
+    name: exoplanets-app

+ 67 - 0
labs/monitoring/apps/frontend-test.yaml

@@ -0,0 +1,67 @@
+apiVersion: v1
+kind: List
+metadata: {}
+items:
+- apiVersion: apps/v1
+  kind: Deployment
+  metadata:
+    creationTimestamp: null
+    labels:
+      app: frontend-test
+    name: frontend-test
+  spec:
+    replicas: 10
+    selector:
+      matchLabels:
+        app: frontend-test
+    strategy: {}
+    template:
+      metadata:
+        creationTimestamp: null
+        labels:
+          app: frontend-test
+      spec:
+        containers:
+        - image: registry.ocp4.example.com:8443/redhattraining/hello-world-nginx:v1.0
+          name: hello-world-nginx
+          resources:
+            requests:
+              cpu: 50m
+              memory: 20Mi
+            limits:
+              cpu: 100m
+              memory: 50Mi
+  status: {}
+- apiVersion: v1
+  kind: Service
+  metadata:
+    creationTimestamp: null
+    labels:
+      app: frontend-test
+    name: frontend-test
+  spec:
+    ports:
+    - port: 8080
+      protocol: TCP
+      targetPort: 8080
+    selector:
+      app: frontend-test
+  status:
+    loadBalancer: {}
+- apiVersion: route.openshift.io/v1
+  kind: Route
+  metadata:
+    creationTimestamp: null
+    labels:
+      app: frontend-test
+    name: frontend-test
+  spec:
+    host: frontend-test-monitor.apps.ocp4.example.com
+    port:
+      targetPort: 8080
+    to:
+      kind: ""
+      name: frontend-test
+      weight: null
+  status:
+    ingress: null

+ 63 - 0
labs/monitoring/apps/frontend.yaml

@@ -0,0 +1,63 @@
+apiVersion: v1
+kind: List
+metadata: {}
+items:
+- apiVersion: apps/v1
+  kind: Deployment
+  metadata:
+    creationTimestamp: null
+    labels:
+      app: frontend
+    name: frontend
+  spec:
+    replicas: 10
+    selector:
+      matchLabels:
+        app: frontend
+    strategy: {}
+    template:
+      metadata:
+        creationTimestamp: null
+        labels:
+          app: frontend
+      spec:
+        containers:
+        - image: registry.ocp4.example.com:8443/redhattraining/hello-world-nginx:v1.0
+          name: hello-world-nginx
+          resources:
+            requests:
+              cpu: 50m
+              memory: 20Mi
+  status: {}
+- apiVersion: v1
+  kind: Service
+  metadata:
+    creationTimestamp: null
+    labels:
+      app: frontend
+    name: frontend
+  spec:
+    ports:
+    - port: 8080
+      protocol: TCP
+      targetPort: 8080
+    selector:
+      app: frontend
+  status:
+    loadBalancer: {}
+- apiVersion: route.openshift.io/v1
+  kind: Route
+  metadata:
+    creationTimestamp: null
+    labels:
+      app: frontend
+    name: frontend
+  spec:
+    port:
+      targetPort: 8080
+    to:
+      kind: ""
+      name: frontend
+      weight: null
+  status:
+    ingress: null

+ 26 - 0
labs/monitoring/apps/python-app.yaml

@@ -0,0 +1,26 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  creationTimestamp: null
+  labels:
+    app: python-app
+  name: python-app
+spec:
+  replicas: 1
+  selector:
+    matchLabels:
+      app: python-app
+  strategy: {}
+  template:
+    metadata:
+      creationTimestamp: null
+      labels:
+        app: python-app
+    spec:
+      containers:
+      - image: registry.ocp4.example.com:8443/redhattraining/python-load:v0.1
+        name: python-app
+        resources:
+          requests:
+              cpu: 100m
+              memory: 50Mi

+ 7 - 0
labs/monitoring/apps/traffic-simulator.sh

@@ -0,0 +1,7 @@
+#! /bin/bash
+
+while true;
+do
+    curl http://budget.apps.ocp4.example.com/api/loadtest/v1/cpu/1 & curl http://frontend-dev-monitor.apps.ocp4.example.com/?[1-100] > /dev/null & curl http://exoplanets.apps.ocp4.example.com/?[1-100] > /dev/null
+    sleep 10
+done