Skip to content
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,5 @@ typings/

# End of https://www.gitignore.io/api/node,linux,visualstudiocode,intellij

.idea
.idea
/target/
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- [#72] Configuration options for resource requirements
- [#72] Defaults for CPU and memory requests

## [2.44.2-1]
### Changed
- Upgrade SCM-Manager to version 2.44.2 ([Changelog](https://github.com/scm-manager/scm-manager/blob/2.44.2/CHANGELOG.md))
Expand Down
58 changes: 58 additions & 0 deletions build/k8s-dogu-deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash

set -o errexit
set -o nounset
set -o pipefail

# Variables
BASE_DIR=".."
WORKDIR=$BASE_DIR
TARGET_DIR="$BASE_DIR/target"
# Path to the dogu json of the dogu
DOGU_JSON_FILE=${WORKDIR}/dogu.json
DOGU_JSON_DEV_FILE=${TARGET_DIR}/dogu.json
# Name of the dogu is extracted from the dogu.json
ARTIFACT_ID=$(jq -er ".Name" "${DOGU_JSON_FILE}" | sed "s|.*/||g")
# Namespace of the dogu is extracted from the dogu.json
ARTIFACT_NAMESPACE=$(jq -er ".Name" "${DOGU_JSON_FILE}" | sed "s|/.*||g")
# Namespace of the dogu is extracted from the dogu.json
VERSION=$(jq -er ".Version" ${DOGU_JSON_FILE})
# Image of the dogu is extracted from the dogu.json
IMAGE=$(jq -er ".Image" ${DOGU_JSON_FILE}):${VERSION}
K3S_CLUSTER_FQDN=k3ces.local
K3S_LOCAL_REGISTRY_PORT=30099
NAMESPACE="ecosystem"
K3CES_REGISTRY_URL_PREFIX="${K3S_CLUSTER_FQDN}:${K3S_LOCAL_REGISTRY_PORT}"
IMAGE_DEV_WITHOUT_TAG=$(jq -er ".Image" "${DOGU_JSON_FILE}" | sed "s|registry\.cloudogu\.com\(.\+\)|${K3CES_REGISTRY_URL_PREFIX}\1|g")
IMAGE_DEV="${IMAGE_DEV_WITHOUT_TAG}:${VERSION}"
K8S_RESOURCE_TEMP_YAML=${TARGET_DIR}/${ARTIFACT_ID}_${VERSION}.yaml
echo "$IMAGE_DEV_WITHOUT_TAG"
echo "$IMAGE_DEV"

echo "k8s image-import"
docker build "$BASE_DIR" -t "$IMAGE_DEV"
docker push "$IMAGE_DEV"

echo "generate modified dogu.json"
mkdir -p "$TARGET_DIR"
touch "$DOGU_JSON_DEV_FILE"
jq ".Image=\"$IMAGE_DEV_WITHOUT_TAG\"" "$DOGU_JSON_FILE" > "$DOGU_JSON_DEV_FILE"

echo "install dogu descriptor (dogu.json as configmap)"
kubectl create configmap "${ARTIFACT_ID}-descriptor" --from-file="${DOGU_JSON_DEV_FILE}" --dry-run=client -o yaml | kubectl apply -f - --namespace="${NAMESPACE}"

echo "create dogu resource"
cat <<EOF > "$K8S_RESOURCE_TEMP_YAML"
apiVersion: k8s.cloudogu.com/v1
kind: Dogu
metadata:
name: $ARTIFACT_ID
labels:
dogu: $ARTIFACT_ID
spec:
name: $ARTIFACT_NAMESPACE/$ARTIFACT_ID
version: $VERSION
EOF

echo "apply dogu resource"
kubectl apply -f "${K8S_RESOURCE_TEMP_YAML}" --namespace="${NAMESPACE}"
52 changes: 52 additions & 0 deletions dogu.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,58 @@
"Description": "Size of cache for working directories used to edit repository content, for example using the editor or the review plugin. To disable cache, clean this value.",
"Optional": true,
"Default": "5"
},
{
"Name": "container_config/memory_limit",
"Description":"Limits the container's memory usage. Use a positive integer value followed by one of these units [b,k,m,g] (byte, kibibyte, mebibyte, gibibyte).",
"Optional": true,
"Validation": {
"Type": "BINARY_MEASUREMENT"
}
},
{
"Name": "container_config/memory_request",
"Description":"Requests the container's minimal memory requirement. Use a positive integer value followed by one of these units [b,k,m,g] (byte, kibibyte, mebibyte, gibibyte).",
"Optional": true,
"Validation": {
"Type": "BINARY_MEASUREMENT"
},
"Default": "700m"
},
{
"Name": "container_config/swap_limit",
"Description":"Limits the container's swap memory usage. Use zero or a positive integer value followed by one of these units [b,k,m,g] (byte, kibibyte, mebibyte, gibibyte). 0 will disable swapping.",
"Optional": true,
"Validation": {
"Type": "BINARY_MEASUREMENT"
}
},
{
"Name": "container_config/cpu_core_limit",
"Description":"Limits the container's CPU core usage. Use a positive floating value describing a fraction of 1 CPU core. When you define a value of '0.5', you are requesting half as much CPU time compared to if you asked for '1.0' CPU.",
"Optional": true
},
{
"Name": "container_config/cpu_core_request",
"Description":"Requests the container's minimal CPU core requirement. Use a positive floating value describing a fraction of 1 CPU core. When you define a value of '0.5', you are requesting half as much CPU time compared to if you asked for '1.0' CPU.",
"Optional": true,
"Default": "1.0"
},
{
"Name": "container_config/storage_limit",
"Description":"Limits the container's ephemeral storage usage. Use a positive integer value followed by one of these units [b,k,m,g] (byte, kibibyte, mebibyte, gibibyte).",
"Optional": true,
"Validation": {
"Type": "BINARY_MEASUREMENT"
}
},
{
"Name": "container_config/storage_request",
"Description": "Requests the container's minimal ephemeral storage requirement. Use a positive integer value followed by one of these units [b,k,m,g] (byte, kibibyte, mebibyte, gibibyte).",
"Optional": true,
"Validation": {
"Type": "BINARY_MEASUREMENT"
}
}
],
"ExposedPorts": [
Expand Down