From 85e7c8197c7f6e8d53ce568963a6a2cabff3fa3a Mon Sep 17 00:00:00 2001 From: na Date: Thu, 12 Sep 2024 14:36:17 +0200 Subject: [PATCH] chore: Add Kubernetes deployment and service files for oc-workflow component --- arch/diagrams/src/oc-workflow.puml | 41 ++++++++++++++++++ helm/Chart.yaml | 5 +++ helm/README.md | 67 ++++++++++++++++++++++++++++++ helm/templates/deployment.yml | 31 ++++++++++++++ helm/templates/service.yml | 17 ++++++++ helm/values.yaml | 22 ++++++++++ 6 files changed, 183 insertions(+) create mode 100644 arch/diagrams/src/oc-workflow.puml create mode 100644 helm/Chart.yaml create mode 100644 helm/README.md create mode 100644 helm/templates/deployment.yml create mode 100644 helm/templates/service.yml create mode 100644 helm/values.yaml diff --git a/arch/diagrams/src/oc-workflow.puml b/arch/diagrams/src/oc-workflow.puml new file mode 100644 index 0000000..bf6d598 --- /dev/null +++ b/arch/diagrams/src/oc-workflow.puml @@ -0,0 +1,41 @@ +@startuml +skinparam componentStyle rectangle + +node "Kubernetes Cluster" { + + cloud "Service: oc-workflow" as oc_workflow_service { + oc_workflow_service : Type: NodePort + oc_workflow_service : External NodePort: 8088 # Exposed NodePort for external access + oc_workflow_service : Internal TargetPort: 8080 + } + + ' Deployment for oc-workflow managing the pods + node "Deployment: oc-workflow" as oc_workflow_deployment { + oc_workflow_deployment : Replicas: {{ .Values.replicaCount }} + oc_workflow_deployment : Image: registry.dev.svc.cluster.local:5000/oc-workflow:latest + oc_workflow_deployment : PullPolicy: IfNotPresent + oc_workflow_deployment : TargetPort: 8080 + + node "Pod: oc-workflow-1" as workflow_1 { + component "Container: oc-workflow" as oc_workflow_container1 { + oc_workflow_container1 : Internal Port: 8080 + oc_workflow_container1 : MONGO_DATABASE=DC_myDC + oc_workflow_container1 : MONGO_URI=mongodb://mongo:27017 + } + } + } + + oc_workflow_service --> oc_workflow_deployment : Routes traffic to Deployment + oc_workflow_deployment --> workflow_1 : Manages Pods + + ' MongoDB service and statefulset + + cloud "Service: mongo" as mongo_service { + mongo_service : Type: ClusterIP + mongo_service : Internal Port: 27017 + } + + workflow_1 --> mongo_service : Connects to MongoDB + +} +@enduml \ No newline at end of file diff --git a/helm/Chart.yaml b/helm/Chart.yaml new file mode 100644 index 0000000..490589d --- /dev/null +++ b/helm/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v2 +name: oc-catalog +description: A Helm chart for deploying the oc-catalog application +version: 0.1.0 +appVersion: "1.0" diff --git a/helm/README.md b/helm/README.md new file mode 100644 index 0000000..fab4ff5 --- /dev/null +++ b/helm/README.md @@ -0,0 +1,67 @@ +# README.md - `oc-workflow` Helm Chart + +This document describes the different tags found in the `values.yml` file used in the Helm chart for the `oc-workflow` component. + +## Tags in the `values.yml` file + +### `replicaCount` +- **Description**: Defines the number of replicas for the deployment. A replica represents an instance of the application that will be deployed. +- **Example**: `1` means a single instance of the `oc-workflow` service will be deployed. + +### `image.repository` +- **Description**: Specifies the URL of the Docker image registry where the `oc-workflow` component image is stored. +- **Example**: `registry.dev.svc.cluster.local:5000/oc-workflow` refers to a local registry hosted within the `cluster.local` network. + +### `image.tag` +- **Description**: Indicates the tag of the Docker image to use. Typically, this could be a specific version or `latest` to always pull the latest version. +- **Example**: `latest` means the most recent version of the image will be used. + +### `image.pullPolicy` +- **Description**: Defines the image pull policy. The possible options are: + - `Always`: Always pull the image. + - `IfNotPresent`: Pull the image only if it is not already present on the node. + - `Never`: Never pull the image. +- **Example**: `IfNotPresent` means the image will only be pulled if it is not already present on the node. + +### `env.mongoDatabase` +- **Description**: Defines the name of the MongoDB database the application will connect to. +- **Example**: `DC_myDC` refers to the MongoDB database used by the application. + +### `env.mongoUrl` +- **Description**: Specifies the connection URL for MongoDB used by the application. +- **Example**: `mongodb://toto:27017` indicates that the application will connect to the MongoDB instance hosted at `toto` on port `27017`. + +### `service.type` +- **Description**: Defines the type of Kubernetes service. Possible types include: + - `ClusterIP`: The service is only accessible within the cluster. + - `NodePort`: The service is accessible via a specific port on all cluster nodes. + - `LoadBalancer`: The service is exposed via an external Load Balancer. +- **Example**: `ClusterIP` means the service will only be accessible within the Kubernetes cluster. + +### `service.port` +- **Description**: Specifies the port on which the service will be exposed within the cluster. +- **Example**: `8088` means the service will be accessible on port `8088`. + +### `service.targetPort` +- **Description**: Defines the port on which the application listens inside the container. +- **Example**: `8080` means the application listens on port `8080` within the container. + +### `resources.limits.cpu` +- **Description**: Specifies the maximum amount of CPU (in millicores) allocated to the container. +- **Example**: `500m` means the container can use up to 0.5 CPU (or 50% of a full CPU core). + +### `resources.limits.memory` +- **Description**: Specifies the maximum amount of memory (in MiB) allocated to the container. +- **Example**: `512Mi` means the container can use up to 512 MiB of memory. + +### `resources.requests.cpu` +- **Description**: Defines the guaranteed amount of CPU (in millicores) for the container. Kubernetes will ensure this amount is always available. +- **Example**: `250m` means the container will have at least 0.25 CPU (or 25% of a full CPU core). + +### `resources.requests.memory` +- **Description**: Defines the guaranteed amount of memory (in MiB) for the container. Kubernetes will reserve this memory for the container. +- **Example**: `256Mi` means the container will have at least 256 MiB of memory. + +## Conclusion + +This `values.yml` file allows configuring the deployment settings for the `oc-workflow` component. Each tag plays a specific role in defining the Docker image, service configuration, and resource allocation for the container within the Kubernetes cluster. diff --git a/helm/templates/deployment.yml b/helm/templates/deployment.yml new file mode 100644 index 0000000..057436f --- /dev/null +++ b/helm/templates/deployment.yml @@ -0,0 +1,31 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: oc-workflow + labels: + app: oc-workflow +spec: + replicas: 1 + selector: + matchLabels: + app: oc-workflow + template: + metadata: + labels: + app: oc-workflow + spec: + containers: + - name: oc-workflow + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + ports: + - containerPort: {{ .Values.service.targetPort }} + env: + - name: MONGO_DATABASE + value: "{{ .Values.env.mongoDatabase }}" + resources: + limits: + cpu: "{{ .Values.resources.limits.cpu }}" + memory: "{{ .Values.resources.limits.memory }}" + requests: + cpu: "{{ .Values.resources.requests.cpu }}" + memory: "{{ .Values.resources.requests.memory }}" diff --git a/helm/templates/service.yml b/helm/templates/service.yml new file mode 100644 index 0000000..a7e0959 --- /dev/null +++ b/helm/templates/service.yml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + name: oc-workflow + labels: + app: oc-workflow + release: {{ .Release.Name }} +spec: + type: {{ .Values.service.type }} # Utilisation du type de service configuré (ClusterIP, NodePort, LoadBalancer) + selector: + app: oc-catalog + release: {{ .Release.Name }} + ports: + - protocol: TCP + port: {{ .Values.service.port }} # Port exposé (8089 par défaut) + targetPort: {{ .Values.service.targetPort }} # Port du conteneur interne (8080 par défaut) + diff --git a/helm/values.yaml b/helm/values.yaml new file mode 100644 index 0000000..8b33540 --- /dev/null +++ b/helm/values.yaml @@ -0,0 +1,22 @@ +replicaCount: 1 + +image: + repository: registry.dev.svc.cluster.local:5000/oc-workflow + tag: latest + pullPolicy: IfNotPresent + +env: + mongoDatabase: DC_myDC + +service: + type: ClusterIP # Le type de service + port: 8088 # Port exposé + targetPort: 8080 # Port interne du conteneur + +resources: + limits: + cpu: "500m" + memory: "512Mi" + requests: + cpu: "250m" + memory: "256Mi"