Skip to content
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

Enhance pkg-level config and recommendation feature #123

Merged
merged 4 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 22 additions & 23 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ RUN --mount=type=cache,target=/go/pkg/mod \
# Copy some necessary files to the container
COPY api ./api
COPY cmd/cm-beetle ./cmd/cm-beetle
COPY conf ./conf
COPY pkg ./pkg
COPY scripts ./scripts
# COPY conf ./conf

# Build the Go app
RUN --mount=type=cache,target=/go/pkg/mod \
Expand All @@ -46,17 +46,27 @@ RUN apt-get update && apt-get install -y --no-install-recommends \

## Copy the Pre-built binary and necessary files from the previous stage
COPY --from=builder /go/src/github.com/cloud-barista/cm-beetle/scripts/ /app/scripts/
COPY --from=builder /go/src/github.com/cloud-barista/cm-beetle/conf/ /app/conf/
COPY --from=builder /go/src/github.com/cloud-barista/cm-beetle/cmd/cm-beetle/cm-beetle /app/
COPY --from=builder /go/src/github.com/cloud-barista/cm-beetle/api/ /app/api/
# COPY --from=builder /go/src/github.com/cloud-barista/cm-beetle/conf/ /app/conf/

## Set environment variables
# Set system endpoints
ENV BEETLE_ROOT=/app \
BEETLE_CBSTORE_ROOT=/app \
BEETLE_CBLOG_ROOT=/app
ENV BEETLE_ROOT=/app

ENV BEETLE_TUMBLEBUG_REST_URL=http://localhost:1323/tumblebug
## Set SELF_ENDPOINT, to access Swagger API dashboard outside (Ex: export SELF_ENDPOINT=x.x.x.x:8056)
ENV BEETLE_SELF_ENDPOINT=localhost:8056

## Set API access config
# API_ALLOW_ORIGINS (ex: https://cloud-barista.org,xxx.xxx.xxx.xxx or * for all)
# Set ENABLE_AUTH=true currently for basic auth for all routes (i.e., url or path)
ENV BEETLE_API_ALLOW_ORIGINS=* \
BEETLE_API_AUTH_ENABLED=true \
BEETLE_API_USERNAME=default \
BEETLE_API_PASSWORD=default

## Set internal DB config (lkvstore: local key-value store, default file path: ./db/beetle.db)
ENV BEETLE_LKVSTORE_PATH=/app/db/beetle.db

## Logger configuration
# Set log file path (default logfile path: ./beetle.log)
Expand All @@ -66,30 +76,19 @@ ENV BEETLE_LOGFILE_PATH=/app/log/beetle.log \
BEETLE_LOGFILE_MAXBACKUPS=3 \
BEETLE_LOGFILE_MAXAGE=30 \
BEETLE_LOGFILE_COMPRESS=false \
BEETLE_LOGLEVEL=info
BEETLE_LOGLEVEL=info \
BEETLE_LOGWRITER=both

# Set execution environment, such as development or production
ENV BEETLE_NODE_ENV=production

## Set internal DB config (SQLlite)
ENV BEETLE_SQLITE_URL=localhost:3306 \
BEETLE_SQLITE_DATABASE=cm_beetle \
BEETLE_SQLITE_USER=cm_beetle \
BEETLE_SQLITE_PASSWORD=cm_beetle

## Set API access config
# API_ALLOW_ORIGINS (ex: https://cloud-barista.org,xxx.xxx.xxx.xxx or * for all)
# Set ENABLE_AUTH=true currently for basic auth for all routes (i.e., url or path)
ENV BEETLE_API_ALLOW_ORIGINS=* \
BEETLE_API_AUTH_ENABLED=true \
BEETLE_API_USERNAME=default \
BEETLE_API_PASSWORD=default

## Set period for auto control goroutine invocation
ENV BEETLE_AUTOCONTROL_DURATION_MS=10000

## Set SELF_ENDPOINT, to access Swagger API dashboard outside (Ex: export SELF_ENDPOINT=x.x.x.x:8056)
ENV BEETLE_SELF_ENDPOINT=localhost:8056
## Set Tumblebug access config
ENV BEETLE_TUMBLEBUG_REST_URL=http://localhost:1323 \
BEETLE_TUMBLEBUG_API_USERNAME=default \
BEETLE_TUMBLEBUG_API_PASSWORD=default

ENTRYPOINT [ "/app/cm-beetle" ]

Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ clean: ## Remove previous build
@cd cmd/$(MODULE_NAME) && $(GO) clean
@echo "Cleaned!"

compose: swag ## Build and up services by docker compose
@echo "Building and starting services by docker compose..."
@cd deployments/docker-compose && DOCKER_BUILDKIT=1 docker compose up --build

compose-up: ## Up services by docker compose
@echo "Starting services by docker compose..."
@cd deployments/docker-compose && docker compose up

compose-build-up: swag ## Build and up services by docker compose
@echo "Building and starting services by docker compose..."
@cd deployments/docker-compose && DOCKER_BUILDKIT=1 docker compose up --build

compose-down: ## Down services by docker compose
@echo "Removing services by docker compose..."
@cd deployments/docker-compose && docker compose down
Expand Down
188 changes: 101 additions & 87 deletions api/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,13 @@ const docTemplate = `{
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/github_com_cloud-barista_cm-beetle_pkg_core_common.SimpleMsg"
"$ref": "#/definitions/common.SimpleMsg"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/github_com_cloud-barista_cm-beetle_pkg_core_common.SimpleMsg"
"$ref": "#/definitions/common.SimpleMsg"
}
}
}
Expand Down Expand Up @@ -555,6 +555,15 @@ const docTemplate = `{
}
}
},
"common.SimpleMsg": {
"type": "object",
"properties": {
"message": {
"type": "string",
"example": "Any message"
}
}
},
"controller.CreateUserRequest": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -632,7 +641,7 @@ const docTemplate = `{
"vm": {
"type": "array",
"items": {
"$ref": "#/definitions/mci.TbVmDynamicReq"
"$ref": "#/definitions/model.TbVmDynamicReq"
}
}
}
Expand Down Expand Up @@ -675,7 +684,7 @@ const docTemplate = `{
"vm": {
"type": "array",
"items": {
"$ref": "#/definitions/mci.TbVmDynamicReq"
"$ref": "#/definitions/model.TbVmDynamicReq"
}
}
}
Expand Down Expand Up @@ -724,44 +733,15 @@ const docTemplate = `{
},
"controller.RecommendInfraResponse": {
"type": "object",
"required": [
"name",
"vm"
],
"properties": {
"description": {
"type": "string",
"example": "Made in CB-TB"
},
"installMonAgent": {
"description": "InstallMonAgent Option for CB-Dragonfly agent installation ([yes/no] default:yes)",
"type": "string",
"default": "no",
"enum": [
"yes",
"no"
],
"example": "no"
},
"label": {
"description": "Label is for describing the mci in a keyword (any string can be used)",
"type": "string",
"example": "DynamicVM"
},
"name": {
"type": "string",
"example": "mci01"
"type": "string"
},
"systemLabel": {
"description": "SystemLabel is for describing the mci in a keyword (any string can be used) for special System purpose",
"type": "string",
"example": ""
"status": {
"type": "string"
},
"vm": {
"type": "array",
"items": {
"$ref": "#/definitions/mci.TbVmDynamicReq"
}
"targetInfra": {
"$ref": "#/definitions/model.TbMciDynamicReq"
}
}
},
Expand Down Expand Up @@ -793,15 +773,6 @@ const docTemplate = `{
}
}
},
"github_com_cloud-barista_cm-beetle_pkg_core_common.SimpleMsg": {
"type": "object",
"properties": {
"message": {
"type": "string",
"example": "Any message"
}
}
},
"infra.CPU": {
"type": "object",
"required": [
Expand Down Expand Up @@ -1165,7 +1136,89 @@ const docTemplate = `{
}
}
},
"mci.TbVmDynamicReq": {
"model.MyUser": {
"type": "object",
"properties": {
"email": {
"type": "string"
},
"id": {
"type": "integer"
},
"name": {
"type": "string"
}
}
},
"model.Response": {
"type": "object",
"properties": {
"details": {
"type": "string",
"example": "Any details"
},
"list": {
"type": "array",
"items": {}
},
"object": {
"type": "object",
"additionalProperties": true
},
"success": {
"type": "boolean",
"example": true
},
"text": {
"type": "string",
"example": "Any text"
}
}
},
"model.TbMciDynamicReq": {
"type": "object",
"required": [
"name",
"vm"
],
"properties": {
"description": {
"type": "string",
"example": "Made in CB-TB"
},
"installMonAgent": {
"description": "InstallMonAgent Option for CB-Dragonfly agent installation ([yes/no] default:yes)",
"type": "string",
"default": "no",
"enum": [
"yes",
"no"
],
"example": "no"
},
"label": {
"description": "Label is for describing the mci in a keyword (any string can be used)",
"type": "string",
"example": "DynamicVM"
},
"name": {
"type": "string",
"example": "mci01"
},
"systemLabel": {
"description": "SystemLabel is for describing the mci in a keyword (any string can be used) for special System purpose",
"type": "string",
"example": ""
},
"vm": {
"type": "array",
"items": {
"$ref": "#/definitions/model.TbVmDynamicReq"
}
}
}
},
"model.TbVmDynamicReq": {
"type": "object",
"required": [
"commonImage",
Expand Down Expand Up @@ -1222,45 +1275,6 @@ const docTemplate = `{
}
}
},
"model.MyUser": {
"type": "object",
"properties": {
"email": {
"type": "string"
},
"id": {
"type": "integer"
},
"name": {
"type": "string"
}
}
},
"model.Response": {
"type": "object",
"properties": {
"details": {
"type": "string",
"example": "Any details"
},
"list": {
"type": "array",
"items": {}
},
"object": {
"type": "object",
"additionalProperties": true
},
"success": {
"type": "boolean",
"example": true
},
"text": {
"type": "string",
"example": "Any text"
}
}
},
"network.CSP": {
"type": "object",
"properties": {
Expand Down
Loading