Skip to content

Commit b4e0492

Browse files
committed
env variables and logging verbosity
1 parent 5adc8c4 commit b4e0492

File tree

10 files changed

+201
-0
lines changed

10 files changed

+201
-0
lines changed

api/crds/manifests/openmcp.cloud_clusterproviders.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,27 @@ spec:
4141
spec:
4242
description: ClusterProviderSpec defines the desired state of ClusterProvider.
4343
properties:
44+
env:
45+
description: Env is a list of environment variables to set in the
46+
containers of the init job and deployment of the provider.
47+
items:
48+
description: EnvVar represents an environment variable present in
49+
a Container.
50+
properties:
51+
name:
52+
description: Name is the name of the environment variable.
53+
minLength: 1
54+
type: string
55+
value:
56+
description: Value is the value of the environment variable.
57+
type: string
58+
required:
59+
- name
60+
type: object
61+
type: array
62+
x-kubernetes-list-map-keys:
63+
- name
64+
x-kubernetes-list-type: map
4465
image:
4566
description: Image is the name of the image of a provider.
4667
minLength: 1
@@ -59,6 +80,14 @@ spec:
5980
- name
6081
type: object
6182
type: array
83+
verbosity:
84+
default: INFO
85+
description: Verbosity is the verbosity level of the provider.
86+
enum:
87+
- DEBUG
88+
- INFO
89+
- ERROR
90+
type: string
6291
required:
6392
- image
6493
type: object

api/crds/manifests/openmcp.cloud_platformservices.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,27 @@ spec:
4141
spec:
4242
description: PlatformServiceSpec defines the desired state of PlatformService.
4343
properties:
44+
env:
45+
description: Env is a list of environment variables to set in the
46+
containers of the init job and deployment of the provider.
47+
items:
48+
description: EnvVar represents an environment variable present in
49+
a Container.
50+
properties:
51+
name:
52+
description: Name is the name of the environment variable.
53+
minLength: 1
54+
type: string
55+
value:
56+
description: Value is the value of the environment variable.
57+
type: string
58+
required:
59+
- name
60+
type: object
61+
type: array
62+
x-kubernetes-list-map-keys:
63+
- name
64+
x-kubernetes-list-type: map
4465
image:
4566
description: Image is the name of the image of a provider.
4667
minLength: 1
@@ -59,6 +80,14 @@ spec:
5980
- name
6081
type: object
6182
type: array
83+
verbosity:
84+
default: INFO
85+
description: Verbosity is the verbosity level of the provider.
86+
enum:
87+
- DEBUG
88+
- INFO
89+
- ERROR
90+
type: string
6291
required:
6392
- image
6493
type: object

api/crds/manifests/openmcp.cloud_serviceproviders.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,27 @@ spec:
4141
spec:
4242
description: ServiceProviderSpec defines the desired state of ServiceProvider.
4343
properties:
44+
env:
45+
description: Env is a list of environment variables to set in the
46+
containers of the init job and deployment of the provider.
47+
items:
48+
description: EnvVar represents an environment variable present in
49+
a Container.
50+
properties:
51+
name:
52+
description: Name is the name of the environment variable.
53+
minLength: 1
54+
type: string
55+
value:
56+
description: Value is the value of the environment variable.
57+
type: string
58+
required:
59+
- name
60+
type: object
61+
type: array
62+
x-kubernetes-list-map-keys:
63+
- name
64+
x-kubernetes-list-type: map
4465
image:
4566
description: Image is the name of the image of a provider.
4667
minLength: 1
@@ -59,6 +80,14 @@ spec:
5980
- name
6081
type: object
6182
type: array
83+
verbosity:
84+
default: INFO
85+
description: Verbosity is the verbosity level of the provider.
86+
enum:
87+
- DEBUG
88+
- INFO
89+
- ERROR
90+
type: string
6291
required:
6392
- image
6493
type: object

api/provider/v1alpha1/deployment_types.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ type DeploymentSpec struct {
3232
// ImagePullSecrets are secrets in the same namespace.
3333
// They can be used to fetch provider images from private registries.
3434
ImagePullSecrets []ObjectReference `json:"imagePullSecrets,omitempty"`
35+
36+
// Env is a list of environment variables to set in the containers of the init job and deployment of the provider.
37+
// +optional
38+
// +patchMergeKey=name
39+
// +patchStrategy=merge
40+
// +listType=map
41+
// +listMapKey=name
42+
Env []EnvVar `json:"env,omitempty" patchStrategy:"merge" patchMergeKey:"name"`
43+
44+
// Verbosity is the verbosity level of the provider.
45+
// +kubebuilder:validation:Enum=DEBUG;INFO;ERROR
46+
// +kubebuilder:default=INFO
47+
Verbosity string `json:"verbosity,omitempty"`
3548
}
3649

3750
// DeploymentStatus defines the observed state of a provider.
@@ -50,3 +63,13 @@ type ObjectReference struct {
5063
// +kubebuilder:validation:MinLength=1
5164
Name string `json:"name"`
5265
}
66+
67+
// EnvVar represents an environment variable present in a Container.
68+
type EnvVar struct {
69+
// Name is the name of the environment variable.
70+
// +kubebuilder:validation:MinLength=1
71+
Name string `json:"name"`
72+
// Value is the value of the environment variable.
73+
// +optional
74+
Value string `json:"value,omitempty"`
75+
}

api/provider/v1alpha1/zz_generated.deepcopy.go

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
## Controller
55

66
- [AccessRequest Controller](controller/accessrequest.md)
7+
- [Deployment Controllers](controller/deployment.md)
78
- [Cluster Scheduler](controller/scheduler.md)
89

910
## Resources

docs/controller/deployment.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Deployment Controllers
2+
3+
An OpenMCP landscape has three controllers (called _deployment controllers_) which are responsible for deploying other controllers (called _providers_):
4+
5+
- the **ClusterProvider Controller** is responsible for deploying cluster providers.
6+
- the **ServiceProvider Controller** is responsible for deploying service providers.
7+
- the **PlatformService Controller** is responsible for deploying platform services.
8+
9+
The deployments are specified in kubernetes resources of the kinds `ClusterProvider`, `ServiceProvider`, and `PlatformService` respectively.
10+
11+
## Provider Image
12+
13+
To be deployable, each provider must have an image available in a container registry. The image must have an executable as entrypoint. It will be used twice: to initialize the provider and to run it. For the initialization, a Job is started with the executable, and the following arguments are supplied:
14+
15+
```shell
16+
init
17+
--environment <environment>
18+
--verbosity <DEBUG, INFO, or ERROR>
19+
```
20+
21+
Once the initialization job has completed, a Deployment is created/updated with the same image and the following arguments:
22+
23+
```shell
24+
run
25+
--environment <environment>
26+
--verbosity <DEBUG|INFO|ERROR>
27+
```
28+
29+
## Provider Resource
30+
31+
The provider resources specify how to deploy the providers. They are of the kind `ClusterProvider`, `ServiceProvider`, or `PlatformService`. They are cluster-scoped, and have the following common structure:
32+
33+
```yaml
34+
apiVersion: openmcp.cloud/v1alpha1
35+
kind: <ClusterProvider|ServiceProvider|PlatformService>
36+
metadata:
37+
name: <name>
38+
spec:
39+
image: <image>
40+
imagePullSecrets:
41+
- name: <image-pull-secret-name>
42+
env:
43+
- name: <environment-variable-name>
44+
value: <environment-variable-value>
45+
verbosity: <DEBUG|INFO|ERROR>
46+
```
47+
48+
- The `image` field specifies the container image to use for the init job and deployment of the provider.
49+
- The `imagePullSecrets` field specifies a list of secrets that contain the credentials to pull the image from a registry.
50+
- The `env` field specifies a list of name-value pairs that are passed as environment variables to the init job and deployment of the provider.
51+
- The `verbosity` field specifies the logging level. Supported values are DEBUG, INFO, and ERROR. The default is INFO.

internal/controllers/provider/install/deployment.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ func (m *deploymentMutator) Mutate(d *appsv1.Deployment) error {
6767
Args: []string{
6868
"run",
6969
"--environment=" + m.values.Environment(),
70+
"--verbosity=" + m.values.Verbosity(),
7071
},
72+
Env: m.values.EnvironmentVariables(),
7173
},
7274
},
7375
ImagePullSecrets: m.values.ImagePullSecrets(),

internal/controllers/provider/install/job.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ func (m *jobMutator) Mutate(j *v1.Job) error {
7070
Args: []string{
7171
"init",
7272
"--environment=" + m.values.Environment(),
73+
"--verbosity=" + m.values.Verbosity(),
7374
},
75+
Env: m.values.EnvironmentVariables(),
7476
},
7577
},
7678
ServiceAccountName: m.values.NamespacedResourceName(initPrefix),

internal/controllers/provider/install/values.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,18 @@ func (v *Values) LabelsController() map[string]string {
100100
m["app.kubernetes.io/component"] = "controller"
101101
return m
102102
}
103+
104+
func (v *Values) Verbosity() string {
105+
return v.deploymentSpec.Verbosity
106+
}
107+
108+
func (v *Values) EnvironmentVariables() []corev1.EnvVar {
109+
env := make([]corev1.EnvVar, len(v.deploymentSpec.Env))
110+
for i, e := range v.deploymentSpec.Env {
111+
env[i] = corev1.EnvVar{
112+
Name: e.Name,
113+
Value: e.Value,
114+
}
115+
}
116+
return env
117+
}

0 commit comments

Comments
 (0)