-
Notifications
You must be signed in to change notification settings - Fork 66
Ensure the platform operator stack is deployed before running e2e tests #21
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
Changes from all commits
cd9ca47
9310fc7
eb6135b
6e9be74
19acd4d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,5 @@ | ||
# Build the manager binary | ||
FROM golang:1.17 as builder | ||
|
||
WORKDIR /workspace | ||
# Copy the Go Modules manifests | ||
COPY go.mod go.mod | ||
COPY go.sum go.sum | ||
# cache deps before building and copying source so that we don't need to re-download as much | ||
# and so that source changes don't invalidate our downloaded layer | ||
RUN go mod download | ||
|
||
# Copy the go source | ||
COPY main.go main.go | ||
COPY api/ api/ | ||
COPY controllers/ controllers/ | ||
|
||
# Build | ||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager main.go | ||
|
||
# Use distroless as minimal base image to package the manager binary | ||
# Refer to https://github.com/GoogleContainerTools/distroless for more details | ||
FROM gcr.io/distroless/static:nonroot | ||
FROM gcr.io/distroless/static:debug-nonroot | ||
WORKDIR / | ||
COPY --from=builder /workspace/manager . | ||
USER 65532:65532 | ||
|
||
ENTRYPOINT ["/manager"] | ||
COPY manager manager | ||
EXPOSE 8080 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,10 @@ import ( | |
platformv1alpha1 "github.com/timflannagan/platform-operators/api/v1alpha1" | ||
) | ||
|
||
const channelName = "4.12" | ||
const ( | ||
channelName = "4.12" | ||
plainProvisionerID = "core.rukpak.io/plain" | ||
) | ||
|
||
// PlatformOperatorReconciler reconciles a PlatformOperator object | ||
type PlatformOperatorReconciler struct { | ||
|
@@ -102,8 +105,27 @@ func (r *PlatformOperatorReconciler) Reconcile(ctx context.Context, req ctrl.Req | |
return ctrl.Result{}, client.IgnoreNotFound(err) | ||
} | ||
|
||
css := &operatorsv1alpha1.CatalogSourceList{} | ||
if err := r.List(ctx, css); err != nil { | ||
log.Error(err, "failed to list the catalogsource resources in the cluster") | ||
return ctrl.Result{}, err | ||
} | ||
if len(css.Items) == 0 { | ||
log.Info("unable to query catalog content as no catalogsources are available") | ||
return ctrl.Result{}, nil | ||
} | ||
// TODO(tflannag): properly handle multiple catalogsources in a cluster | ||
cs := css.Items[0] | ||
Comment on lines
+117
to
+118
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a super short term hack that's needed in order to work with the basic e2e tests that I have sitting locally, which deploy a magic catalog instance, so hardcoding the CatalogSource reference, and even worse hardcode that logic at the main.go level as it fails the container at startup, wouldn't work with that setup. |
||
|
||
log.Info("creating registry client from catalogsource") | ||
rc, err := registryClient.NewClient(cs.Spec.Address) | ||
if err != nil { | ||
log.Error(err, "failed to create registry client from catalogsource", "name", cs.GetName(), "namespace", cs.GetNamespace(), "address", cs.Spec.Address) | ||
return ctrl.Result{}, err | ||
} | ||
|
||
log.Info("listing bundles from context") | ||
it, err := r.RegistryClient.ListBundles(ctx) | ||
it, err := rc.ListBundles(ctx) | ||
if err != nil { | ||
log.Error(err, "failed to list bundles in the platform operators catalog source") | ||
return ctrl.Result{}, err | ||
|
@@ -153,22 +175,19 @@ func (r *PlatformOperatorReconciler) ensureBundleInstance(ctx context.Context, p | |
|
||
_, err := controllerutil.CreateOrUpdate(ctx, r.Client, bi, func() error { | ||
bi.SetOwnerReferences([]metav1.OwnerReference{*controllerRef}) | ||
bi.Spec = *buildBundleInstance(bi.GetName(), bundle.BundlePath) | ||
bi.Spec = *buildBundleInstance(bundle.BundlePath) | ||
return nil | ||
}) | ||
return err | ||
} | ||
|
||
// createBundleInstance is responsible for taking a name and image to create an embedded BundleInstance | ||
func buildBundleInstance(name, image string) *rukpakv1alpha1.BundleInstanceSpec { | ||
func buildBundleInstance(image string) *rukpakv1alpha1.BundleInstanceSpec { | ||
return &rukpakv1alpha1.BundleInstanceSpec{ | ||
ProvisionerClassName: "core.rukpak.io/plain", | ||
ProvisionerClassName: plainProvisionerID, | ||
Template: &rukpakv1alpha1.BundleTemplate{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Labels: map[string]string{"app": name}, | ||
}, | ||
Spec: rukpakv1alpha1.BundleSpec{ | ||
ProvisionerClassName: "core.rukpak.io/plain", | ||
ProvisionerClassName: plainProvisionerID, | ||
Source: rukpakv1alpha1.BundleSource{ | ||
Type: rukpakv1alpha1.SourceTypeImage, | ||
Image: &rukpakv1alpha1.ImageSource{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update from the debug tag that matched the rukpak container image to debug-nonroot as I ran into the following error locally:
And that's because kubebuilder/operator-sdk automatically scaffold out that securityContext for our manager resources by default (and we didn't use that SDK tooling in rukpak).