You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pc...@apache.org on 2024/01/26 08:53:59 UTC
(camel-k) 02/03: Add feature to insert annotations in the builder pod, from config
This is an automated email from the ASF dual-hosted git repository.
pcongiusti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit ab6217d4b6b43e96c9a4db5f9de2254fbddafbf7
Author: Rodrigue Cloutier <rc...@petalmd.com>
AuthorDate: Thu Jan 25 08:06:12 2024 -0500
Add feature to insert annotations in the builder pod, from config
---
config/crd/bases/camel.apache.org_builds.yaml | 54 ++++++++++++++++++++++
.../camel.apache.org_integrationplatforms.yaml | 12 +++++
docs/modules/ROOT/partials/apis/camel-k-crds.adoc | 7 +++
helm/camel-k/crds/crd-build.yaml | 54 ++++++++++++++++++++++
helm/camel-k/crds/crd-integration-platform.yaml | 12 +++++
pkg/apis/camel/v1/common_types.go | 2 +
pkg/apis/camel/v1/zz_generated.deepcopy.go | 7 +++
.../camel/v1/buildconfiguration.go | 15 ++++++
pkg/controller/build/build_pod.go | 3 +-
pkg/resources/resources.go | 8 ++--
10 files changed, 169 insertions(+), 5 deletions(-)
diff --git a/config/crd/bases/camel.apache.org_builds.yaml b/config/crd/bases/camel.apache.org_builds.yaml
index 6fd600e23..28f75654f 100644
--- a/config/crd/bases/camel.apache.org_builds.yaml
+++ b/config/crd/bases/camel.apache.org_builds.yaml
@@ -86,6 +86,12 @@ spec:
Build. Deprecated: no longer in use in Camel K 2 - maintained for
backward compatibility'
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ description: Annotation to use for the builder pod. Only used
+ for `pod` strategy
+ type: object
limitCPU:
description: The maximum amount of CPU required. Only used for
`pod` strategy
@@ -158,6 +164,12 @@ spec:
description: The configuration that should be used to perform
the Build.
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ description: Annotation to use for the builder pod.
+ Only used for `pod` strategy
+ type: object
limitCPU:
description: The maximum amount of CPU required. Only
used for `pod` strategy
@@ -256,6 +268,12 @@ spec:
description: The configuration that should be used to perform
the Build.
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ description: Annotation to use for the builder pod.
+ Only used for `pod` strategy
+ type: object
limitCPU:
description: The maximum amount of CPU required. Only
used for `pod` strategy
@@ -767,6 +785,12 @@ spec:
description: The configuration that should be used to perform
the Build.
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ description: Annotation to use for the builder pod.
+ Only used for `pod` strategy
+ type: object
limitCPU:
description: The maximum amount of CPU required. Only
used for `pod` strategy
@@ -836,6 +860,12 @@ spec:
description: The configuration that should be used to perform
the Build.
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ description: Annotation to use for the builder pod.
+ Only used for `pod` strategy
+ type: object
limitCPU:
description: The maximum amount of CPU required. Only
used for `pod` strategy
@@ -933,6 +963,12 @@ spec:
description: The configuration that should be used to perform
the Build.
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ description: Annotation to use for the builder pod.
+ Only used for `pod` strategy
+ type: object
limitCPU:
description: The maximum amount of CPU required. Only
used for `pod` strategy
@@ -1029,6 +1065,12 @@ spec:
description: The configuration that should be used to perform
the Build.
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ description: Annotation to use for the builder pod.
+ Only used for `pod` strategy
+ type: object
limitCPU:
description: The maximum amount of CPU required. Only
used for `pod` strategy
@@ -1531,6 +1573,12 @@ spec:
description: The configuration that should be used to perform
the Build.
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ description: Annotation to use for the builder pod.
+ Only used for `pod` strategy
+ type: object
limitCPU:
description: The maximum amount of CPU required. Only
used for `pod` strategy
@@ -1596,6 +1644,12 @@ spec:
description: The configuration that should be used to perform
the Build.
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ description: Annotation to use for the builder pod.
+ Only used for `pod` strategy
+ type: object
limitCPU:
description: The maximum amount of CPU required. Only
used for `pod` strategy
diff --git a/config/crd/bases/camel.apache.org_integrationplatforms.yaml b/config/crd/bases/camel.apache.org_integrationplatforms.yaml
index 3afa3fd0f..7d6b012d7 100644
--- a/config/crd/bases/camel.apache.org_integrationplatforms.yaml
+++ b/config/crd/bases/camel.apache.org_integrationplatforms.yaml
@@ -105,6 +105,12 @@ spec:
description: the configuration required to build an Integration
container image
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ description: Annotation to use for the builder pod. Only used
+ for `pod` strategy
+ type: object
limitCPU:
description: The maximum amount of CPU required. Only used
for `pod` strategy
@@ -1905,6 +1911,12 @@ spec:
description: the configuration required to build an Integration
container image
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ description: Annotation to use for the builder pod. Only used
+ for `pod` strategy
+ type: object
limitCPU:
description: The maximum amount of CPU required. Only used
for `pod` strategy
diff --git a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
index 0a65eef48..44c752fff 100644
--- a/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
+++ b/docs/modules/ROOT/partials/apis/camel-k-crds.adoc
@@ -608,6 +608,13 @@ map[string]string
The node selector for the builder pod. Only used for `pod` strategy
+|`annotations` +
+map[string]string
+|
+
+
+Annotation to use for the builder pod. Only used for `pod` strategy
+
|===
diff --git a/helm/camel-k/crds/crd-build.yaml b/helm/camel-k/crds/crd-build.yaml
index 6fd600e23..28f75654f 100644
--- a/helm/camel-k/crds/crd-build.yaml
+++ b/helm/camel-k/crds/crd-build.yaml
@@ -86,6 +86,12 @@ spec:
Build. Deprecated: no longer in use in Camel K 2 - maintained for
backward compatibility'
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ description: Annotation to use for the builder pod. Only used
+ for `pod` strategy
+ type: object
limitCPU:
description: The maximum amount of CPU required. Only used for
`pod` strategy
@@ -158,6 +164,12 @@ spec:
description: The configuration that should be used to perform
the Build.
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ description: Annotation to use for the builder pod.
+ Only used for `pod` strategy
+ type: object
limitCPU:
description: The maximum amount of CPU required. Only
used for `pod` strategy
@@ -256,6 +268,12 @@ spec:
description: The configuration that should be used to perform
the Build.
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ description: Annotation to use for the builder pod.
+ Only used for `pod` strategy
+ type: object
limitCPU:
description: The maximum amount of CPU required. Only
used for `pod` strategy
@@ -767,6 +785,12 @@ spec:
description: The configuration that should be used to perform
the Build.
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ description: Annotation to use for the builder pod.
+ Only used for `pod` strategy
+ type: object
limitCPU:
description: The maximum amount of CPU required. Only
used for `pod` strategy
@@ -836,6 +860,12 @@ spec:
description: The configuration that should be used to perform
the Build.
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ description: Annotation to use for the builder pod.
+ Only used for `pod` strategy
+ type: object
limitCPU:
description: The maximum amount of CPU required. Only
used for `pod` strategy
@@ -933,6 +963,12 @@ spec:
description: The configuration that should be used to perform
the Build.
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ description: Annotation to use for the builder pod.
+ Only used for `pod` strategy
+ type: object
limitCPU:
description: The maximum amount of CPU required. Only
used for `pod` strategy
@@ -1029,6 +1065,12 @@ spec:
description: The configuration that should be used to perform
the Build.
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ description: Annotation to use for the builder pod.
+ Only used for `pod` strategy
+ type: object
limitCPU:
description: The maximum amount of CPU required. Only
used for `pod` strategy
@@ -1531,6 +1573,12 @@ spec:
description: The configuration that should be used to perform
the Build.
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ description: Annotation to use for the builder pod.
+ Only used for `pod` strategy
+ type: object
limitCPU:
description: The maximum amount of CPU required. Only
used for `pod` strategy
@@ -1596,6 +1644,12 @@ spec:
description: The configuration that should be used to perform
the Build.
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ description: Annotation to use for the builder pod.
+ Only used for `pod` strategy
+ type: object
limitCPU:
description: The maximum amount of CPU required. Only
used for `pod` strategy
diff --git a/helm/camel-k/crds/crd-integration-platform.yaml b/helm/camel-k/crds/crd-integration-platform.yaml
index 3afa3fd0f..7d6b012d7 100644
--- a/helm/camel-k/crds/crd-integration-platform.yaml
+++ b/helm/camel-k/crds/crd-integration-platform.yaml
@@ -105,6 +105,12 @@ spec:
description: the configuration required to build an Integration
container image
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ description: Annotation to use for the builder pod. Only used
+ for `pod` strategy
+ type: object
limitCPU:
description: The maximum amount of CPU required. Only used
for `pod` strategy
@@ -1905,6 +1911,12 @@ spec:
description: the configuration required to build an Integration
container image
properties:
+ annotations:
+ additionalProperties:
+ type: string
+ description: Annotation to use for the builder pod. Only used
+ for `pod` strategy
+ type: object
limitCPU:
description: The maximum amount of CPU required. Only used
for `pod` strategy
diff --git a/pkg/apis/camel/v1/common_types.go b/pkg/apis/camel/v1/common_types.go
index 8dadcb3bb..fdcd68324 100644
--- a/pkg/apis/camel/v1/common_types.go
+++ b/pkg/apis/camel/v1/common_types.go
@@ -55,6 +55,8 @@ type BuildConfiguration struct {
LimitMemory string `property:"limit-memory" json:"limitMemory,omitempty"`
// The node selector for the builder pod. Only used for `pod` strategy
NodeSelector map[string]string `property:"node-selector" json:"nodeSelector,omitempty"`
+ // Annotation to use for the builder pod. Only used for `pod` strategy
+ Annotations map[string]string `property:"annotations" json:"annotations,omitempty"`
}
// BuildStrategy specifies how the Build should be executed.
diff --git a/pkg/apis/camel/v1/zz_generated.deepcopy.go b/pkg/apis/camel/v1/zz_generated.deepcopy.go
index f0d23440d..ed9b930e3 100644
--- a/pkg/apis/camel/v1/zz_generated.deepcopy.go
+++ b/pkg/apis/camel/v1/zz_generated.deepcopy.go
@@ -153,6 +153,13 @@ func (in *BuildConfiguration) DeepCopyInto(out *BuildConfiguration) {
(*out)[key] = val
}
}
+ if in.Annotations != nil {
+ in, out := &in.Annotations, &out.Annotations
+ *out = make(map[string]string, len(*in))
+ for key, val := range *in {
+ (*out)[key] = val
+ }
+ }
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BuildConfiguration.
diff --git a/pkg/client/camel/applyconfiguration/camel/v1/buildconfiguration.go b/pkg/client/camel/applyconfiguration/camel/v1/buildconfiguration.go
index e970d81d2..1b1f99777 100644
--- a/pkg/client/camel/applyconfiguration/camel/v1/buildconfiguration.go
+++ b/pkg/client/camel/applyconfiguration/camel/v1/buildconfiguration.go
@@ -35,6 +35,7 @@ type BuildConfigurationApplyConfiguration struct {
LimitCPU *string `json:"limitCPU,omitempty"`
LimitMemory *string `json:"limitMemory,omitempty"`
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
+ Annotations map[string]string `json:"annotations,omitempty"`
}
// BuildConfigurationApplyConfiguration constructs an declarative configuration of the BuildConfiguration type for use with
@@ -120,3 +121,17 @@ func (b *BuildConfigurationApplyConfiguration) WithNodeSelector(entries map[stri
}
return b
}
+
+// WithAnnotations puts the entries into the Annotations field in the declarative configuration
+// and returns the receiver, so that objects can be build by chaining "With" function invocations.
+// If called multiple times, the entries provided by each call will be put on the Annotations field,
+// overwriting an existing map entries in Annotations field with the same key.
+func (b *BuildConfigurationApplyConfiguration) WithAnnotations(entries map[string]string) *BuildConfigurationApplyConfiguration {
+ if b.Annotations == nil && len(entries) > 0 {
+ b.Annotations = make(map[string]string, len(entries))
+ }
+ for k, v := range entries {
+ b.Annotations[k] = v
+ }
+ return b
+}
diff --git a/pkg/controller/build/build_pod.go b/pkg/controller/build/build_pod.go
index ab9c433d5..2b2b87798 100644
--- a/pkg/controller/build/build_pod.go
+++ b/pkg/controller/build/build_pod.go
@@ -67,12 +67,13 @@ func newBuildPod(ctx context.Context, client client.Client, build *v1.Build) *co
"camel.apache.org/build": build.Name,
"camel.apache.org/component": "builder",
},
+ Annotations: build.BuilderConfiguration().Annotations,
},
Spec: corev1.PodSpec{
ServiceAccountName: platform.BuilderServiceAccount,
RestartPolicy: corev1.RestartPolicyNever,
SecurityContext: podSecurityContext,
- NodeSelector: build.TaskConfiguration("builder").NodeSelector,
+ NodeSelector: build.BuilderConfiguration().NodeSelector,
},
}
diff --git a/pkg/resources/resources.go b/pkg/resources/resources.go
index 4084f39b5..09dc7fdcf 100644
--- a/pkg/resources/resources.go
+++ b/pkg/resources/resources.go
@@ -117,9 +117,9 @@ var assets = func() http.FileSystem {
"/crd/bases/camel.apache.org_builds.yaml": &vfsgen۰CompressedFileInfo{
name: "camel.apache.org_builds.yaml",
modTime: time.Time{},
- uncompressedSize: 95791,
+ uncompressedSize: 98647,
- compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x7d\x6b\x73\x1b\x37\x96\xe8\x77\xfd\x8a\x53\xf1\x07\xcb\x55\x22\x35\xe3\x64\x67\xb3\xba\xb5\x75\x4b\x2b\x27\xb3\x1a\x27\xb6\xd7\x94\x3d\x99\xda\xda\x2a\x81\xdd\x87\x24\xc2\x6e\xa0\x2f\x80\x16\xcd\xdc\xba\xff\xfd\x16\x5e\xfd\x10\xd9\xdd\x00\x45\xda\x9e\x72\xe3\x4b\x62\xaa\x01\x9c\x83\xc7\x79\xe1\x3c\x9e\xc1\xe4\x78\xed\xec\x19\xfc\x42\x13\x64\x12\x53\x50\x1c\xd4\x0a\xe1\xba\x20\xc9\x0a\x61\xc6\x17\x6a\x43\x04\xc2\x [...]
+ compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x7d\x5d\x93\xdb\x38\x92\xe0\x7b\xfd\x8a\x8c\xf6\x83\xcb\x11\x92\x6a\xc6\xdd\x3b\xdb\x5b\x17\x1b\x17\xb5\xe5\xee\xd9\x1a\x77\xdb\x5e\xab\xec\xe9\x89\x8d\x8d\x28\x88\x4c\x49\x68\x91\x00\x0f\x00\x4b\x56\x5f\xdc\x7f\xbf\xc0\x17\x45\x4a\x22\x09\xa8\x24\xdb\x13\x26\x5e\xba\xad\x22\x12\x99\xf8\xc8\x2f\x24\x32\x9f\xc1\xf8\x74\xed\xe2\x19\xfc\x42\x13\x64\x12\x53\x50\x1c\xd4\x12\xe1\xa6\x20\xc9\x12\x61\xca\xe7\x6a\x4d\x04\x [...]
},
"/crd/bases/camel.apache.org_camelcatalogs.yaml": &vfsgen۰CompressedFileInfo{
name: "camel.apache.org_camelcatalogs.yaml",
@@ -138,9 +138,9 @@ var assets = func() http.FileSystem {
"/crd/bases/camel.apache.org_integrationplatforms.yaml": &vfsgen۰CompressedFileInfo{
name: "camel.apache.org_integrationplatforms.yaml",
modTime: time.Time{},
- uncompressedSize: 200434,
+ uncompressedSize: 201010,
- compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x7d\xff\x73\xdb\x36\xd2\xf7\xef\xfd\x2b\x30\xee\x3c\x13\xbb\xa3\x2f\x49\xef\x69\xaf\x8f\x9f\xeb\xbd\xaf\xeb\xa4\xad\x9b\x38\xf6\x6b\x3b\xb9\xbb\x69\x3b\x15\x44\xae\x24\xc4\x24\xc0\x03\x40\xd9\xea\xdc\x1f\xff\x0e\x16\x00\x49\x49\x14\x48\x7d\xb1\xe3\xb4\x52\x67\x1a\xdb\x22\xc0\x05\xb0\xd8\x5d\x2c\x76\x3f\xfb\x39\xe9\xee\xee\xf3\xd9\xe7\xe4\x0d\x8b\x80\x2b\x88\x89\x16\x44\x4f\x80\x9c\x64\x34\x9a\x00\xb9\x16\x23\x7d\x [...]
+ compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xec\x7d\xff\x73\xdb\x36\xd2\xf7\xef\xfd\x2b\x30\xee\x3c\x63\xa7\xa3\x2f\x49\xef\x69\xaf\x8f\x9f\xeb\xbd\xaf\xeb\xa4\xad\x9b\x38\xf6\x6b\x3b\xb9\xbb\x69\x3b\x15\x44\xae\x24\xc4\x24\xc0\x03\x40\xd9\xea\xdc\x1f\xff\x0e\x16\x00\x49\x49\x14\x48\x7d\xb1\xe3\xb4\x62\x67\x1a\x4b\x22\xc1\x05\xb0\xd8\x5d\x2c\x76\x3f\xfb\x39\xe9\xee\xee\xfa\xec\x73\xf2\x86\x45\xc0\x15\xc4\x44\x0b\xa2\x27\x40\x4e\x32\x1a\x4d\x80\x5c\x8b\x91\xbe\x [...]
},
"/crd/bases/camel.apache.org_integrations.yaml": &vfsgen۰CompressedFileInfo{
name: "camel.apache.org_integrations.yaml",