Skip to content

Commit

Permalink
crd: Expose "DefaultRuntimeClassName" to the CcInstallConfig
Browse files Browse the repository at this point in the history
This will allow users to define which runtime class they want to be used
as the default "kata" one.

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
  • Loading branch information
fidencio committed Aug 7, 2023
1 parent 6cf4bda commit 4cdd03e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
6 changes: 6 additions & 0 deletions api/v1beta1/ccruntime_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ type CcInstallConfig struct {
// +optional
RuntimeClassNames []string `json:"runtimeClassNames,omitempty"`

// This specifies the RuntimeClass to be used as the default one
// If not set, the default "kata" runtime class will NOT be created. Otherwise, the default "kata" runtime class will be created
// as as "alias" for the value set here
// +optional
DefaultRuntimeClassName string `json:"defaultRuntimeClassName,omitempty"`

// This specifies whether the CcRuntime (kata or enclave-cc) will be running on debug mode
// +optional
Debug bool `json:"debug,omitempty"`
Expand Down
6 changes: 6 additions & 0 deletions config/crd/bases/confidentialcontainers.org_ccruntimes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ spec:
description: This specifies whether the CcRuntime (kata or enclave-cc)
will be running on debug mode
type: boolean
defaultRuntimeClassName:
description: This specifies the RuntimeClass to be used as the
default one If not set, the default "kata" runtime class will
NOT be created. Otherwise, the default "kata" runtime class
will be created as as "alias" for the value set here
type: string
environmentVariables:
description: This specifies the environment variables required
by the daemon set
Expand Down
16 changes: 16 additions & 0 deletions controllers/ccruntime_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -654,11 +654,27 @@ func (r *CcRuntimeReconciler) processDaemonset(operation DaemonOperation) *appsv

var debug = strconv.FormatBool(r.ccRuntime.Spec.Config.Debug)

var defaultShim = ""
var createDefaultRuntimeClass = "false"
if strings.HasPrefix(r.ccRuntime.Spec.Config.DefaultRuntimeClassName, "kata-") {
// Remove the "kata-" prefix from DefaultRuntimeClassName
defaultShim = strings.TrimPrefix(r.ccRuntime.Spec.Config.DefaultRuntimeClassName, "kata-")
createDefaultRuntimeClass = "true"
}

var envVars = []corev1.EnvVar{
{
Name: "DEBUG",
Value: debug,
},
{
Name: "DEFAULT_SHIM",
Value: defaultShim,
},
{
Name: "CREATE_DEFAULT_RUNTIMECLASS",
Value: createDefaultRuntimeClass,
},
}
envVars = append(envVars, r.ccRuntime.Spec.Config.EnvironmentVariables...)

Expand Down

0 comments on commit 4cdd03e

Please sign in to comment.