Compare commits
3 Commits
05e041cccf
...
chart
| Author | SHA1 | Date | |
|---|---|---|---|
| 9d7f473982 | |||
|
|
17aeef4ad0 | ||
|
|
e9ff0bd58c |
41
arch/diagrams/src/oc-catalog.puml
Normal file
41
arch/diagrams/src/oc-catalog.puml
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
@startuml
|
||||||
|
skinparam componentStyle rectangle
|
||||||
|
|
||||||
|
node "Kubernetes Cluster" {
|
||||||
|
|
||||||
|
cloud "Service: oc-catalog" as oc_catalog_service {
|
||||||
|
oc_catalog_service : Type: NodePort
|
||||||
|
oc_catalog_service : External NodePort: 8087 # Exposed NodePort for external access
|
||||||
|
oc_catalog_service : Internal TargetPort: 8080
|
||||||
|
}
|
||||||
|
|
||||||
|
' Deployment for oc-catalog managing the pods
|
||||||
|
node "Deployment: oc-catalog" as oc_catalog_deployment {
|
||||||
|
oc_catalog_deployment : Replicas: {{ .Values.replicaCount }}
|
||||||
|
oc_catalog_deployment : Image: registry.dev.svc.cluster.local:5000/oc-catalog:latest
|
||||||
|
oc_catalog_deployment : PullPolicy: IfNotPresent
|
||||||
|
oc_catalog_deployment : TargetPort: 8080
|
||||||
|
|
||||||
|
node "Pod: oc-catalog-1" as catalog_1 {
|
||||||
|
component "Container: oc-catalog" as oc_catalog_container1 {
|
||||||
|
oc_catalog_container1 : Internal Port: 8080
|
||||||
|
oc_catalog_container1 : MONGO_DATABASE=DC_myDC
|
||||||
|
oc_catalog_container1 : MONGO_URI=mongodb://mongo:27017
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
oc_catalog_service --> oc_catalog_deployment : Routes traffic to Deployment
|
||||||
|
oc_catalog_deployment --> catalog_1 : Manages Pods
|
||||||
|
|
||||||
|
' MongoDB service and statefulset
|
||||||
|
|
||||||
|
cloud "Service: mongo" as mongo_service {
|
||||||
|
mongo_service : Type: ClusterIP
|
||||||
|
mongo_service : Internal Port: 27017
|
||||||
|
}
|
||||||
|
|
||||||
|
catalog_1 --> mongo_service : Connects to MongoDB
|
||||||
|
|
||||||
|
}
|
||||||
|
@enduml
|
||||||
5
helm/Chart.yaml
Normal file
5
helm/Chart.yaml
Normal file
@@ -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"
|
||||||
67
helm/README.md
Normal file
67
helm/README.md
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
# README.md - `oc-catalog` Helm Chart
|
||||||
|
|
||||||
|
This document describes the different tags found in the `values.yml` file used in the Helm chart for the `oc-catalog` 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-catalog` service will be deployed.
|
||||||
|
|
||||||
|
### `image.repository`
|
||||||
|
- **Description**: Specifies the URL of the Docker image registry where the `oc-catalog` component image is stored.
|
||||||
|
- **Example**: `registry.dev.svc.cluster.local:5000/oc-catalog` 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**: `8087` means the service will be accessible on port `8087`.
|
||||||
|
|
||||||
|
### `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-catalog` component. Each tag plays a specific role in defining the Docker image, service configuration, and resource allocation for the container within the Kubernetes cluster.
|
||||||
7
helm/templates/configmap.yml
Normal file
7
helm/templates/configmap.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: oc-catalog-configmap
|
||||||
|
data:
|
||||||
|
MONGO_DATABASE: "{{ .Values.env.mongoDatabase }}"
|
||||||
|
OCCATALOG_MONGOURL: "{{ .Values.env.mongoUrl }}"
|
||||||
36
helm/templates/deployment.yml
Normal file
36
helm/templates/deployment.yml
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: oc-catalog
|
||||||
|
labels:
|
||||||
|
app: oc-catalog
|
||||||
|
chart: {{ .Chart.Name }}-{{ .Chart.Version }}
|
||||||
|
release: {{ .Release.Name }}
|
||||||
|
heritage: {{ .Release.Service }}
|
||||||
|
spec:
|
||||||
|
replicas: {{ .Values.replicaCount }}
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: oc-catalog
|
||||||
|
release: {{ .Release.Name }}
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: oc-catalog
|
||||||
|
release: {{ .Release.Name }}
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: oc-catalog
|
||||||
|
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
||||||
|
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||||
|
ports:
|
||||||
|
- containerPort: {{ .Values.service.targetPort }}
|
||||||
|
envFrom:
|
||||||
|
- configMapRef:
|
||||||
|
name: oc-catalog-configmap
|
||||||
|
imagePullSecrets:
|
||||||
|
{{- if .Values.imagePullSecrets }}
|
||||||
|
{{- range .Values.imagePullSecrets }}
|
||||||
|
- name: {{ .name }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
16
helm/templates/service.yml
Normal file
16
helm/templates/service.yml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: oc-catalog
|
||||||
|
labels:
|
||||||
|
app: oc-catalog
|
||||||
|
release: {{ .Release.Name }}
|
||||||
|
spec:
|
||||||
|
type: {{ .Values.service.type }}
|
||||||
|
selector:
|
||||||
|
app: oc-catalog
|
||||||
|
release: {{ .Release.Name }}
|
||||||
|
ports:
|
||||||
|
- protocol: TCP
|
||||||
|
port: {{ .Values.service.port }}
|
||||||
|
targetPort: {{ .Values.service.targetPort }}
|
||||||
18
helm/values.yaml
Normal file
18
helm/values.yaml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
replicaCount: 1
|
||||||
|
|
||||||
|
image:
|
||||||
|
repository: registry.dev.svc.cluster.local:5000/oc-catalog
|
||||||
|
tag: latest
|
||||||
|
pullPolicy: IfNotPresent
|
||||||
|
|
||||||
|
service:
|
||||||
|
type: NodePort
|
||||||
|
port: 8087
|
||||||
|
targetPort: 8080
|
||||||
|
|
||||||
|
env:
|
||||||
|
mongoDatabase: DC_myDC
|
||||||
|
mongoUrl: mongodb://toto:27017
|
||||||
|
|
||||||
|
imagePullSecrets:
|
||||||
|
- name: regcred
|
||||||
4
main.go
4
main.go
@@ -16,7 +16,7 @@ func main() {
|
|||||||
// Load the right config file
|
// Load the right config file
|
||||||
o := oclib.GetConfLoader()
|
o := oclib.GetConfLoader()
|
||||||
|
|
||||||
// feed the library with the loaded config,
|
// feed the library with the loaded config
|
||||||
oclib.SetConfig(
|
oclib.SetConfig(
|
||||||
o.GetStringDefault("MONGO_URL", "mongodb://127.0.0.1:27017"),
|
o.GetStringDefault("MONGO_URL", "mongodb://127.0.0.1:27017"),
|
||||||
o.GetStringDefault("MONGO_DATABASE", "DC_myDC"),
|
o.GetStringDefault("MONGO_DATABASE", "DC_myDC"),
|
||||||
@@ -29,6 +29,6 @@ func main() {
|
|||||||
beego.BConfig.Listen.HTTPPort = o.GetIntDefault("port", 8080)
|
beego.BConfig.Listen.HTTPPort = o.GetIntDefault("port", 8080)
|
||||||
beego.BConfig.WebConfig.DirectoryIndex = true
|
beego.BConfig.WebConfig.DirectoryIndex = true
|
||||||
beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
|
beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
|
||||||
//}
|
|
||||||
beego.Run()
|
beego.Run()
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
oc-catalog
Executable file
BIN
oc-catalog
Executable file
Binary file not shown.
@@ -1,10 +1,10 @@
|
|||||||
// @APIVersion 1.0.0
|
// @APIVersion 1.0.0
|
||||||
// @Title beego Test API
|
// @Title oc-catalog
|
||||||
// @Description beego has a very cool tools to autogenerate documents for your API
|
// @Description OpenCloud catalog
|
||||||
// @Contact astaxie@gmail.com
|
// @Contact admin@o-cloud.io
|
||||||
// @TermsOfServiceUrl http://beego.me/
|
// @TermsOfServiceUrl http://cloud.o-forge.io/
|
||||||
// @License Apache 2.0
|
// @License MIT
|
||||||
// @LicenseUrl http://www.apache.org/licenses/LICENSE-2.0.html
|
// @LicenseUrl https://opensource.org/license/mit
|
||||||
package routers
|
package routers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
{
|
{
|
||||||
"swagger": "2.0",
|
"swagger": "2.0",
|
||||||
"info": {
|
"info": {
|
||||||
"title": "beego Test API",
|
"title": "oc-catalog",
|
||||||
"description": "beego has a very cool tools to autogenerate documents for your API\n",
|
"description": "OpenCloud catalog\n",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"termsOfService": "http://beego.me/",
|
"termsOfService": "http://cloud.o-forge.io/",
|
||||||
"contact": {
|
"contact": {
|
||||||
"email": "astaxie@gmail.com"
|
"email": "admin@o-cloud.io"
|
||||||
},
|
},
|
||||||
"license": {
|
"license": {
|
||||||
"name": "Apache 2.0",
|
"name": "MIT",
|
||||||
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
|
"url": "https://opensource.org/license/mit"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"basePath": "/oc/",
|
"basePath": "/oc/",
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
swagger: "2.0"
|
swagger: "2.0"
|
||||||
info:
|
info:
|
||||||
title: beego Test API
|
title: oc-catalog
|
||||||
description: |
|
description: |
|
||||||
beego has a very cool tools to autogenerate documents for your API
|
OpenCloud catalog
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
termsOfService: http://beego.me/
|
termsOfService: http://cloud.o-forge.io/
|
||||||
contact:
|
contact:
|
||||||
email: astaxie@gmail.com
|
email: admin@o-cloud.io
|
||||||
license:
|
license:
|
||||||
name: Apache 2.0
|
name: MIT
|
||||||
url: http://www.apache.org/licenses/LICENSE-2.0.html
|
url: https://opensource.org/license/mit
|
||||||
basePath: /oc/
|
basePath: /oc/
|
||||||
paths:
|
paths:
|
||||||
/data/:
|
/data/:
|
||||||
|
|||||||
Reference in New Issue
Block a user