Skip to content

Commit b25835c

Browse files
authored
Merge pull request #73 from cloudogu/feature/72-add-configuration-options-for-resource-requirements
Feature/72 add configuration options for resource requirements
2 parents 272e8e0 + 09a8a13 commit b25835c

File tree

4 files changed

+117
-1
lines changed

4 files changed

+117
-1
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,5 @@ typings/
153153

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

156-
.idea
156+
.idea
157+
/target/

CHANGELOG.md

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

7+
## [Unreleased]
8+
### Added
9+
- [#72] Configuration options for resource requirements
10+
- [#72] Defaults for CPU and memory requests
11+
712
## [2.44.2-1]
813
### Changed
914
- Upgrade SCM-Manager to version 2.44.2 ([Changelog](https://github.com/scm-manager/scm-manager/blob/2.44.2/CHANGELOG.md))

build/k8s-dogu-deploy.sh

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/bash
2+
3+
set -o errexit
4+
set -o nounset
5+
set -o pipefail
6+
7+
# Variables
8+
BASE_DIR=".."
9+
WORKDIR=$BASE_DIR
10+
TARGET_DIR="$BASE_DIR/target"
11+
# Path to the dogu json of the dogu
12+
DOGU_JSON_FILE=${WORKDIR}/dogu.json
13+
DOGU_JSON_DEV_FILE=${TARGET_DIR}/dogu.json
14+
# Name of the dogu is extracted from the dogu.json
15+
ARTIFACT_ID=$(jq -er ".Name" "${DOGU_JSON_FILE}" | sed "s|.*/||g")
16+
# Namespace of the dogu is extracted from the dogu.json
17+
ARTIFACT_NAMESPACE=$(jq -er ".Name" "${DOGU_JSON_FILE}" | sed "s|/.*||g")
18+
# Namespace of the dogu is extracted from the dogu.json
19+
VERSION=$(jq -er ".Version" ${DOGU_JSON_FILE})
20+
# Image of the dogu is extracted from the dogu.json
21+
IMAGE=$(jq -er ".Image" ${DOGU_JSON_FILE}):${VERSION}
22+
K3S_CLUSTER_FQDN=k3ces.local
23+
K3S_LOCAL_REGISTRY_PORT=30099
24+
NAMESPACE="ecosystem"
25+
K3CES_REGISTRY_URL_PREFIX="${K3S_CLUSTER_FQDN}:${K3S_LOCAL_REGISTRY_PORT}"
26+
IMAGE_DEV_WITHOUT_TAG=$(jq -er ".Image" "${DOGU_JSON_FILE}" | sed "s|registry\.cloudogu\.com\(.\+\)|${K3CES_REGISTRY_URL_PREFIX}\1|g")
27+
IMAGE_DEV="${IMAGE_DEV_WITHOUT_TAG}:${VERSION}"
28+
K8S_RESOURCE_TEMP_YAML=${TARGET_DIR}/${ARTIFACT_ID}_${VERSION}.yaml
29+
echo "$IMAGE_DEV_WITHOUT_TAG"
30+
echo "$IMAGE_DEV"
31+
32+
echo "k8s image-import"
33+
docker build "$BASE_DIR" -t "$IMAGE_DEV"
34+
docker push "$IMAGE_DEV"
35+
36+
echo "generate modified dogu.json"
37+
mkdir -p "$TARGET_DIR"
38+
touch "$DOGU_JSON_DEV_FILE"
39+
jq ".Image=\"$IMAGE_DEV_WITHOUT_TAG\"" "$DOGU_JSON_FILE" > "$DOGU_JSON_DEV_FILE"
40+
41+
echo "install dogu descriptor (dogu.json as configmap)"
42+
kubectl create configmap "${ARTIFACT_ID}-descriptor" --from-file="${DOGU_JSON_DEV_FILE}" --dry-run=client -o yaml | kubectl apply -f - --namespace="${NAMESPACE}"
43+
44+
echo "create dogu resource"
45+
cat <<EOF > "$K8S_RESOURCE_TEMP_YAML"
46+
apiVersion: k8s.cloudogu.com/v1
47+
kind: Dogu
48+
metadata:
49+
name: $ARTIFACT_ID
50+
labels:
51+
dogu: $ARTIFACT_ID
52+
spec:
53+
name: $ARTIFACT_NAMESPACE/$ARTIFACT_ID
54+
version: $VERSION
55+
EOF
56+
57+
echo "apply dogu resource"
58+
kubectl apply -f "${K8S_RESOURCE_TEMP_YAML}" --namespace="${NAMESPACE}"

dogu.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,58 @@
130130
"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.",
131131
"Optional": true,
132132
"Default": "5"
133+
},
134+
{
135+
"Name": "container_config/memory_limit",
136+
"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).",
137+
"Optional": true,
138+
"Validation": {
139+
"Type": "BINARY_MEASUREMENT"
140+
}
141+
},
142+
{
143+
"Name": "container_config/memory_request",
144+
"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).",
145+
"Optional": true,
146+
"Validation": {
147+
"Type": "BINARY_MEASUREMENT"
148+
},
149+
"Default": "700m"
150+
},
151+
{
152+
"Name": "container_config/swap_limit",
153+
"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.",
154+
"Optional": true,
155+
"Validation": {
156+
"Type": "BINARY_MEASUREMENT"
157+
}
158+
},
159+
{
160+
"Name": "container_config/cpu_core_limit",
161+
"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.",
162+
"Optional": true
163+
},
164+
{
165+
"Name": "container_config/cpu_core_request",
166+
"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.",
167+
"Optional": true,
168+
"Default": "1.0"
169+
},
170+
{
171+
"Name": "container_config/storage_limit",
172+
"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).",
173+
"Optional": true,
174+
"Validation": {
175+
"Type": "BINARY_MEASUREMENT"
176+
}
177+
},
178+
{
179+
"Name": "container_config/storage_request",
180+
"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).",
181+
"Optional": true,
182+
"Validation": {
183+
"Type": "BINARY_MEASUREMENT"
184+
}
133185
}
134186
],
135187
"ExposedPorts": [

0 commit comments

Comments
 (0)