2 Commits

Author SHA1 Message Date
mr
5c0ade62b4 Merge branch 'main' of https://cloud.o-forge.io/core/oc-workflow into main 2024-09-23 14:27:28 +02:00
mr
016cb5e49a Adjust to new Oc-Lib 2024-09-23 13:28:41 +02:00
11 changed files with 27 additions and 198 deletions

View File

@@ -23,7 +23,7 @@ WORKDIR /app
COPY --from=builder /app/setup /usr/bin/
COPY --from=builder /app/swagger /app/swagger
COPY docker_conf.json /etc/oc/conf.json
COPY docker_conf.json /etc/oc/workflow.json
EXPOSE 8080

View File

@@ -1,41 +0,0 @@
@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

View File

@@ -3,7 +3,9 @@ version: '3.4'
services:
oc-workflow:
environment:
- MONGO_DATABASE=DC_myDC
- _OCWORKFLOW_MONGO_DATABASE=DC_myDC
- _OCWORKFLOW_MONGO_URL=mongodb://mongo:27017
- _OCWORKFLOW_NATS_URL=nats://nats:4222
image: 'oc-workflow:latest'
ports:
- 8088:8080

12
go.mod
View File

@@ -5,7 +5,7 @@ go 1.22.0
toolchain go1.22.4
require (
cloud.o-forge.io/core/oc-lib v0.0.0-20240904135449-4f0ab6a3760f
cloud.o-forge.io/core/oc-lib v0.0.0-20240923092351-6c9b9ea30d2b
github.com/beego/beego/v2 v2.3.0
github.com/nats-io/nats.go v1.37.0
github.com/smartystreets/goconvey v1.7.2
@@ -19,14 +19,14 @@ require (
github.com/gabriel-vasile/mimetype v1.4.5 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.22.0 // indirect
github.com/go-playground/validator/v10 v10.22.1 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 // indirect
github.com/goraz/onion v0.1.3 // indirect
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/jtolds/gls v4.20.0+incompatible // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/klauspost/compress v1.17.10 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
@@ -50,9 +50,9 @@ require (
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect
go.mongodb.org/mongo-driver v1.16.1 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/net v0.28.0 // indirect
go.mongodb.org/mongo-driver v1.17.0 // indirect
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/text v0.18.0 // indirect

16
go.sum
View File

@@ -1,7 +1,7 @@
cloud.o-forge.io/core/oc-lib v0.0.0-20240904124127-235c8d5ccb41 h1:NhhZNsQ2Wg71ANTiW22ccFZKLBLsGx9hbMP4FHHgob4=
cloud.o-forge.io/core/oc-lib v0.0.0-20240904124127-235c8d5ccb41/go.mod h1:FIJD0taWLJ5pjQLJ6sfE2KlTkvbmk5SMcyrxdjsaVz0=
cloud.o-forge.io/core/oc-lib v0.0.0-20240904135449-4f0ab6a3760f h1:v9mw3uNg/DJswOvHooMu8/BMedA+vIXbma+8iUwsjUI=
cloud.o-forge.io/core/oc-lib v0.0.0-20240904135449-4f0ab6a3760f/go.mod h1:FIJD0taWLJ5pjQLJ6sfE2KlTkvbmk5SMcyrxdjsaVz0=
cloud.o-forge.io/core/oc-lib v0.0.0-20240923092351-6c9b9ea30d2b h1:Yj/85Liy09ukhLgkmF5FEQQUyl7UilOTdLj332s0HIY=
cloud.o-forge.io/core/oc-lib v0.0.0-20240923092351-6c9b9ea30d2b/go.mod h1:FIJD0taWLJ5pjQLJ6sfE2KlTkvbmk5SMcyrxdjsaVz0=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/beego/beego/v2 v2.3.0 h1:iECVwzm6egw6iw6tkWrEDqXG4NQtKLQ6QBSYqlM6T/I=
github.com/beego/beego/v2 v2.3.0/go.mod h1:Ob/5BJ9fIKZLd4s9ZV3o9J6odkkIyL83et+p98gyYXo=
@@ -31,6 +31,8 @@ github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJn
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.22.0 h1:k6HsTZ0sTnROkhS//R0O+55JgM8C4Bx7ia+JlgcnOao=
github.com/go-playground/validator/v10 v10.22.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
github.com/go-playground/validator/v10 v10.22.1 h1:40JcKH+bBNGFczGuoBYgX4I6m/i27HYW8P9FDk5PbgA=
github.com/go-playground/validator/v10 v10.22.1/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
@@ -51,6 +53,8 @@ github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
github.com/klauspost/compress v1.17.10 h1:oXAz+Vh0PMUvJczoi+flxpnBEPxoER1IaAnU/NMPtT0=
github.com/klauspost/compress v1.17.10/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
@@ -128,11 +132,15 @@ github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78/go.mod h1:aL8wCCfTfS
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.mongodb.org/mongo-driver v1.16.1 h1:rIVLL3q0IHM39dvE+z2ulZLp9ENZKThVfuvN/IiN4l8=
go.mongodb.org/mongo-driver v1.16.1/go.mod h1:oB6AhJQvFQL4LEHyXi6aJzQJtBiTQHiAd83l0GdFaiw=
go.mongodb.org/mongo-driver v1.17.0 h1:Hp4q2MCjvY19ViwimTs00wHi7G4yzxh4/2+nTx8r40k=
go.mongodb.org/mongo-driver v1.17.0/go.mod h1:wwWm/+BuOddhcq3n68LKRmgk2wXzmF6s0SFOa0GINL4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191112222119-e1110fd1c708/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0=
golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
@@ -143,6 +151,8 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
@@ -157,8 +167,6 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg=
golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=

View File

@@ -1,5 +0,0 @@
apiVersion: v2
name: oc-catalog
description: A Helm chart for deploying the oc-catalog application
version: 0.1.0
appVersion: "1.0"

View File

@@ -1,67 +0,0 @@
# 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.

View File

@@ -1,31 +0,0 @@
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 }}"

View File

@@ -1,17 +0,0 @@
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)

View File

@@ -1,22 +0,0 @@
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"

View File

@@ -20,14 +20,16 @@ func main() {
o := oclib.GetConfLoader()
// feed the library with the loaded config
fmt.Println("Config file:", os.Getenv("MONGO_URL"))
oclib.SetConfig(
o.GetStringDefault("MONGO_URL", "mongodb://127.0.0.1:27017"),
o.GetStringDefault("MONGO_DATABASE", "DC_myDC"),
o.GetStringDefault("NATS_URL", "nats://localhost:4222"),
o.GetStringDefault("lokiurl", ""),
o.GetStringDefault("loglevel", "info"),
o.GetStringDefault("LOKI_URL", ""),
o.GetStringDefault("LOG_LEVEL", "info"),
)
fmt.Println("Config file:", o.GetStringDefault("HOSTNAME", "localhost"))
// Init OC with hostname and port for discovery purpose
/* PATHS ARE REFERENCE FOR INNER SERVICE OF DISTANT OC
* PATHS ARE USED TO CALL OTHER OC SERVICES
* NAMES ARE CANONICAL NAMES OF THE SERVICES