Skip to content
This repository was archived by the owner on Aug 12, 2024. It is now read-only.

Commit bb7cd98

Browse files
committed
update image source unpacking to use a direct image registry client
Signed-off-by: everettraven <everettraven@gmail.com>
1 parent 99faf1c commit bb7cd98

40 files changed

Lines changed: 1557 additions & 357 deletions

Makefile

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ test-e2e: $(GINKGO) ## Run the e2e tests
117117
$(GINKGO) $(E2E_FLAGS) --trace $(FOCUS) test/e2e
118118

119119
e2e: KIND_CLUSTER_NAME := rukpak-e2e
120-
e2e: run image-registry local-git kind-load-bundles registry-load-bundles test-e2e kind-cluster-cleanup ## Run e2e tests against an ephemeral kind cluster
120+
e2e: run image-registry secure-image-registry local-git kind-load-bundles registry-load-bundles secure-registry-load-bundles test-e2e kind-cluster-cleanup ## Run e2e tests against an ephemeral kind cluster
121121

122122
kind-cluster: $(KIND) kind-cluster-cleanup ## Standup a kind cluster
123123
$(KIND) create cluster --name ${KIND_CLUSTER_NAME} ${KIND_CLUSTER_CONFIG}
@@ -127,7 +127,10 @@ kind-cluster-cleanup: $(KIND) ## Delete the kind cluster
127127
$(KIND) delete cluster --name ${KIND_CLUSTER_NAME}
128128

129129
image-registry: ## Setup in-cluster image registry
130-
./test/tools/imageregistry/setup_imageregistry.sh ${KIND_CLUSTER_NAME}
130+
./test/tools/imageregistry/image-registry.sh ${REGISTRY_NAMESPACE} ${REGISTRY_NAME}
131+
132+
secure-image-registry: ## Setup a private in-cluster image registry
133+
./test/tools/imageregistry/image-registry-secure.sh ${REGISTRY_NAMESPACE} ${REGISTRY_NAME}
131134

132135
local-git: ## Setup in-cluster git repository
133136
./test/tools/git/setup_git.sh ${KIND_CLUSTER_NAME}
@@ -218,8 +221,19 @@ kind-load: $(KIND) ## Loads the currently constructed image onto the cluster
218221
$(KIND) load docker-image $(IMAGE) --name $(KIND_CLUSTER_NAME)
219222

220223
registry-load-bundles: ## Load selected e2e testdata container images created in kind-load-bundles into registry
221-
$(CONTAINER_RUNTIME) tag localhost/testdata/bundles/plain-v0:valid $(DNS_NAME):5000/bundles/plain-v0:valid
222-
./test/tools/imageregistry/load_test_image.sh $(KIND) $(KIND_CLUSTER_NAME)
224+
testdata/bundles/plain-v0/valid/build-push-e2e-bundle.sh ${REGISTRY_NAMESPACE} $(DNS_NAME):5000/bundles/plain-v0:valid
225+
testdata/bundles/plain-v0/dependent/build-push-e2e-bundle.sh ${REGISTRY_NAMESPACE} $(DNS_NAME):5000/bundles/plain-v0:dependent
226+
testdata/bundles/plain-v0/provides/build-push-e2e-bundle.sh ${REGISTRY_NAMESPACE} $(DNS_NAME):5000/bundles/plain-v0:provides
227+
testdata/bundles/plain-v0/empty/build-push-e2e-bundle.sh ${REGISTRY_NAMESPACE} $(DNS_NAME):5000/bundles/plain-v0:empty
228+
testdata/bundles/plain-v0/no-manifests/build-push-e2e-bundle.sh ${REGISTRY_NAMESPACE} $(DNS_NAME):5000/bundles/plain-v0:no-manifests
229+
testdata/bundles/plain-v0/invalid-missing-crds/build-push-e2e-bundle.sh ${REGISTRY_NAMESPACE} $(DNS_NAME):5000/bundles/plain-v0:invalid-missing-crds
230+
testdata/bundles/plain-v0/invalid-crds-and-crs/build-push-e2e-bundle.sh ${REGISTRY_NAMESPACE} $(DNS_NAME):5000/bundles/plain-v0:invalid-crds-and-crs
231+
testdata/bundles/plain-v0/subdir/build-push-e2e-bundle.sh ${REGISTRY_NAMESPACE} $(DNS_NAME):5000/bundles/plain-v0:subdir
232+
testdata/bundles/registry/valid/build-push-e2e-bundle.sh ${REGISTRY_NAMESPACE} $(DNS_NAME):5000/bundles/registry:valid
233+
testdata/bundles/registry/invalid/build-push-e2e-bundle.sh ${REGISTRY_NAMESPACE} $(DNS_NAME):5000/bundles/registry:invalid
234+
235+
secure-registry-load-bundles: ## Load selected e2e testdata container images created in kind-load-bundles into private registry
236+
testdata/bundles/plain-v0/valid/build-push-e2e-bundle-secure.sh ${REGISTRY_NAMESPACE} docker-registry-secure.rukpak-e2e.svc.cluster.local:5000/bundles/plain-v0:valid
223237

224238
###########
225239
# Release #

api/v1alpha2/bundle_types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ type ImageSource struct {
6161
Ref string `json:"ref"`
6262
// ImagePullSecretName contains the name of the image pull secret in the namespace that the provisioner is deployed.
6363
ImagePullSecretName string `json:"pullSecret,omitempty"`
64+
// InsecureSkipTLSVerify indicates that TLS certificate validation should be skipped.
65+
// If this option is specified, the HTTPS protocol will still be used to
66+
// fetch the specified image reference.
67+
// This should not be used in a production environment.
68+
// +optional
69+
InsecureSkipTLSVerify bool `json:"insecureSkipTLSVerify,omitempty"`
6470
}
6571

6672
type GitSource struct {

cmd/core/main.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func main() {
7777
enableLeaderElection bool
7878
probeAddr string
7979
systemNamespace string
80-
unpackImage string
80+
unpackCacheDir string
8181
rukpakVersion bool
8282
provisionerStorageDirectory string
8383
)
@@ -86,7 +86,7 @@ func main() {
8686
flag.StringVar(&bundleCAFile, "bundle-ca-file", "", "The file containing the certificate authority for connecting to bundle content servers.")
8787
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
8888
flag.StringVar(&systemNamespace, "system-namespace", "", "Configures the namespace that gets used to deploy system resources.")
89-
flag.StringVar(&unpackImage, "unpack-image", util.DefaultUnpackImage, "Configures the container image that gets used to unpack Bundle contents.")
89+
flag.StringVar(&unpackCacheDir, "unpack-cache-dir", "/var/cache/unpack", "Configures the directory that gets used to unpack and cache Bundle contents.")
9090
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
9191
"Enable leader election for controller manager. "+
9292
"Enabling this will ensure there is only one active controller manager.")
@@ -107,7 +107,7 @@ func main() {
107107
}
108108

109109
ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))
110-
setupLog.Info("starting up the core controllers and servers", "git commit", version.String(), "unpacker image", unpackImage)
110+
setupLog.Info("starting up the core controllers and servers", "git commit", version.String(), "unpacker cache", unpackCacheDir)
111111

112112
dependentRequirement, err := labels.NewRequirement(util.CoreOwnerKindKey, selection.In, []string{rukpakv1alpha2.BundleDeploymentKind})
113113
if err != nil {
@@ -196,12 +196,17 @@ func main() {
196196
os.Exit(1)
197197
}
198198

199-
unpacker, err := source.NewDefaultUnpacker(mgr, systemNamespace, unpackImage, rootCAs)
199+
unpacker, err := source.NewDefaultUnpacker(mgr, systemNamespace, unpackCacheDir, rootCAs)
200200
if err != nil {
201201
setupLog.Error(err, "unable to setup bundle unpacker")
202202
os.Exit(1)
203203
}
204204

205+
if err := bundleFinalizers.Register(finalizer.CleanupUnpackCacheKey, &finalizer.CleanupUnpackCache{Unpacker: unpacker}); err != nil {
206+
setupLog.Error(err, "unable to register finalizer", "finalizerKey", finalizer.CleanupUnpackCacheKey)
207+
os.Exit(1)
208+
}
209+
205210
bdNamespaceMapper := func(obj client.Object) (string, error) {
206211
bd, ok := obj.(*rukpakv1alpha2.BundleDeployment)
207212
if !ok {
@@ -261,8 +266,9 @@ func main() {
261266
os.Exit(1)
262267
}
263268

269+
ctx := ctrl.SetupSignalHandler()
264270
setupLog.Info("starting manager")
265-
if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil {
271+
if err := mgr.Start(ctx); err != nil {
266272
setupLog.Error(err, "problem running manager")
267273
os.Exit(1)
268274
}

cmd/helm/main.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ func main() {
7070
enableLeaderElection bool
7171
probeAddr string
7272
systemNamespace string
73-
unpackImage string
73+
unpackCacheDir string
7474
rukpakVersion bool
7575
storageDirectory string
7676
)
7777
flag.StringVar(&httpBindAddr, "http-bind-address", ":8080", "The address the http server binds to.")
7878
flag.StringVar(&httpExternalAddr, "http-external-address", "http://localhost:8080", "The external address at which the http server is reachable.")
7979
flag.StringVar(&bundleCAFile, "bundle-ca-file", "", "The file containing the certificate authority for connecting to bundle content servers.")
8080
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
81-
flag.StringVar(&unpackImage, "unpack-image", util.DefaultUnpackImage, "Configures the container image that gets used to unpack Bundle contents.")
81+
flag.StringVar(&unpackCacheDir, "unpack-cache-dir", "/var/cache/unpack", "Configures the directory that gets used to unpack and cache Bundle contents.")
8282
flag.StringVar(&systemNamespace, "system-namespace", "", "Configures the namespace that gets used to deploy system resources.")
8383
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
8484
"Enable leader election for controller manager. "+
@@ -188,12 +188,17 @@ func main() {
188188
os.Exit(1)
189189
}
190190

191-
unpacker, err := source.NewDefaultUnpacker(mgr, systemNamespace, unpackImage, rootCAs)
191+
unpacker, err := source.NewDefaultUnpacker(mgr, systemNamespace, unpackCacheDir, rootCAs)
192192
if err != nil {
193193
setupLog.Error(err, "unable to setup bundle unpacker")
194194
os.Exit(1)
195195
}
196196

197+
if err := bundleFinalizers.Register(finalizer.CleanupUnpackCacheKey, &finalizer.CleanupUnpackCache{Unpacker: unpacker}); err != nil {
198+
setupLog.Error(err, "unable to register finalizer", "finalizerKey", finalizer.CleanupUnpackCacheKey)
199+
os.Exit(1)
200+
}
201+
197202
bdNamespaceMapper := func(obj client.Object) (string, error) {
198203
bd, ok := obj.(*rukpakv1alpha2.BundleDeployment)
199204
if !ok {
@@ -243,8 +248,9 @@ func main() {
243248
os.Exit(1)
244249
}
245250

251+
ctx := ctrl.SetupSignalHandler()
246252
setupLog.Info("starting manager")
247-
if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil {
253+
if err := mgr.Start(ctx); err != nil {
248254
setupLog.Error(err, "problem running manager")
249255
os.Exit(1)
250256
}

go.mod

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@ go 1.21
55
toolchain go1.21.0
66

77
require (
8+
github.com/containerd/containerd v1.7.15
89
github.com/go-git/go-billy/v5 v5.5.0
910
github.com/go-git/go-git/v5 v5.12.0
1011
github.com/go-logr/logr v1.4.1
12+
github.com/google/go-containerregistry v0.19.1
13+
github.com/google/go-containerregistry/pkg/authn/k8schain v0.0.0-20240418155129-98dd3e91704f
14+
github.com/google/go-containerregistry/pkg/authn/kubernetes v0.0.0-20240418155129-98dd3e91704f
1115
github.com/gorilla/handlers v1.5.2
1216
github.com/nlepage/go-tarfs v1.2.1
1317
github.com/onsi/ginkgo/v2 v2.17.2
@@ -35,9 +39,20 @@ require (
3539
)
3640

3741
require (
42+
cloud.google.com/go/compute v1.24.0 // indirect
43+
cloud.google.com/go/compute/metadata v0.2.3 // indirect
3844
dario.cat/mergo v1.0.0 // indirect
3945
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect
46+
github.com/Azure/azure-sdk-for-go v68.0.0+incompatible // indirect
4047
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
48+
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
49+
github.com/Azure/go-autorest/autorest v0.11.29 // indirect
50+
github.com/Azure/go-autorest/autorest/adal v0.9.23 // indirect
51+
github.com/Azure/go-autorest/autorest/azure/auth v0.5.12 // indirect
52+
github.com/Azure/go-autorest/autorest/azure/cli v0.4.6 // indirect
53+
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect
54+
github.com/Azure/go-autorest/logger v0.2.1 // indirect
55+
github.com/Azure/go-autorest/tracing v0.6.0 // indirect
4156
github.com/BurntSushi/toml v1.3.2 // indirect
4257
github.com/MakeNowJust/heredoc v1.0.0 // indirect
4358
github.com/Masterminds/goutils v1.1.1 // indirect
@@ -49,17 +64,33 @@ require (
4964
github.com/ProtonMail/go-crypto v1.0.0 // indirect
5065
github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df // indirect
5166
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
67+
github.com/aws/aws-sdk-go-v2 v1.18.0 // indirect
68+
github.com/aws/aws-sdk-go-v2/config v1.18.25 // indirect
69+
github.com/aws/aws-sdk-go-v2/credentials v1.13.24 // indirect
70+
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.3 // indirect
71+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.33 // indirect
72+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.27 // indirect
73+
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.34 // indirect
74+
github.com/aws/aws-sdk-go-v2/service/ecr v1.18.11 // indirect
75+
github.com/aws/aws-sdk-go-v2/service/ecrpublic v1.16.2 // indirect
76+
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.27 // indirect
77+
github.com/aws/aws-sdk-go-v2/service/sso v1.12.10 // indirect
78+
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.10 // indirect
79+
github.com/aws/aws-sdk-go-v2/service/sts v1.19.0 // indirect
80+
github.com/aws/smithy-go v1.13.5 // indirect
81+
github.com/awslabs/amazon-ecr-credential-helper/ecr-login v0.0.0-20230510185313-f5e39e5f34c7 // indirect
5282
github.com/beorn7/perks v1.0.1 // indirect
5383
github.com/blang/semver/v4 v4.0.0 // indirect
5484
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
5585
github.com/cespare/xxhash/v2 v2.2.0 // indirect
5686
github.com/chai2010/gettext-go v1.0.2 // indirect
87+
github.com/chrismellard/docker-credential-acr-env v0.0.0-20230304212654-82a0ddb27589 // indirect
5788
github.com/cloudflare/circl v1.3.7 // indirect
5889
github.com/containerd/cgroups/v3 v3.0.2 // indirect
59-
github.com/containerd/containerd v1.7.15 // indirect
6090
github.com/containerd/continuity v0.4.2 // indirect
6191
github.com/containerd/errdefs v0.1.0 // indirect
6292
github.com/containerd/log v0.1.0 // indirect
93+
github.com/containerd/stargz-snapshotter/estargz v0.15.1 // indirect
6394
github.com/containerd/ttrpc v1.2.3 // indirect
6495
github.com/containerd/typeurl/v2 v2.1.1 // indirect
6596
github.com/containers/common v0.58.2 // indirect
@@ -69,6 +100,7 @@ require (
69100
github.com/containers/storage v1.53.0 // indirect
70101
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
71102
github.com/davecgh/go-spew v1.1.1 // indirect
103+
github.com/dimchansky/utfbom v1.1.1 // indirect
72104
github.com/distribution/reference v0.6.0 // indirect
73105
github.com/docker/cli v26.0.1+incompatible // indirect
74106
github.com/docker/distribution v2.8.3+incompatible // indirect
@@ -96,6 +128,7 @@ require (
96128
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
97129
github.com/gobwas/glob v0.2.3 // indirect
98130
github.com/gogo/protobuf v1.3.2 // indirect
131+
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
99132
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
100133
github.com/golang/protobuf v1.5.4 // indirect
101134
github.com/google/btree v1.1.2 // indirect
@@ -119,6 +152,7 @@ require (
119152
github.com/imdario/mergo v0.3.16 // indirect
120153
github.com/inconshreveable/mousetrap v1.1.0 // indirect
121154
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
155+
github.com/jmespath/go-jmespath v0.4.0 // indirect
122156
github.com/jmoiron/sqlx v1.3.5 // indirect
123157
github.com/josharian/intern v1.0.0 // indirect
124158
github.com/json-iterator/go v1.1.12 // indirect
@@ -134,6 +168,7 @@ require (
134168
github.com/mattn/go-isatty v0.0.17 // indirect
135169
github.com/mattn/go-runewidth v0.0.15 // indirect
136170
github.com/mitchellh/copystructure v1.2.0 // indirect
171+
github.com/mitchellh/go-homedir v1.1.0 // indirect
137172
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
138173
github.com/mitchellh/reflectwalk v1.0.2 // indirect
139174
github.com/moby/locker v1.0.1 // indirect

0 commit comments

Comments
 (0)