Skip to content

Commit bac9aa3

Browse files
committed
Added dummy agent with helm chart for testing.
1 parent fe91721 commit bac9aa3

File tree

12 files changed

+567
-0
lines changed

12 files changed

+567
-0
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import org.springframework.boot.gradle.tasks.bundling.BootBuildImage
2+
import org.springframework.boot.gradle.tasks.bundling.BootJar
3+
4+
plugins {
5+
kotlin("plugin.spring") version "1.9.10"
6+
id("org.springframework.boot") version "3.1.5" // Use the latest compatible version
7+
id("io.spring.dependency-management") version "1.1.3"
8+
id("com.citi.helm") version "2.2.0"
9+
id("com.citi.helm-publish") version "2.2.0"
10+
}
11+
12+
dependencies {
13+
implementation("org.springframework.boot:spring-boot-starter-web")
14+
implementation("org.springframework.boot:spring-boot-starter-webflux")
15+
implementation("org.springframework.boot:spring-boot-starter-actuator")
16+
}
17+
18+
tasks.named<Test>("test") {
19+
enabled = false
20+
}
21+
22+
tasks.withType<BootJar> {
23+
mainClass.set("integration.AgentApplicationKt")
24+
}
25+
26+
tasks.named<BootBuildImage>("bootBuildImage") {
27+
if (project.hasProperty("REGISTRY_URL")) {
28+
val registryUrl = getProperty("REGISTRY_URL")
29+
val registryUsername = getProperty("REGISTRY_USERNAME")
30+
val registryPassword = getProperty("REGISTRY_PASSWORD")
31+
val registryNamespace = getProperty("REGISTRY_NAMESPACE")
32+
33+
imageName.set("$registryUrl/$registryNamespace/dummy-agent:0.1.0-SNAPSHOT")
34+
publish = true
35+
docker {
36+
publishRegistry {
37+
url.set(registryUrl)
38+
username.set(registryUsername)
39+
password.set(registryPassword)
40+
}
41+
}
42+
} else {
43+
imageName.set("${rootProject.name}:${project.version}")
44+
publish = false
45+
}
46+
}
47+
48+
helm {
49+
charts {
50+
create("main") {
51+
chartName.set("${project.name}-chart")
52+
chartVersion.set("${project.version}")
53+
sourceDir.set(file("src/main/helm"))
54+
}
55+
}
56+
}
57+
58+
tasks.register("helmPush") {
59+
description = "Push Helm chart to OCI registry"
60+
group = "helm"
61+
dependsOn(tasks.named("helmPackageMainChart"))
62+
63+
doLast {
64+
val registryUrl = getProperty("REGISTRY_URL")
65+
val registryUsername = getProperty("REGISTRY_USERNAME")
66+
val registryPassword = getProperty("REGISTRY_PASSWORD")
67+
val registryNamespace = getProperty("REGISTRY_NAMESPACE")
68+
69+
helm.execHelm("registry", "login") {
70+
option("-u", registryUsername)
71+
option("-p", registryPassword)
72+
args(registryUrl)
73+
}
74+
75+
helm.execHelm("push") {
76+
args(tasks.named("helmPackageMainChart").get().outputs.files.singleFile.toString())
77+
args("oci://$registryUrl/$registryNamespace")
78+
}
79+
80+
helm.execHelm("registry", "logout") {
81+
args(registryUrl)
82+
}
83+
}
84+
}
85+
86+
fun getProperty(propertyName: String) = System.getenv(propertyName) ?: project.findProperty(propertyName) as String
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
kotlin.code.style=official
2+
3+
chartName=dummy-agent
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
apiVersion: v2
2+
name: ${chartName}
3+
description: The Dummy Agent
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: ${chartVersion}
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
# It is recommended to use it with quotes.
24+
appVersion: ${projectVersion}
25+
home: https://github.com/eclipse-lmos/lmos-dummy-agents
26+
keywords:
27+
- lmos
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "dummy-agent.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "dummy-agent.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "dummy-agent.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "dummy-agent.labels" -}}
37+
helm.sh/chart: {{ include "dummy-agent.chart" . }}
38+
{{ include "dummy-agent.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "dummy-agent.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "dummy-agent.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "dummy-agent.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "dummy-agent.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}
63+
64+
{{/*
65+
Create Docker secrets for pulling images from a private container registry.
66+
*/}}
67+
{{- define "imagePullSecret" }}
68+
{{- printf "{\"auths\": {\"%s\": {\"auth\": \"%s\"}}}" .Values.imageCredentials.registry (printf "%s:%s" .Values.imageCredentials.username .Values.imageCredentials.password | b64enc) | b64enc }}
69+
{{- end }}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "dummy-agent.fullname" . }}
5+
labels:
6+
{{- include "dummy-agent.labels" . | nindent 4 }}
7+
wot-agent: "true"
8+
spec:
9+
{{- if not .Values.autoscaling.enabled }}
10+
replicas: {{ .Values.replicaCount }}
11+
{{- end }}
12+
selector:
13+
matchLabels:
14+
{{- include "dummy-agent.selectorLabels" . | nindent 6 }}
15+
template:
16+
metadata:
17+
{{- with .Values.podAnnotations }}
18+
annotations:
19+
{{- toYaml . | nindent 8 }}
20+
{{- end }}
21+
labels:
22+
{{- include "dummy-agent.labels" . | nindent 8 }}
23+
app: {{ include "dummy-agent.fullname" . }} # Adding app label for istio
24+
version: {{ .Chart.AppVersion | quote }} # Adding version label for istio
25+
{{- with .Values.podLabels }}
26+
{{- toYaml . | nindent 8 }}
27+
{{- end }}
28+
spec:
29+
{{- with .Values.imagePullSecrets }}
30+
imagePullSecrets:
31+
{{- toYaml . | nindent 8 }}
32+
{{- end }}
33+
securityContext:
34+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
35+
containers:
36+
- name: {{ .Chart.Name }}
37+
securityContext:
38+
{{- toYaml .Values.securityContext | nindent 12 }}
39+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
40+
imagePullPolicy: Always
41+
ports:
42+
- name: http
43+
containerPort: {{ .Values.service.port }}
44+
protocol: TCP
45+
livenessProbe:
46+
{{- toYaml .Values.livenessProbe | nindent 12 }}
47+
readinessProbe:
48+
{{- toYaml .Values.readinessProbe | nindent 12 }}
49+
resources:
50+
{{- toYaml .Values.resources | nindent 12 }}
51+
{{- with .Values.volumeMounts }}
52+
volumeMounts:
53+
{{- toYaml . | nindent 12 }}
54+
{{- end }}
55+
{{- with .Values.volumes }}
56+
volumes:
57+
{{- toYaml . | nindent 8 }}
58+
{{- end }}
59+
{{- with .Values.nodeSelector }}
60+
nodeSelector:
61+
{{- toYaml . | nindent 8 }}
62+
{{- end }}
63+
{{- with .Values.affinity }}
64+
affinity:
65+
{{- toYaml . | nindent 8 }}
66+
{{- end }}
67+
{{- with .Values.tolerations }}
68+
tolerations:
69+
{{- toYaml . | nindent 8 }}
70+
{{- end }}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ include "dummy-agent.fullname" . }}
5+
labels:
6+
{{- include "dummy-agent.labels" . | nindent 4 }}
7+
spec:
8+
type: {{ .Values.service.type }}
9+
ports:
10+
- port: {{ .Values.service.port }}
11+
targetPort: {{ .Values.service.port }}
12+
protocol: TCP
13+
name: http
14+
selector:
15+
{{- include "dummy-agent.selectorLabels" . | nindent 4 }}
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Default values for arc-dummy-agent.
2+
# This is a YAML-formatted file.
3+
# Declare variables to be passed into your templates.
4+
5+
replicaCount: 1
6+
7+
image:
8+
repository: ghcr.io/sbussweiler/dummy-agent
9+
tag: 0.1.0-SNAPSHOT
10+
pullPolicy: IfNotPresent
11+
12+
nameOverride: "dummy-agent"
13+
fullnameOverride: "dummy-agent"
14+
15+
podAnnotations: {}
16+
podLabels: {}
17+
18+
podSecurityContext: {}
19+
# fsGroup: 2000
20+
21+
securityContext: {}
22+
# capabilities:
23+
# drop:
24+
# - ALL
25+
# readOnlyRootFilesystem: true
26+
# runAsNonRoot: true
27+
# runAsUser: 1000
28+
29+
service:
30+
type: ClusterIP
31+
port: 8080
32+
33+
ingress:
34+
enabled: false
35+
className: ""
36+
annotations: {}
37+
# kubernetes.io/ingress.class: nginx
38+
# kubernetes.io/tls-acme: "true"
39+
hosts:
40+
- host: chart-example.local
41+
paths:
42+
- path: /
43+
pathType: ImplementationSpecific
44+
tls: []
45+
# - secretName: chart-example-tls
46+
# hosts:
47+
# - chart-example.local
48+
49+
resources: {}
50+
# We usually recommend not to specify default resources and to leave this as a conscious
51+
# choice for the user. This also increases chances charts run on environments with little
52+
# resources, such as Minikube. If you do want to specify resources, uncomment the following
53+
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
54+
# limits:
55+
# cpu: 100m
56+
# memory: 128Mi
57+
# requests:
58+
# cpu: 100m
59+
# memory: 128Mi
60+
61+
#livenessProbe:
62+
# httpGet:
63+
# path: /health
64+
# port: 9090
65+
# initialDelaySeconds: 20
66+
#readinessProbe:
67+
# httpGet:
68+
# path: /health
69+
# port: 9090
70+
# initialDelaySeconds: 20
71+
72+
#readinessProbe:
73+
# httpGet:
74+
# path: "/health/readiness"
75+
# port: 9090
76+
# initialDelaySeconds: 30
77+
# timeoutSeconds: 5
78+
# periodSeconds: 10
79+
# failureThreshold: 3
80+
#livenessProbe:
81+
# httpGet:
82+
# path: "/health/liveness"
83+
# port: 9090
84+
# initialDelaySeconds: 30
85+
# timeoutSeconds: 5
86+
# periodSeconds: 10
87+
# failureThreshold: 3
88+
89+
autoscaling:
90+
enabled: false
91+
minReplicas: 1
92+
maxReplicas: 100
93+
targetCPUUtilizationPercentage: 80
94+
# targetMemoryUtilizationPercentage: 80
95+
96+
# Additional volumes on the output Deployment definition.
97+
volumes: []
98+
# - name: foo
99+
# secret:
100+
# secretName: mysecret
101+
# optional: false
102+
103+
# Additional volumeMounts on the output Deployment definition.
104+
volumeMounts: []
105+
# - name: foo
106+
# mountPath: "/etc/foo"
107+
# readOnly: true
108+
109+
nodeSelector: {}
110+
111+
tolerations: []
112+
113+
affinity: {}
114+
115+
customApiGroup: lmos.eclipse
116+
customResources:
117+
- agents
118+

0 commit comments

Comments
 (0)