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
29 changes: 29 additions & 0 deletions api/crds/manifests/openmcp.cloud_clusterproviders.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,27 @@ spec:
spec:
description: ClusterProviderSpec defines the desired state of ClusterProvider.
properties:
env:
description: Env is a list of environment variables to set in the
containers of the init job and deployment of the provider.
items:
description: EnvVar represents an environment variable present in
a Container.
properties:
name:
description: Name is the name of the environment variable.
minLength: 1
type: string
value:
description: Value is the value of the environment variable.
type: string
required:
- name
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
image:
description: Image is the name of the image of a provider.
minLength: 1
Expand All @@ -59,6 +80,14 @@ spec:
- name
type: object
type: array
verbosity:
default: INFO
description: Verbosity is the verbosity level of the provider.
enum:
- DEBUG
- INFO
- ERROR
type: string
required:
- image
type: object
Expand Down
29 changes: 29 additions & 0 deletions api/crds/manifests/openmcp.cloud_platformservices.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,27 @@ spec:
spec:
description: PlatformServiceSpec defines the desired state of PlatformService.
properties:
env:
description: Env is a list of environment variables to set in the
containers of the init job and deployment of the provider.
items:
description: EnvVar represents an environment variable present in
a Container.
properties:
name:
description: Name is the name of the environment variable.
minLength: 1
type: string
value:
description: Value is the value of the environment variable.
type: string
required:
- name
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
image:
description: Image is the name of the image of a provider.
minLength: 1
Expand All @@ -59,6 +80,14 @@ spec:
- name
type: object
type: array
verbosity:
default: INFO
description: Verbosity is the verbosity level of the provider.
enum:
- DEBUG
- INFO
- ERROR
type: string
required:
- image
type: object
Expand Down
29 changes: 29 additions & 0 deletions api/crds/manifests/openmcp.cloud_serviceproviders.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,27 @@ spec:
spec:
description: ServiceProviderSpec defines the desired state of ServiceProvider.
properties:
env:
description: Env is a list of environment variables to set in the
containers of the init job and deployment of the provider.
items:
description: EnvVar represents an environment variable present in
a Container.
properties:
name:
description: Name is the name of the environment variable.
minLength: 1
type: string
value:
description: Value is the value of the environment variable.
type: string
required:
- name
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
image:
description: Image is the name of the image of a provider.
minLength: 1
Expand All @@ -59,6 +80,14 @@ spec:
- name
type: object
type: array
verbosity:
default: INFO
description: Verbosity is the verbosity level of the provider.
enum:
- DEBUG
- INFO
- ERROR
type: string
required:
- image
type: object
Expand Down
23 changes: 23 additions & 0 deletions api/provider/v1alpha1/deployment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ type DeploymentSpec struct {
// ImagePullSecrets are secrets in the same namespace.
// They can be used to fetch provider images from private registries.
ImagePullSecrets []ObjectReference `json:"imagePullSecrets,omitempty"`

// Env is a list of environment variables to set in the containers of the init job and deployment of the provider.
// +optional
// +patchMergeKey=name
// +patchStrategy=merge
// +listType=map
// +listMapKey=name
Env []EnvVar `json:"env,omitempty" patchStrategy:"merge" patchMergeKey:"name"`

// Verbosity is the verbosity level of the provider.
// +kubebuilder:validation:Enum=DEBUG;INFO;ERROR
// +kubebuilder:default=INFO
Verbosity string `json:"verbosity,omitempty"`
}

// DeploymentStatus defines the observed state of a provider.
Expand All @@ -50,3 +63,13 @@ type ObjectReference struct {
// +kubebuilder:validation:MinLength=1
Name string `json:"name"`
}

// EnvVar represents an environment variable present in a Container.
type EnvVar struct {
// Name is the name of the environment variable.
// +kubebuilder:validation:MinLength=1
Name string `json:"name"`
// Value is the value of the environment variable.
// +optional
Value string `json:"value,omitempty"`
}
20 changes: 20 additions & 0 deletions api/provider/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
## Controller

- [AccessRequest Controller](controller/accessrequest.md)
- [Deployment Controllers](controller/deployment.md)
- [Cluster Scheduler](controller/scheduler.md)

## Resources
Expand Down
51 changes: 51 additions & 0 deletions docs/controller/deployment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Deployment Controllers

An OpenMCP landscape has three controllers (called _deployment controllers_) which are responsible for deploying other controllers (called _providers_):

- the **ClusterProvider Controller** is responsible for deploying cluster providers.
- the **ServiceProvider Controller** is responsible for deploying service providers.
- the **PlatformService Controller** is responsible for deploying platform services.

The deployments are specified in kubernetes resources of the kinds `ClusterProvider`, `ServiceProvider`, and `PlatformService` respectively.

## Provider Image

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:

```shell
init
--environment <environment>
--verbosity <DEBUG, INFO, or ERROR>
```

Once the initialization job has completed, a Deployment is created/updated with the same image and the following arguments:

```shell
run
--environment <environment>
--verbosity <DEBUG|INFO|ERROR>
```

## Provider Resource

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:

```yaml
apiVersion: openmcp.cloud/v1alpha1
kind: <ClusterProvider|ServiceProvider|PlatformService>
metadata:
name: <name>
spec:
image: <image>
imagePullSecrets:
- name: <image-pull-secret-name>
env:
- name: <environment-variable-name>
value: <environment-variable-value>
verbosity: <DEBUG|INFO|ERROR>
```

- The `image` field specifies the container image to use for the init job and deployment of the provider.
- The `imagePullSecrets` field specifies a list of secrets that contain the credentials to pull the image from a registry.
- 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.
- The `verbosity` field specifies the logging level. Supported values are DEBUG, INFO, and ERROR. The default is INFO.
2 changes: 2 additions & 0 deletions internal/controllers/provider/install/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ func (m *deploymentMutator) Mutate(d *appsv1.Deployment) error {
Args: []string{
"run",
"--environment=" + m.values.Environment(),
"--verbosity=" + m.values.Verbosity(),
},
Env: m.values.EnvironmentVariables(),
},
},
ImagePullSecrets: m.values.ImagePullSecrets(),
Expand Down
2 changes: 2 additions & 0 deletions internal/controllers/provider/install/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ func (m *jobMutator) Mutate(j *v1.Job) error {
Args: []string{
"init",
"--environment=" + m.values.Environment(),
"--verbosity=" + m.values.Verbosity(),
},
Env: m.values.EnvironmentVariables(),
},
},
ServiceAccountName: m.values.NamespacedResourceName(initPrefix),
Expand Down
15 changes: 15 additions & 0 deletions internal/controllers/provider/install/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,18 @@ func (v *Values) LabelsController() map[string]string {
m["app.kubernetes.io/component"] = "controller"
return m
}

func (v *Values) Verbosity() string {
return v.deploymentSpec.Verbosity
}

func (v *Values) EnvironmentVariables() []corev1.EnvVar {
env := make([]corev1.EnvVar, len(v.deploymentSpec.Env))
for i, e := range v.deploymentSpec.Env {
env[i] = corev1.EnvVar{
Name: e.Name,
Value: e.Value,
}
}
return env
}