Skip to content

Commit

Permalink
controller: add support to pull_type
Browse files Browse the repository at this point in the history
The same way we can customize the snapshotter to be used by the runtime
class, lets add a new property to customize the pulling image method.

Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
Signed-off-by: Beraldo Leal <bleal@redhat.com>
  • Loading branch information
wainersm authored and beraldoleal committed Jul 10, 2024
1 parent c4f2024 commit dc8314c
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 1 deletion.
4 changes: 3 additions & 1 deletion api/v1beta1/ccruntime_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,14 @@ type FailedNodeStatus struct {
Error string `json:"error"`
}

// RuntimeClass holds the name and the snapshotter to be used by a runtime class
// RuntimeClass holds the name and basic customizations to be used by a runtime class
type RuntimeClass struct {
// Name of the runtime class
Name string `json:"name"`
// The snapshotter to be used by the runtime class
Snapshotter string `json:"snapshotter"`
// The pulling image method to be used by the runtime class
PullType string `json:"pulltype"`
}

func init() {
Expand Down
5 changes: 5 additions & 0 deletions config/samples/ccruntime/default/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,19 @@ patches:
value:
- name: "kata-clh"
snapshotter: "nydus"
pulltype: ""
- name: "kata-qemu"
snapshotter: "nydus"
pulltype: ""
- name: "kata-qemu-tdx"
snapshotter: "nydus"
pulltype: ""
- name: "kata-qemu-sev"
snapshotter: "nydus"
pulltype: ""
- name: "kata-qemu-snp"
snapshotter: "nydus"
pulltype: ""
- op: add
path: /spec/config/defaultRuntimeClassName
value: "kata-qemu"
Expand Down
1 change: 1 addition & 0 deletions config/samples/ccruntime/peer-pods/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ patches:
value:
- name: "kata-remote"
snapshotter: "nydus"
pulltype: "guest-pull"
- op: add
path: /spec/config/debug
value: false
Expand Down
2 changes: 2 additions & 0 deletions config/samples/ccruntime/s390x/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ patches:
value:
- name: "kata-qemu"
snapshotter: "nydus"
pulltype: ""
- name: "kata-qemu-se"
snapshotter: "nydus"
pulltype: ""
- op: add
path: /spec/config/defaultRuntimeClassName
value: "kata-qemu"
Expand Down
1 change: 1 addition & 0 deletions config/samples/enclave-cc/base/ccruntime-enclave-cc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ spec:
runtimeClasses:
- name: "enclave-cc"
snapshotter: "overlayfs"
pulltype: ""
postUninstall:
image: quay.io/confidential-containers/reqs-payload
volumeMounts:
Expand Down
10 changes: 10 additions & 0 deletions controllers/ccruntime_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,7 @@ func (r *CcRuntimeReconciler) processDaemonset(operation DaemonOperation) *appsv

var shims []string
var snapshotter_handler_mapping []string
var pull_type_mapping []string
for _, runtimeClass := range r.ccRuntime.Spec.Config.RuntimeClasses {
// Similarly to what's being done for the default shim, let's remove
// the "kata-" prefix from the runtime class names
Expand All @@ -640,6 +641,11 @@ func (r *CcRuntimeReconciler) processDaemonset(operation DaemonOperation) *appsv
mapping := shim + ":" + runtimeClass.Snapshotter
snapshotter_handler_mapping = append(snapshotter_handler_mapping, mapping)
}

if runtimeClass.PullType != "" {
mapping := shim + ":" + runtimeClass.PullType
pull_type_mapping = append(pull_type_mapping, mapping)
}
}

var envVars = []corev1.EnvVar{
Expand Down Expand Up @@ -675,6 +681,10 @@ func (r *CcRuntimeReconciler) processDaemonset(operation DaemonOperation) *appsv
Name: "SNAPSHOTTER_HANDLER_MAPPING",
Value: strings.Join(snapshotter_handler_mapping, ","),
},
{
Name: "PULL_TYPE_MAPPING",
Value: strings.Join(pull_type_mapping, ","),
},
}
envVars = append(envVars, r.ccRuntime.Spec.Config.EnvironmentVariables...)

Expand Down

0 comments on commit dc8314c

Please sign in to comment.