Skip to content

Commit 8d56a38

Browse files
committed
Implement TLS overlay for Catalogd TLS
Signed-off-by: Tayler Geiger <[email protected]>
1 parent ab2e1c6 commit 8d56a38

39 files changed

+77
-258
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

.vscode/launch.json

Lines changed: 0 additions & 18 deletions
This file was deleted.

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.
@@ -148,7 +148,7 @@ build-push-e2e-catalog: ## Build the testdata catalog used for e2e tests and pus
148148
# for example: ARTIFACT_PATH=/tmp/artifacts make test-e2e
149149
.PHONY: test-e2e
150150
test-e2e: KIND_CLUSTER_NAME := operator-controller-e2e
151-
test-e2e: KUSTOMIZE_BUILD_DIR := config/e2e
151+
test-e2e: KUSTOMIZE_BUILD_DIR := config/base/e2e
152152
test-e2e: GO_BUILD_FLAGS := -cover
153153
test-e2e: run image-registry build-push-e2e-catalog kind-load-test-artifacts e2e e2e-coverage kind-clean #HELP Run e2e test suite on local kind cluster
154154

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: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ limitations under the License.
1717
package main
1818

1919
import (
20+
"crypto/tls"
2021
"crypto/x509"
2122
"flag"
2223
"fmt"
24+
"log"
2325
"net/http"
2426
"net/url"
2527
"os"
@@ -80,9 +82,11 @@ func main() {
8082
systemNamespace string
8183
unpackImage string
8284
provisionerStorageDirectory string
85+
tlsCert string
8386
)
8487
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
8588
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
89+
flag.StringVar(&tlsCert, "tls-cert", "", "The TLS certificate to use for verifying HTTPS connections to the Catalogd web server.")
8690
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
8791
"Enable leader election for controller manager. "+
8892
"Enabling this will ensure there is only one active controller manager.")
@@ -152,8 +156,27 @@ func main() {
152156
os.Exit(1)
153157
}
154158

159+
httpClient := &http.Client{Timeout: 10 * time.Second}
160+
161+
if tlsCert != "" {
162+
cert, err := os.ReadFile(tlsCert)
163+
if err != nil {
164+
log.Fatalf("Failed to read certificate file: %v", err)
165+
}
166+
caCertPool := x509.NewCertPool()
167+
caCertPool.AppendCertsFromPEM(cert)
168+
tlsConfig := &tls.Config{
169+
RootCAs: caCertPool,
170+
MinVersion: tls.VersionTLS12,
171+
}
172+
tlsTransport := &http.Transport{
173+
TLSClientConfig: tlsConfig,
174+
}
175+
httpClient.Transport = tlsTransport
176+
}
177+
155178
cl := mgr.GetClient()
156-
catalogClient := catalogclient.New(cl, cache.NewFilesystemCache(cachePath, &http.Client{Timeout: 10 * time.Second}))
179+
catalogClient := catalogclient.New(cl, cache.NewFilesystemCache(cachePath, httpClient))
157180

158181
cfgGetter, err := helmclient.NewActionConfigGetter(mgr.GetConfig(), mgr.GetRESTMapper(), helmclient.StorageNamespaceMapper(func(o client.Object) (string, error) {
159182
return systemNamespace, nil

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# It should be run by config/default
44
resources:
55
- bases/olm.operatorframework.io_clusterextensions.yaml
6-
- bases/olm.operatorframework.io_extensions.yaml
76

87
# the following config is for teaching kustomize how to do kustomization for CRDs.
98
configurations:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
namespace: operator-controller-system
22

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

0 commit comments

Comments
 (0)