-
Notifications
You must be signed in to change notification settings - Fork 0
Add Inventory service IaC: Dockerfile, Helm chart, ArgoCD manifests #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| apiVersion: argoproj.io/v1alpha1 | ||
| kind: Application | ||
| metadata: | ||
| name: inventory-dev | ||
| namespace: argocd | ||
| spec: | ||
| project: default | ||
| source: | ||
| repoURL: https://github.com/Cognition-Partner-Workshops/ordermanager-iac.git | ||
| targetRevision: main | ||
| path: helm/inventory | ||
| helm: | ||
| valueFiles: | ||
| - values.yaml | ||
| - values-dev.yaml | ||
| destination: | ||
| server: https://kubernetes.default.svc | ||
| namespace: decomposition-dev | ||
| syncPolicy: | ||
| automated: | ||
| prune: true | ||
| selfHeal: true | ||
| syncOptions: | ||
| - CreateNamespace=true | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| apiVersion: argoproj.io/v1alpha1 | ||
| kind: Application | ||
| metadata: | ||
| name: inventory-staging | ||
| namespace: argocd | ||
| spec: | ||
| project: default | ||
| source: | ||
| repoURL: https://github.com/Cognition-Partner-Workshops/ordermanager-iac.git | ||
| targetRevision: main | ||
| path: helm/inventory | ||
| helm: | ||
| valueFiles: | ||
| - values.yaml | ||
| - values-staging.yaml | ||
| destination: | ||
| server: https://kubernetes.default.svc | ||
| namespace: decomposition-staging | ||
| syncPolicy: | ||
| automated: | ||
| prune: true | ||
| selfHeal: true | ||
| syncOptions: | ||
| - CreateNamespace=true |
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔍 No CI/CD pipeline exists for building the inventory Docker image The existing Was this helpful? React with 👍 or 👎 to provide feedback.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Acknowledged — out of scope for this PR. The task was to add the Dockerfile/Helm/ArgoCD manifests modeled on the existing monolith patterns; the CI build-push pipeline for the inventory image is a separate follow-up. Flagging to the repo owner rather than adding a pipeline here, since the ECR repo/permissions setup for |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # Stage 1: Build .NET Inventory API | ||
| FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build | ||
| WORKDIR /src | ||
| COPY src/Inventory.Api/Inventory.Api.csproj src/Inventory.Api/ | ||
| RUN dotnet restore src/Inventory.Api/Inventory.Api.csproj | ||
| COPY src/Inventory.Api/ src/Inventory.Api/ | ||
| RUN dotnet publish src/Inventory.Api/Inventory.Api.csproj -c Release -o /app/publish | ||
|
|
||
| # Stage 2: Runtime | ||
| FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS runtime | ||
| WORKDIR /app | ||
| COPY --from=build /app/publish . | ||
| EXPOSE 8080 | ||
| ENV ASPNETCORE_URLS=http://+:8080 | ||
| ENTRYPOINT ["dotnet", "Inventory.Api.dll"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| apiVersion: v2 | ||
| name: inventory | ||
| description: Helm chart for the Inventory microservice (extracted from OrderManager monolith) | ||
| type: application | ||
| version: 0.1.0 | ||
| appVersion: "1.0.0" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| {{/* | ||
| Expand the name of the chart. | ||
| */}} | ||
| {{- define "inventory.name" -}} | ||
| {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} | ||
| {{- end }} | ||
|
|
||
| {{- define "inventory.fullname" -}} | ||
| {{- if .Values.fullnameOverride }} | ||
| {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} | ||
| {{- else }} | ||
| {{- $name := default .Chart.Name .Values.nameOverride }} | ||
| {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} | ||
| {{- end }} | ||
| {{- end }} | ||
|
|
||
| {{- define "inventory.labels" -}} | ||
| helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} | ||
| app.kubernetes.io/name: {{ include "inventory.name" . }} | ||
| app.kubernetes.io/instance: {{ .Release.Name }} | ||
| app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
| {{- end }} | ||
|
|
||
| {{- define "inventory.selectorLabels" -}} | ||
| app.kubernetes.io/name: {{ include "inventory.name" . }} | ||
| app.kubernetes.io/instance: {{ .Release.Name }} | ||
| {{- end }} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| metadata: | ||
| name: {{ include "inventory.fullname" . }} | ||
| labels: | ||
| {{- include "inventory.labels" . | nindent 4 }} | ||
| spec: | ||
| {{- if not .Values.autoscaling.enabled }} | ||
| replicas: {{ .Values.replicaCount }} | ||
| {{- end }} | ||
| selector: | ||
| matchLabels: | ||
| {{- include "inventory.selectorLabels" . | nindent 6 }} | ||
| template: | ||
| metadata: | ||
| labels: | ||
| {{- include "inventory.selectorLabels" . | nindent 8 }} | ||
| spec: | ||
| containers: | ||
| - name: {{ .Chart.Name }} | ||
| image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" | ||
| imagePullPolicy: {{ .Values.image.pullPolicy }} | ||
| ports: | ||
| - name: http | ||
| containerPort: {{ .Values.service.targetPort }} | ||
| protocol: TCP | ||
| {{- if .Values.env }} | ||
| env: | ||
| {{- toYaml .Values.env | nindent 12 }} | ||
| {{- end }} | ||
| resources: | ||
| {{- toYaml .Values.resources | nindent 12 }} | ||
| livenessProbe: | ||
| httpGet: | ||
| path: /health | ||
| port: http | ||
| initialDelaySeconds: 15 | ||
| periodSeconds: 20 | ||
| readinessProbe: | ||
| httpGet: | ||
| path: /health | ||
| port: http | ||
| initialDelaySeconds: 5 | ||
| periodSeconds: 10 | ||
|
Comment on lines
+18
to
+49
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟨 Missing pod security context allows containers to run with elevated privileges The deployment template ( Was this helpful? React with 👍 or 👎 to provide feedback.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Noted. The chart mirrors the existing |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| {{- if .Values.autoscaling.enabled }} | ||
| apiVersion: autoscaling/v2 | ||
| kind: HorizontalPodAutoscaler | ||
| metadata: | ||
| name: {{ include "inventory.fullname" . }} | ||
| labels: | ||
| {{- include "inventory.labels" . | nindent 4 }} | ||
| spec: | ||
| scaleTargetRef: | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| name: {{ include "inventory.fullname" . }} | ||
| minReplicas: {{ .Values.autoscaling.minReplicas }} | ||
| maxReplicas: {{ .Values.autoscaling.maxReplicas }} | ||
| metrics: | ||
| - type: Resource | ||
| resource: | ||
| name: cpu | ||
| target: | ||
| type: Utilization | ||
| averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} | ||
| {{- end }} |
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔍 Ingress template has cert-manager annotation but no TLS section The base Was this helpful? React with 👍 or 👎 to provide feedback.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct, and intentional — as noted, this matches the existing |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| {{- if .Values.ingress.enabled -}} | ||
| apiVersion: networking.k8s.io/v1 | ||
| kind: Ingress | ||
| metadata: | ||
| name: {{ include "inventory.fullname" . }} | ||
| labels: | ||
| {{- include "inventory.labels" . | nindent 4 }} | ||
| {{- with .Values.ingress.annotations }} | ||
| annotations: | ||
| {{- toYaml . | nindent 4 }} | ||
| {{- end }} | ||
| spec: | ||
| ingressClassName: {{ .Values.ingress.className }} | ||
| rules: | ||
| {{- range .Values.ingress.hosts }} | ||
| - host: {{ .host | quote }} | ||
| http: | ||
| paths: | ||
| {{- range .paths }} | ||
| - path: {{ .path }} | ||
| pathType: {{ .pathType }} | ||
| backend: | ||
| service: | ||
| name: {{ include "inventory.fullname" $ }} | ||
| port: | ||
| number: {{ $.Values.service.port }} | ||
| {{- end }} | ||
| {{- end }} | ||
| {{- end }} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| apiVersion: networking.k8s.io/v1 | ||
| kind: NetworkPolicy | ||
| metadata: | ||
| name: {{ include "inventory.fullname" . }} | ||
| labels: | ||
| {{- include "inventory.labels" . | nindent 4 }} | ||
| spec: | ||
| podSelector: | ||
| matchLabels: | ||
| {{- include "inventory.selectorLabels" . | nindent 6 }} | ||
| policyTypes: | ||
| - Ingress | ||
| - Egress | ||
| ingress: | ||
| - from: | ||
| - namespaceSelector: | ||
| matchLabels: | ||
| kubernetes.io/metadata.name: ingress-nginx | ||
| ports: | ||
| - protocol: TCP | ||
| port: {{ .Values.service.targetPort }} | ||
| - from: | ||
| - podSelector: | ||
| matchLabels: | ||
| app.kubernetes.io/name: ordermanager | ||
| ports: | ||
| - protocol: TCP | ||
| port: {{ .Values.service.targetPort }} | ||
| {{- if .Values.monitoring.enabled }} | ||
| - from: | ||
| - namespaceSelector: | ||
| matchLabels: | ||
| kubernetes.io/metadata.name: monitoring | ||
| ports: | ||
| - protocol: TCP | ||
| port: {{ .Values.monitoring.port }} | ||
| {{- end }} | ||
| egress: | ||
| - to: [] | ||
| ports: | ||
| - protocol: UDP | ||
| port: 53 | ||
| - protocol: TCP | ||
| port: 53 | ||
| - to: [] | ||
| ports: | ||
| - protocol: TCP | ||
| port: 443 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| name: {{ include "inventory.fullname" . }} | ||
| labels: | ||
| {{- include "inventory.labels" . | nindent 4 }} | ||
| spec: | ||
| type: {{ .Values.service.type }} | ||
| ports: | ||
| - port: {{ .Values.service.port }} | ||
| targetPort: {{ .Values.service.targetPort }} | ||
| protocol: TCP | ||
| name: http | ||
| selector: | ||
| {{- include "inventory.selectorLabels" . | nindent 4 }} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| {{- if .Values.monitoring.enabled }} | ||
| apiVersion: monitoring.coreos.com/v1 | ||
| kind: ServiceMonitor | ||
| metadata: | ||
| name: {{ include "inventory.fullname" . }} | ||
| labels: | ||
| {{- include "inventory.labels" . | nindent 4 }} | ||
| spec: | ||
| selector: | ||
| matchLabels: | ||
| {{- include "inventory.selectorLabels" . | nindent 6 }} | ||
| endpoints: | ||
| - port: http | ||
| path: {{ .Values.monitoring.path }} | ||
| interval: 30s | ||
| {{- end }} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| replicaCount: 1 | ||
|
|
||
| image: | ||
| tag: dev-latest | ||
|
|
||
| ingress: | ||
| hosts: | ||
| - host: inventory-dev.workshop.local | ||
| paths: | ||
| - path: / | ||
| pathType: Prefix | ||
|
|
||
| resources: | ||
| requests: | ||
| cpu: 50m | ||
| memory: 128Mi | ||
| limits: | ||
| cpu: 250m | ||
| memory: 256Mi | ||
|
|
||
| env: | ||
| - name: ASPNETCORE_ENVIRONMENT | ||
| value: Development | ||
| - name: ConnectionStrings__DefaultConnection | ||
| value: "Data Source=inventory.db" | ||
|
|
||
| persistence: | ||
| enabled: false |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| replicaCount: 2 | ||
|
|
||
| image: | ||
| tag: staging-latest | ||
|
|
||
| ingress: | ||
| hosts: | ||
| - host: inventory-staging.workshop.local | ||
| paths: | ||
| - path: / | ||
| pathType: Prefix | ||
|
|
||
| resources: | ||
| requests: | ||
| cpu: 100m | ||
| memory: 128Mi | ||
| limits: | ||
| cpu: 250m | ||
| memory: 256Mi | ||
|
|
||
| autoscaling: | ||
| enabled: true | ||
| minReplicas: 2 | ||
| maxReplicas: 4 | ||
| targetCPUUtilizationPercentage: 75 | ||
|
Comment on lines
+21
to
+25
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔍 Staging enables autoscaling with multiple replicas but uses SQLite, which doesn't support concurrent writes The staging values ( Was this helpful? React with 👍 or 👎 to provide feedback.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Valid concern for a real environment. As you note, this is a workshop/demo config and mirrors the ordermanager staging setup. A proper fix would swap SQLite for a networked DB (Postgres/RDS) before scaling past 1 replica, or pin the service to |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| replicaCount: 1 | ||
|
|
||
| image: | ||
| repository: 599083837640.dkr.ecr.us-east-1.amazonaws.com/workshop/inventory | ||
| tag: latest | ||
| pullPolicy: IfNotPresent | ||
|
|
||
| service: | ||
| type: ClusterIP | ||
| port: 80 | ||
| targetPort: 8080 | ||
|
|
||
| ingress: | ||
| enabled: true | ||
| className: nginx | ||
| annotations: | ||
| cert-manager.io/cluster-issuer: letsencrypt-staging | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟨 Production TLS uses Let's Encrypt staging issuer, producing untrusted certificates The base Was this helpful? React with 👍 or 👎 to provide feedback.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Intentional — this mirrors the existing |
||
| hosts: | ||
| - host: inventory.workshop.local | ||
| paths: | ||
| - path: / | ||
| pathType: Prefix | ||
|
|
||
| resources: | ||
| requests: | ||
| cpu: 50m | ||
| memory: 128Mi | ||
| limits: | ||
| cpu: 250m | ||
| memory: 256Mi | ||
|
|
||
| autoscaling: | ||
| enabled: false | ||
| minReplicas: 1 | ||
| maxReplicas: 3 | ||
| targetCPUUtilizationPercentage: 80 | ||
|
|
||
| env: | ||
| - name: ASPNETCORE_ENVIRONMENT | ||
| value: Production | ||
| - name: ConnectionStrings__DefaultConnection | ||
| value: "Data Source=/data/inventory.db" | ||
|
|
||
| persistence: | ||
| enabled: true | ||
| size: 1Gi | ||
| storageClass: gp2 | ||
|
Comment on lines
+42
to
+47
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 Production database path references a non-existent directory, causing the service to fail on startup The production connection string is set to write the database at Impact: The inventory service will crash or error on first database access in production because the target directory is missing. Missing PVC template and volume mount despite persistence configurationThe
When the .NET application tries to open Note: The existing ordermanager chart has the same pattern ( Prompt for agentsWas this helpful? React with 👍 or 👎 to provide feedback.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in cba8dfb's follow-up commit. Added |
||
|
|
||
| monitoring: | ||
| enabled: true | ||
| path: /metrics | ||
| port: 8080 | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔍 ArgoCD inventory apps reference a different repo URL than the existing ordermanager apps
The new inventory ArgoCD manifests use
repoURL: https://github.com/Cognition-Partner-Workshops/ordermanager-iac.git(argocd/inventory-dev.yaml:9), which matches the actual repository name. However, the existing ordermanager ArgoCD apps userepoURL: https://github.com/Cognition-Partner-Workshops/app_dotnet-angular-monolith-iac.git(argocd/application-dev.yaml:9). This discrepancy suggests the repository was renamed at some point and the old ArgoCD manifests were never updated. The new inventory URLs appear correct, but the inconsistency may cause confusion and the old ordermanager ArgoCD apps may need updating to the current repo name.Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new inventory manifests deliberately use the correct current repo name (
ordermanager-iac). The existing ordermanager apps still point at the oldapp_dotnet-angular-monolith-iac.gitname — that's a pre-existing inconsistency from a repo rename, outside this PR's scope. Flagging to the repo owner that those older ArgoCD apps should be updated separately.