diff --git a/deploy/webapp/backend/deployment.yaml b/deploy/webapp/backend/deployment.yaml new file mode 100644 index 0000000..1211d8e --- /dev/null +++ b/deploy/webapp/backend/deployment.yaml @@ -0,0 +1,74 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: backend + namespace: webapp +spec: + minReadySeconds: 3 + revisionHistoryLimit: 5 + progressDeadlineSeconds: 60 + strategy: + rollingUpdate: + maxUnavailable: 0 + type: RollingUpdate + selector: + matchLabels: + app: backend + template: + metadata: + annotations: + prometheus.io/scrape: "true" + prometheus.io/port: "9797" + labels: + app: backend + spec: + serviceAccountName: webapp + containers: + - name: backend + image: stefanprodan/podinfo:3.2.2 + imagePullPolicy: IfNotPresent + ports: + - name: http + containerPort: 9898 + protocol: TCP + - name: http-metrics + containerPort: 9797 + protocol: TCP + - name: grpc + containerPort: 9999 + protocol: TCP + command: + - ./podinfo + - --port=9898 + - --port-metrics=9797 + - --grpc-port=9999 + - --grpc-service-name=backend + - --level=info + env: + - name: PODINFO_UI_COLOR + value: "#34577c" + livenessProbe: + exec: + command: + - podcli + - check + - http + - localhost:9898/healthz + initialDelaySeconds: 5 + timeoutSeconds: 5 + readinessProbe: + exec: + command: + - podcli + - check + - http + - localhost:9898/readyz + initialDelaySeconds: 5 + timeoutSeconds: 5 + resources: + limits: + cpu: 2000m + memory: 512Mi + requests: + cpu: 100m + memory: 32Mi diff --git a/deploy/webapp/backend/hpa.yaml b/deploy/webapp/backend/hpa.yaml new file mode 100644 index 0000000..5692a38 --- /dev/null +++ b/deploy/webapp/backend/hpa.yaml @@ -0,0 +1,19 @@ +apiVersion: autoscaling/v2beta2 +kind: HorizontalPodAutoscaler +metadata: + name: backend + namespace: webapp +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: backend + minReplicas: 1 + maxReplicas: 2 + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 99 diff --git a/deploy/webapp/backend/service.yaml b/deploy/webapp/backend/service.yaml new file mode 100644 index 0000000..ef4e7e1 --- /dev/null +++ b/deploy/webapp/backend/service.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: Service +metadata: + name: backend + namespace: webapp +spec: + type: ClusterIP + selector: + app: backend + ports: + - name: http + port: 9898 + protocol: TCP + targetPort: http + - port: 9999 + targetPort: grpc + protocol: TCP + name: grpc diff --git a/deploy/webapp/common/namespace.yaml b/deploy/webapp/common/namespace.yaml new file mode 100644 index 0000000..11ec570 --- /dev/null +++ b/deploy/webapp/common/namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: webapp diff --git a/deploy/webapp/common/service-account.yaml b/deploy/webapp/common/service-account.yaml new file mode 100644 index 0000000..12d9d86 --- /dev/null +++ b/deploy/webapp/common/service-account.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: webapp + namespace: webapp diff --git a/deploy/webapp/frontend/deployment.yaml b/deploy/webapp/frontend/deployment.yaml new file mode 100644 index 0000000..96c4261 --- /dev/null +++ b/deploy/webapp/frontend/deployment.yaml @@ -0,0 +1,73 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: frontend + namespace: webapp +spec: + minReadySeconds: 3 + revisionHistoryLimit: 5 + progressDeadlineSeconds: 60 + strategy: + rollingUpdate: + maxUnavailable: 0 + type: RollingUpdate + selector: + matchLabels: + app: frontend + template: + metadata: + annotations: + prometheus.io/scrape: "true" + prometheus.io/port: "9797" + labels: + app: frontend + spec: + serviceAccountName: webapp + containers: + - name: frontend + image: stefanprodan/podinfo:3.2.2 + imagePullPolicy: IfNotPresent + ports: + - name: http + containerPort: 9898 + protocol: TCP + - name: http-metrics + containerPort: 9797 + protocol: TCP + - name: grpc + containerPort: 9999 + protocol: TCP + command: + - ./podinfo + - --port=9898 + - --port-metrics=9797 + - --level=info + - --backend-url=http://backend:9898/echo + env: + - name: PODINFO_UI_COLOR + value: "#34577c" + livenessProbe: + exec: + command: + - podcli + - check + - http + - localhost:9898/healthz + initialDelaySeconds: 5 + timeoutSeconds: 5 + readinessProbe: + exec: + command: + - podcli + - check + - http + - localhost:9898/readyz + initialDelaySeconds: 5 + timeoutSeconds: 5 + resources: + limits: + cpu: 1000m + memory: 128Mi + requests: + cpu: 100m + memory: 32Mi diff --git a/deploy/webapp/frontend/hpa.yaml b/deploy/webapp/frontend/hpa.yaml new file mode 100644 index 0000000..d5b317e --- /dev/null +++ b/deploy/webapp/frontend/hpa.yaml @@ -0,0 +1,19 @@ +apiVersion: autoscaling/v2beta2 +kind: HorizontalPodAutoscaler +metadata: + name: frontend + namespace: webapp +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: backend + minReplicas: 1 + maxReplicas: 4 + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 99 diff --git a/deploy/webapp/frontend/service.yaml b/deploy/webapp/frontend/service.yaml new file mode 100644 index 0000000..3ea7960 --- /dev/null +++ b/deploy/webapp/frontend/service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: frontend + namespace: webapp +spec: + type: ClusterIP + selector: + app: frontend + ports: + - name: http + port: 80 + protocol: TCP + targetPort: http