Skip to content

Commit a1cb8a6

Browse files
authored
⚠ add TLS overlay for Catalogd v0.13.0 web server TLS (#888)
* Update catalogd dep to v0.13.0 Fix references to Catalog and CatalogSpec * Implement TLS overlay for Catalogd TLS Signed-off-by: Tayler Geiger <[email protected]> * Reorganize TLS changes * Move e2e to its own overlay * Change default namespace to olmv1-system Use v0.14.0 of Catalogd which also uses olmv1-system namespace --------- Signed-off-by: Tayler Geiger <[email protected]>
1 parent 5798a4a commit a1cb8a6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+134
-64
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,4 @@ install.sh
3939
site
4040

4141
.tiltbuild/
42+
.vscode

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ else
5454
$(warning Could not find docker or podman in path! This may result in targets requiring a container runtime failing!)
5555
endif
5656

57-
KUSTOMIZE_BUILD_DIR := config/default
57+
KUSTOMIZE_BUILD_DIR := config/overlays/tls
5858

5959
# Disable -j flag for make
6060
.NOTPARALLEL:
@@ -95,7 +95,7 @@ tidy: #HELP Update dependencies.
9595

9696
.PHONY: manifests
9797
manifests: $(CONTROLLER_GEN) #EXHELP Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
98-
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
98+
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/base/crd/bases
9999

100100
.PHONY: generate
101101
generate: $(CONTROLLER_GEN) #EXHELP Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
@@ -150,7 +150,7 @@ build-push-e2e-catalog: ## Build the testdata catalog used for e2e tests and pus
150150
# for example: ARTIFACT_PATH=/tmp/artifacts make test-e2e
151151
.PHONY: test-e2e
152152
test-e2e: KIND_CLUSTER_NAME := operator-controller-e2e
153-
test-e2e: KUSTOMIZE_BUILD_DIR := config/e2e
153+
test-e2e: KUSTOMIZE_BUILD_DIR := config/overlays/e2e
154154
test-e2e: GO_BUILD_FLAGS := -cover
155155
test-e2e: run image-registry build-push-e2e-catalog registry-load-bundles e2e e2e-coverage kind-clean #HELP Run e2e test suite on local kind cluster
156156

Tiltfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ repos = cfg.get('repos', ['operator-controller', 'catalogd'])
99

1010
repo = {
1111
'image': 'quay.io/operator-framework/operator-controller',
12-
'yaml': 'config/default',
12+
'yaml': 'config/overlays/tls',
1313
'binaries': {
1414
'manager': 'operator-controller-controller-manager',
1515
},

cmd/manager/main.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@ import (
2020
"crypto/x509"
2121
"flag"
2222
"fmt"
23-
"net/http"
2423
"net/url"
2524
"os"
2625
"path/filepath"
27-
"time"
2826

2927
"github.com/spf13/pflag"
3028
"go.uber.org/zap/zapcore"
@@ -50,6 +48,7 @@ import (
5048
"github.com/operator-framework/operator-controller/internal/catalogmetadata/cache"
5149
catalogclient "github.com/operator-framework/operator-controller/internal/catalogmetadata/client"
5250
"github.com/operator-framework/operator-controller/internal/controllers"
51+
"github.com/operator-framework/operator-controller/internal/httputil"
5352
"github.com/operator-framework/operator-controller/internal/labels"
5453
"github.com/operator-framework/operator-controller/internal/version"
5554
"github.com/operator-framework/operator-controller/pkg/features"
@@ -58,7 +57,7 @@ import (
5857

5958
var (
6059
setupLog = ctrl.Log.WithName("setup")
61-
defaultSystemNamespace = "operator-controller-system"
60+
defaultSystemNamespace = "olmv1-system"
6261
)
6362

6463
// podNamespace checks whether the controller is running in a Pod vs.
@@ -82,9 +81,11 @@ func main() {
8281
operatorControllerVersion bool
8382
systemNamespace string
8483
provisionerStorageDirectory string
84+
caCert string
8585
)
8686
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
8787
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
88+
flag.StringVar(&caCert, "ca-cert", "", "The TLS certificate to use for verifying HTTPS connections to the Catalogd web server.")
8889
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
8990
"Enable leader election for controller manager. "+
9091
"Enabling this will ensure there is only one active controller manager.")
@@ -153,8 +154,13 @@ func main() {
153154
os.Exit(1)
154155
}
155156

157+
httpClient, err := httputil.BuildHTTPClient(caCert)
158+
if err != nil {
159+
setupLog.Error(err, "unable to create catalogd http client")
160+
}
161+
156162
cl := mgr.GetClient()
157-
catalogClient := catalogclient.New(cl, cache.NewFilesystemCache(cachePath, &http.Client{Timeout: 10 * time.Second}))
163+
catalogClient := catalogclient.New(cl, cache.NewFilesystemCache(cachePath, httpClient))
158164

159165
cfgGetter, err := helmclient.NewActionConfigGetter(mgr.GetConfig(), mgr.GetRESTMapper(), helmclient.StorageNamespaceMapper(func(o client.Object) (string, error) {
160166
return systemNamespace, nil
File renamed without changes.

config/default/kustomization.yaml renamed to config/base/kustomization.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Adds namespace to all resources.
2-
namespace: operator-controller-system
2+
namespace: olmv1-system
33

44
# Value of this field is prepended to the
55
# names of all resources, e.g. a deployment named
@@ -15,9 +15,9 @@ namePrefix: operator-controller-
1515
# someName: someValue
1616

1717
resources:
18-
- ../crd
19-
- ../rbac
20-
- ../manager
18+
- crd
19+
- rbac
20+
- manager
2121
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
2222
# crd/kustomization.yaml
2323
#- ../webhook

config/manager/manager.yaml renamed to config/base/manager/manager.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,4 @@ spec:
114114
- name: cache
115115
emptyDir: {}
116116
- name: bundle-cache
117-
emptyDir: {}
117+
emptyDir: {}
File renamed without changes.
File renamed without changes.

config/rbac/role.yaml renamed to config/base/rbac/role.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ rules:
2020
- apiGroups:
2121
- catalogd.operatorframework.io
2222
resources:
23-
- catalogs
23+
- clustercatalogs
2424
verbs:
2525
- list
2626
- watch
File renamed without changes.

config/e2e/kustomization.yaml renamed to config/overlays/e2e/kustomization.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
namespace: operator-controller-system
1+
namespace: olmv1-system
22

33
resources:
4-
- ../default
4+
- ../../overlays/tls
55
- manager_e2e_coverage_pvc.yaml
66
- manager_e2e_coverage_copy_pod.yaml
77

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Adds namespace to all resources.
2+
namespace: olmv1-system
3+
4+
# Value of this field is prepended to the
5+
# names of all resources, e.g. a deployment named
6+
# "wordpress" becomes "alices-wordpress".
7+
# Note that it should also match with the prefix (text before '-') of the namespace
8+
# field above.
9+
10+
# the following config is for teaching kustomize how to do var substitution
11+
apiVersion: kustomize.config.k8s.io/v1beta1
12+
kind: Kustomization
13+
resources:
14+
- ../../base
15+
16+
patches:
17+
- target:
18+
kind: Deployment
19+
name: controller-manager
20+
path: patches/manager_deployment_cert.yaml
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
- op: add
2+
path: /spec/template/spec/volumes/-
3+
value: {"name":"ca-certificate", "secret":{"secretName":"catalogd-catalogserver-cert", "optional": false, "items": [{"key": "tls.crt", "path": "tls.crt"}]}}
4+
- op: add
5+
path: /spec/template/spec/containers/0/volumeMounts/-
6+
value: {"name":"ca-certificate", "readOnly": true, "mountPath":"/var/certs"}
7+
- op: add
8+
path: /spec/template/spec/containers/0/args/-
9+
value: "--ca-cert=/var/certs/tls.crt"

config/samples/catalogd_operatorcatalog.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
apiVersion: catalogd.operatorframework.io/v1alpha1
2-
kind: Catalog
2+
kind: ClusterCatalog
33
metadata:
44
name: operatorhubio
55
spec:

docs/Tasks/adding-a-catalog.md

Lines changed: 1 addition & 1 deletion

docs/Tasks/explore-available-packages.md

Lines changed: 1 addition & 1 deletion

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require (
1010
github.com/go-logr/logr v1.4.2
1111
github.com/google/go-cmp v0.6.0
1212
github.com/operator-framework/api v0.25.0
13-
github.com/operator-framework/catalogd v0.12.0
13+
github.com/operator-framework/catalogd v0.14.0
1414
github.com/operator-framework/helm-operator-plugins v0.2.2-0.20240520180534-f463c36fedf9
1515
github.com/operator-framework/operator-registry v1.43.1
1616
github.com/operator-framework/rukpak v0.23.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,8 @@ github.com/opencontainers/runtime-spec v1.2.0 h1:z97+pHb3uELt/yiAWD691HNHQIF07bE
475475
github.com/opencontainers/runtime-spec v1.2.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
476476
github.com/operator-framework/api v0.25.0 h1:pSQwFSoPmZaTIERadawxtCwicehLkC7i9n3w3+70SVI=
477477
github.com/operator-framework/api v0.25.0/go.mod h1:PvyCQb0x53ytIqdTECH5e+iqv+am3uZ0qGsZWmL35gQ=
478-
github.com/operator-framework/catalogd v0.12.0 h1:Cww+CyowkfTFugB9ZjUDpKvumh2vPe/TjCUpMHDmVBM=
479-
github.com/operator-framework/catalogd v0.12.0/go.mod h1:4lryGtBTVOdqlKR0MaVYnlsSOc7HiagVRVo3J4uIo7E=
478+
github.com/operator-framework/catalogd v0.14.0 h1:M/kDqhH1hBB9amUk7/dAV4WZuJIa5ARboeY6GMjhx0E=
479+
github.com/operator-framework/catalogd v0.14.0/go.mod h1:84M4gm0JPrwOLVbEOoCns/xjlg4ljenVMPYUO/Cs+Wc=
480480
github.com/operator-framework/helm-operator-plugins v0.2.2-0.20240520180534-f463c36fedf9 h1:f7/TMBpuIZEQ3JbD9UyP1L1ZCSLLWdR2aPN+A+dOHFY=
481481
github.com/operator-framework/helm-operator-plugins v0.2.2-0.20240520180534-f463c36fedf9/go.mod h1:ly6Bd9rSzmt37Wy6WtZHmA+IY9zG958MryJFLcVpCXw=
482482
github.com/operator-framework/operator-lib v0.14.0 h1:er+BgZymZD1im2wytLJiPLZpGALAX6N0gXaHx3PKbO4=

hack/e2e-coverage.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -euo pipefail
44

55
COVERAGE_OUTPUT="${COVERAGE_OUTPUT:-e2e-cover.out}"
66

7-
OPERATOR_CONTROLLER_NAMESPACE="operator-controller-system"
7+
OPERATOR_CONTROLLER_NAMESPACE="olmv1-system"
88
OPERATOR_CONTROLLER_MANAGER_DEPLOYMENT_NAME="operator-controller-controller-manager"
99
COPY_POD_NAME="e2e-coverage-copy-pod"
1010

internal/catalogmetadata/cache/cache.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ type filesystemCache struct {
6666
// resources that have been successfully reconciled, unpacked, and are being served.
6767
// These requirements help ensure that we can rely on status conditions to determine
6868
// when to issue a request to update the cached Catalog contents.
69-
func (fsc *filesystemCache) FetchCatalogContents(ctx context.Context, catalog *catalogd.Catalog) (io.ReadCloser, error) {
69+
func (fsc *filesystemCache) FetchCatalogContents(ctx context.Context, catalog *catalogd.ClusterCatalog) (io.ReadCloser, error) {
7070
if catalog == nil {
7171
return nil, fmt.Errorf("error: provided catalog must be non-nil")
7272
}

internal/catalogmetadata/cache/cache_test.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func TestCache(t *testing.T) {
5454
t.Run("FetchCatalogContents", func(t *testing.T) {
5555
type test struct {
5656
name string
57-
catalog *catalogd.Catalog
57+
catalog *catalogd.ClusterCatalog
5858
contents []byte
5959
wantErr bool
6060
tripper *MockTripper
@@ -64,11 +64,11 @@ func TestCache(t *testing.T) {
6464
for _, tt := range []test{
6565
{
6666
name: "valid non-cached fetch",
67-
catalog: &catalogd.Catalog{
67+
catalog: &catalogd.ClusterCatalog{
6868
ObjectMeta: metav1.ObjectMeta{
6969
Name: "test-catalog",
7070
},
71-
Status: catalogd.CatalogStatus{
71+
Status: catalogd.ClusterCatalogStatus{
7272
ResolvedSource: &catalogd.ResolvedCatalogSource{
7373
Type: catalogd.SourceTypeImage,
7474
Image: &catalogd.ResolvedImageSource{
@@ -82,11 +82,11 @@ func TestCache(t *testing.T) {
8282
},
8383
{
8484
name: "valid cached fetch",
85-
catalog: &catalogd.Catalog{
85+
catalog: &catalogd.ClusterCatalog{
8686
ObjectMeta: metav1.ObjectMeta{
8787
Name: "test-catalog",
8888
},
89-
Status: catalogd.CatalogStatus{
89+
Status: catalogd.ClusterCatalogStatus{
9090
ResolvedSource: &catalogd.ResolvedCatalogSource{
9191
Type: catalogd.SourceTypeImage,
9292
Image: &catalogd.ResolvedImageSource{
@@ -102,11 +102,11 @@ func TestCache(t *testing.T) {
102102
},
103103
{
104104
name: "cached update fetch with changes",
105-
catalog: &catalogd.Catalog{
105+
catalog: &catalogd.ClusterCatalog{
106106
ObjectMeta: metav1.ObjectMeta{
107107
Name: "test-catalog",
108108
},
109-
Status: catalogd.CatalogStatus{
109+
Status: catalogd.ClusterCatalogStatus{
110110
ResolvedSource: &catalogd.ResolvedCatalogSource{
111111
Type: catalogd.SourceTypeImage,
112112
Image: &catalogd.ResolvedImageSource{
@@ -122,11 +122,11 @@ func TestCache(t *testing.T) {
122122
},
123123
{
124124
name: "fetch error",
125-
catalog: &catalogd.Catalog{
125+
catalog: &catalogd.ClusterCatalog{
126126
ObjectMeta: metav1.ObjectMeta{
127127
Name: "test-catalog",
128128
},
129-
Status: catalogd.CatalogStatus{
129+
Status: catalogd.ClusterCatalogStatus{
130130
ResolvedSource: &catalogd.ResolvedCatalogSource{
131131
Type: catalogd.SourceTypeImage,
132132
Image: &catalogd.ResolvedImageSource{
@@ -141,11 +141,11 @@ func TestCache(t *testing.T) {
141141
},
142142
{
143143
name: "fetch internal server error response",
144-
catalog: &catalogd.Catalog{
144+
catalog: &catalogd.ClusterCatalog{
145145
ObjectMeta: metav1.ObjectMeta{
146146
Name: "test-catalog",
147147
},
148-
Status: catalogd.CatalogStatus{
148+
Status: catalogd.ClusterCatalogStatus{
149149
ResolvedSource: &catalogd.ResolvedCatalogSource{
150150
Type: catalogd.SourceTypeImage,
151151
Image: &catalogd.ResolvedImageSource{
@@ -167,11 +167,11 @@ func TestCache(t *testing.T) {
167167
},
168168
{
169169
name: "nil catalog.status.resolvedSource",
170-
catalog: &catalogd.Catalog{
170+
catalog: &catalogd.ClusterCatalog{
171171
ObjectMeta: metav1.ObjectMeta{
172172
Name: "test-catalog",
173173
},
174-
Status: catalogd.CatalogStatus{
174+
Status: catalogd.ClusterCatalogStatus{
175175
ResolvedSource: nil,
176176
},
177177
},
@@ -181,11 +181,11 @@ func TestCache(t *testing.T) {
181181
},
182182
{
183183
name: "nil catalog.status.resolvedSource.image",
184-
catalog: &catalogd.Catalog{
184+
catalog: &catalogd.ClusterCatalog{
185185
ObjectMeta: metav1.ObjectMeta{
186186
Name: "test-catalog",
187187
},
188-
Status: catalogd.CatalogStatus{
188+
Status: catalogd.ClusterCatalogStatus{
189189
ResolvedSource: &catalogd.ResolvedCatalogSource{
190190
Image: nil,
191191
},

internal/catalogmetadata/client/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type Fetcher interface {
2323
// server for the catalog provided. It returns an io.ReadCloser
2424
// containing the FBC contents that the caller is expected to close.
2525
// returns an error if any occur.
26-
FetchCatalogContents(ctx context.Context, catalog *catalogd.Catalog) (io.ReadCloser, error)
26+
FetchCatalogContents(ctx context.Context, catalog *catalogd.ClusterCatalog) (io.ReadCloser, error)
2727
}
2828

2929
func New(cl client.Client, fetcher Fetcher) *Client {
@@ -46,7 +46,7 @@ type Client struct {
4646
func (c *Client) Bundles(ctx context.Context) ([]*catalogmetadata.Bundle, error) {
4747
var allBundles []*catalogmetadata.Bundle
4848

49-
var catalogList catalogd.CatalogList
49+
var catalogList catalogd.ClusterCatalogList
5050
if err := c.cl.List(ctx, &catalogList); err != nil {
5151
return nil, err
5252
}

0 commit comments

Comments
 (0)