Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

controller: Ensure the runtimeclass was created by the payload #245

Closed
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
14 changes: 13 additions & 1 deletion .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
services:
registry:
image: registry:2
options: --name registry
ports:
- 5000:5000
steps:
Expand Down Expand Up @@ -42,14 +43,17 @@ jobs:
run: |
kind create cluster --image "kindest/node:v1.27.3-coco" -n coco-sgx --config tests/e2e/enclave-cc-kind-config.yaml --wait 120s
kubectl label node coco-sgx-worker node.kubernetes.io/worker=
docker network connect kind registry

- name: Deploy operator from the local registry
run: |
cd config/default
kustomize edit set image localhost:5000/cc-operator:latest
kustomize edit set image quay.io/confidential-containers/operator=localhost:5000/cc-operator:latest
kubectl apply -k .
sleep 1
kubectl wait --for=jsonpath='{.status.conditions[0].status}'=True deployments/cc-operator-controller-manager -n confidential-containers-system
img=$(kubectl get deployments/cc-operator-controller-manager -n confidential-containers-system -o jsonpath='{.spec.template.spec.containers[?(@.name == "manager")].image}')
[ "${img}" = "localhost:5000/cc-operator:latest" ]

- name: Install enclave-cc sim
run: |
Expand All @@ -61,3 +65,11 @@ jobs:
run: |
kubectl apply -f tests/e2e/enclave-cc-pod-sim.yaml
kubectl wait --for=condition=Ready pod/enclave-cc-pod-sim

- name: Debug
if: always()
shell: bash
run: |
set -x
kubectl get pods -A
kubectl get runtimeclass
13 changes: 13 additions & 0 deletions controllers/ccruntime_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/go-logr/logr"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
nodeapi "k8s.io/api/node/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
Expand Down Expand Up @@ -463,6 +464,18 @@ func (r *CcRuntimeReconciler) monitorCcRuntimeInstallation() (ctrl.Result, error

// If the installation of the binaries is successful on all nodes, proceed with creating the runtime classes
if r.allNodesInstalled() {
// Update runtimeClass field
runtimeClassNames := r.ccRuntime.Spec.Config.RuntimeClassNames
for _, runtimeClassName := range runtimeClassNames {
foundRc := &nodeapi.RuntimeClass{}
err := r.Client.Get(context.TODO(), types.NamespacedName{Name: runtimeClassName}, foundRc)
if errors.IsNotFound(err) {
r.Log.Info("The runtime payload failed to creathe the runtime class named %s", runtimeClassName)
return ctrl.Result{}, err
}
}
r.ccRuntime.Status.RuntimeClass = strings.Join(runtimeClassNames, ",")

// Add finalizer for this CR
if !contains(r.ccRuntime.GetFinalizers(), RuntimeConfigFinalizer) {
if err := r.addFinalizer(); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/enclave-cc-kind-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ nodes:
containerdConfigPatches:
- |-
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."localhost:5000"]
endpoint = ["http://localhost:5000"]
endpoint = ["http://registry:5000"]