Skip to content
Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
e5d5c04
:seedling: Bump golang.org/x/crypto from 0.28.0 to 0.31.0 (#1521)
dependabot[bot] Dec 13, 2024
d1db17f
:seedling: Bump markdown2 from 2.5.1 to 2.5.2 (#1519)
dependabot[bot] Dec 13, 2024
61fe142
e2e: add tests to validate metrics endpoint (#1522)
camilamacedo86 Dec 13, 2024
3cd783a
:seedling: Bump certifi from 2024.8.30 to 2024.12.14 (#1526)
dependabot[bot] Dec 16, 2024
7ad65d6
:seedling: Bump mkdocs-material from 9.5.48 to 9.5.49 (#1525)
dependabot[bot] Dec 16, 2024
d3f267a
Configure ENVTEST Binaries for IDE Debugging (#1454)
camilamacedo86 Dec 17, 2024
06bddaf
Adding deprecation notice to roadmap (#1528)
LalatenduMohanty Dec 17, 2024
cd290ba
Add check for client in e2e (#1529)
tmshort Dec 17, 2024
b67bd38
:seedling: Bump helm.sh/helm/v3 from 3.16.3 to 3.16.4 (#1527)
dependabot[bot] Dec 17, 2024
10f0f77
Replace kube-rbac-proxy to ensure the same level of protection with c…
camilamacedo86 Dec 19, 2024
de6a813
(fix) Removing Unused and Insecure Manifests for Prometheus since its…
camilamacedo86 Jan 3, 2025
2c812aa
move service to kustomize manager dir, rename for general purpose use…
joelanford Jan 6, 2025
afe582b
Merge branch 'main' into synchronize
joelanford Jan 6, 2025
b3f6af1
UPSTREAM: <carry>: Add OpenShift specific files
dtfranz Oct 26, 2023
4c69d7c
UPSTREAM: <carry>: Drop commitchecker
awgreene Nov 3, 2023
c850c4b
UPSTREAM: <carry>: Updating ose-olm-operator-controller-container ima…
Dec 16, 2023
1405c02
UPSTREAM: <carry>: update owners
Mar 27, 2024
bae5f4d
UPSTREAM: <carry>: Add pointer to tooling README
bentito Apr 1, 2024
e001e1c
UPSTREAM: <carry>: Disable Validating Admission Policy APIs downstream
Apr 26, 2024
fcc2e64
UPSTREAM: <carry>: Updating ose-olm-operator-controller-container ima…
Mar 27, 2024
96a01e2
UPSTREAM: <carry>: Enable Validating Admission Policy APIs downstream
Apr 30, 2024
7d2ed01
UPSTREAM: <carry>: manifests: set required-scc for openshift workloads
liouk May 2, 2024
88a2462
UPSTREAM: <carry>: Updating ose-olm-operator-controller-container ima…
May 25, 2024
0a1d865
UPSTREAM: <carry>: add everettraven to approvers+reviewers
everettraven Jun 24, 2024
e38dfd4
UPSTREAM: <carry>: add openshift kustomize overlay
everettraven Jul 9, 2024
9c14cc5
UPSTREAM: <carry>: Add tmshort to approvers
tmshort Sep 11, 2024
7ca3c22
UPSTREAM: <carry>: Updating ose-olm-operator-controller-container ima…
Sep 18, 2024
6c86607
UPSTREAM: <carry>: Properly copy and call kustomize
tmshort Sep 23, 2024
ae55b79
UPSTREAM: <carry>: manifests: add hostPath mount for /etc/containers
joelanford Sep 20, 2024
f7c7fc9
UPSTREAM: <carry>: Add test-e2e target for downstream Makefile to be …
dtfranz Sep 26, 2024
f26d8e2
UPSTREAM: <carry>: Add downstream verify makefile target
dtfranz Sep 27, 2024
6f12a85
UPSTREAM: <carry>: openshift: template log verbosity to be managed by…
joelanford Sep 28, 2024
9dc03ee
UPSTREAM: <carry>: Add global-pull-secret flag
Oct 8, 2024
657169b
UPSTREAM: <carry>: Update openshift CAs to operator-controller
tmshort Oct 28, 2024
67e5f40
UPSTREAM: <carry>: Add HowTo for origin tests
tmshort Nov 1, 2024
c508578
UPSTREAM: <carry>: Add e2e registry Dockerfile
dtfranz Nov 16, 2024
95ace89
UPSTREAM: <carry>: add nodeSelector and tolerations to operator-contr…
everettraven Nov 19, 2024
5555857
UPSTREAM: <carry>: namespace: use privileged PSA for audit and warn l…
joelanford Nov 22, 2024
68b3859
UPSTREAM: <carry>: Enable downstream e2e
dtfranz Nov 15, 2024
9a1b812
UPSTREAM: <carry>: Remove m1kola from owners
Dec 12, 2024
f0d170b
UPSTREAM: <carry>: Updating ose-olm-operator-controller-container ima…
Dec 4, 2024
43c0b0a
UPSTREAM: <drop>: go mod vendor
joelanford Jan 6, 2025
77d06b8
UPSTREAM: <drop>: remove upstream GitHub configuration
joelanford Jan 6, 2025
4ce783b
UPSTREAM: <drop>: configure the commit-checker
joelanford Jan 6, 2025
ee1cc93
UPSTREAM: <drop>: rewrite go mod
joelanford Jan 6, 2025
c0b0ccc
UPSTREAM: <carry>: generate and mount service-ca server cert
joelanford Jan 6, 2025
deabcc2
UPSTREAM: <drop>: re-generate manifests for service-ca cert
joelanford Jan 6, 2025
f37f9eb
UPSTREAM: <drop>: improved metrics test output to troubleshoot failure
joelanford Jan 6, 2025
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
26 changes: 26 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,32 @@ you can follow the steps below to test your changes:
make kind-load kind-deploy
```

## How to debug controller tests using ENVTEST

[ENVTEST](https://book.kubebuilder.io/reference/envtest) requires k8s binaries to be downloaded to run the tests.
To download the necessary binaries, follow the steps below:

```sh
make envtest-k8s-bins
```

Note that the binaries are downloaded to the `bin/envtest-binaries` directory.

```sh
$ tree
.
├── envtest-binaries
│   └── k8s
│   └── 1.31.0-darwin-arm64
│   ├── etcd
│   ├── kube-apiserver
│   └── kubectl
```

Now, you can debug them with your IDE:

![Screenshot IDE example](https://github.com/user-attachments/assets/3096d524-0686-48ca-911c-5b843093ad1f)

### Communication Channels

- Email: [operator-framework-olm-dev](mailto:[email protected])
Expand Down
18 changes: 12 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ export WAIT_TIMEOUT := 60s
# Install default ClusterCatalogs
export INSTALL_DEFAULT_CATALOGS := true

# By default setup-envtest will write to $XDG_DATA_HOME, or $HOME/.local/share if that is not defined.
# By default setup-envtest binary will write to $XDG_DATA_HOME, or $HOME/.local/share if that is not defined.
# If $HOME is not set, we need to specify a binary directory to prevent an error in setup-envtest.
# Useful for some CI/CD environments that set neither $XDG_DATA_HOME nor $HOME.
SETUP_ENVTEST_BIN_DIR_OVERRIDE=
SETUP_ENVTEST_BIN_DIR_OVERRIDE += --bin-dir $(ROOT_DIR)/bin/envtest-binaries
ifeq ($(shell [[ $$HOME == "" || $$HOME == "/" ]] && [[ $$XDG_DATA_HOME == "" ]] && echo true ), true)
SETUP_ENVTEST_BIN_DIR_OVERRIDE += --bin-dir /tmp/envtest-binaries
endif
Expand Down Expand Up @@ -158,19 +158,25 @@ test-ext-dev-e2e: $(OPERATOR_SDK) $(KUSTOMIZE) $(KIND) #HELP Run extension creat
test/extension-developer-e2e/setup.sh $(OPERATOR_SDK) $(CONTAINER_RUNTIME) $(KUSTOMIZE) $(KIND) $(KIND_CLUSTER_NAME) $(E2E_REGISTRY_NAMESPACE)
go test -count=1 -v ./test/extension-developer-e2e/...

.PHONY: test-unit
ENVTEST_VERSION := $(shell go list -m k8s.io/client-go | cut -d" " -f2 | sed 's/^v0\.\([[:digit:]]\{1,\}\)\.[[:digit:]]\{1,\}$$/1.\1.x/')
UNIT_TEST_DIRS := $(shell go list ./... | grep -v /test/)
COVERAGE_UNIT_DIR := $(ROOT_DIR)/coverage/unit
test-unit: $(SETUP_ENVTEST) #HELP Run the unit tests

.PHONY: envtest-k8s-bins #HELP Uses setup-envtest to download and install the binaries required to run ENVTEST-test based locally at the project/bin directory.
envtest-k8s-bins: $(SETUP_ENVTEST)
mkdir -p $(ROOT_DIR)/bin
$(SETUP_ENVTEST) use -p env $(ENVTEST_VERSION) $(SETUP_ENVTEST_BIN_DIR_OVERRIDE)

.PHONY: test-unit
test-unit: $(SETUP_ENVTEST) envtest-k8s-bins #HELP Run the unit tests
rm -rf $(COVERAGE_UNIT_DIR) && mkdir -p $(COVERAGE_UNIT_DIR)
eval $$($(SETUP_ENVTEST) use -p env $(ENVTEST_VERSION) $(SETUP_ENVTEST_BIN_DIR_OVERRIDE)) && \
KUBEBUILDER_ASSETS="$(shell $(SETUP_ENVTEST) use -p path $(ENVTEST_VERSION) $(SETUP_ENVTEST_BIN_DIR_OVERRIDE))" \
CGO_ENABLED=1 go test \
-tags '$(GO_BUILD_TAGS)' \
-cover -coverprofile ${ROOT_DIR}/coverage/unit.out \
-count=1 -race -short \
$(UNIT_TEST_DIRS) \
-test.gocoverdir=$(ROOT_DIR)/coverage/unit
-test.gocoverdir=$(COVERAGE_UNIT_DIR)

.PHONY: image-registry
E2E_REGISTRY_IMAGE=localhost/e2e-test-registry:devel
Expand Down
74 changes: 72 additions & 2 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package main

import (
"context"
"crypto/tls"
"flag"
"fmt"
"net/http"
Expand All @@ -41,9 +42,11 @@ import (
"k8s.io/klog/v2/textlogger"
ctrl "sigs.k8s.io/controller-runtime"
crcache "sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/certwatcher"
"sigs.k8s.io/controller-runtime/pkg/client"
crfinalizer "sigs.k8s.io/controller-runtime/pkg/finalizer"
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/metrics/filters"
"sigs.k8s.io/controller-runtime/pkg/metrics/server"

catalogd "github.com/operator-framework/catalogd/api/v1"
Expand All @@ -70,6 +73,7 @@ import (
var (
setupLog = ctrl.Log.WithName("setup")
defaultSystemNamespace = "olmv1-system"
certWatcher *certwatcher.CertWatcher
)

const authFilePrefix = "operator-controller-global-pull-secrets"
Expand All @@ -89,6 +93,8 @@ func podNamespace() string {
func main() {
var (
metricsAddr string
certFile string
keyFile string
enableLeaderElection bool
probeAddr string
cachePath string
Expand All @@ -97,9 +103,11 @@ func main() {
caCertDir string
globalPullSecret string
)
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
flag.StringVar(&metricsAddr, "metrics-bind-address", "", "The address for the metrics endpoint. Requires tls-cert and tls-key. (Default: ':8443')")
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
flag.StringVar(&caCertDir, "ca-certs-dir", "", "The directory of TLS certificate to use for verifying HTTPS connections to the Catalogd and docker-registry web servers.")
flag.StringVar(&certFile, "tls-cert", "", "The certificate file used for the metrics server. Required to enable the metrics server. Requires tls-key.")
flag.StringVar(&keyFile, "tls-key", "", "The key file used for the metrics server. Required to enable the metrics server. Requires tls-cert")
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
"Enable leader election for controller manager. "+
"Enabling this will ensure there is only one active controller manager.")
Expand All @@ -119,6 +127,20 @@ func main() {
os.Exit(0)
}

if (certFile != "" && keyFile == "") || (certFile == "" && keyFile != "") {
setupLog.Error(nil, "unable to configure TLS certificates: tls-cert and tls-key flags must be used together")
os.Exit(1)
}

if metricsAddr != "" && certFile == "" && keyFile == "" {
setupLog.Error(nil, "metrics-bind-address requires tls-cert and tls-key flags to be set")
os.Exit(1)
}

if certFile != "" && keyFile != "" && metricsAddr == "" {
metricsAddr = ":8443"
}

ctrl.SetLogger(textlogger.NewLogger(textlogger.NewConfig()))

setupLog.Info("starting up the controller", "version info", version.String())
Expand Down Expand Up @@ -161,9 +183,49 @@ func main() {
},
}
}

metricsServerOptions := server.Options{}
if len(certFile) > 0 && len(keyFile) > 0 {
setupLog.Info("Starting metrics server with TLS enabled", "addr", metricsAddr, "tls-cert", certFile, "tls-key", keyFile)

metricsServerOptions.BindAddress = metricsAddr
metricsServerOptions.SecureServing = true
metricsServerOptions.FilterProvider = filters.WithAuthenticationAndAuthorization

// If the certificate files change, the watcher will reload them.
var err error
certWatcher, err = certwatcher.New(certFile, keyFile)
if err != nil {
setupLog.Error(err, "Failed to initialize certificate watcher")
os.Exit(1)
}

metricsServerOptions.TLSOpts = append(metricsServerOptions.TLSOpts, func(config *tls.Config) {
config.GetCertificate = certWatcher.GetCertificate
// If the enable-http2 flag is false (the default), http/2 should be disabled
// due to its vulnerabilities. More specifically, disabling http/2 will
// prevent from being vulnerable to the HTTP/2 Stream Cancellation and
// Rapid Reset CVEs. For more information see:
// - https://github.com/advisories/GHSA-qppj-fm5r-hxr3
// - https://github.com/advisories/GHSA-4374-p667-p6c8
// Besides, those CVEs are solved already; the solution is still insufficient, and we need to mitigate
// the risks. More info https://github.com/golang/go/issues/63417
config.NextProtos = []string{"http/1.1"}
})
} else {
// Note that the metrics server is not serving if the BindAddress is set to "0".
// Therefore, the metrics server is disabled by default. It is only enabled
// if certFile and keyFile are provided. The intention is not allowing the metrics
// be served with the default self-signed certificate generated by controller-runtime.
metricsServerOptions.BindAddress = "0"

setupLog.Info("WARNING: Metrics Server is disabled. " +
"Metrics will not be served since the TLS certificate and key file are not provided.")
}

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme.Scheme,
Metrics: server.Options{BindAddress: metricsAddr},
Metrics: metricsServerOptions,
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "9c4404e7.operatorframework.io",
Expand Down Expand Up @@ -220,6 +282,14 @@ func main() {
os.Exit(1)
}

if certWatcher != nil {
setupLog.Info("Adding certificate watcher to manager")
if err := mgr.Add(certWatcher); err != nil {
setupLog.Error(err, "unable to add certificate watcher to manager")
os.Exit(1)
}
}

unpacker := &source.ContainersImageRegistry{
BaseCachePath: filepath.Join(cachePath, "unpack"),
SourceContextFunc: func(logger logr.Logger) (*types.SystemContext, error) {
Expand Down
2 changes: 1 addition & 1 deletion commitchecker.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
expectedMergeBase: 45f86cbcb2ffb3121d3708d6e33732427a339460
expectedMergeBase: 2c812aaf385ffe786538a2ef4928bd23feb58a74
upstreamBranch: main
upstreamOrg: operator-framework
upstreamRepo: operator-controller
3 changes: 1 addition & 2 deletions config/base/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ resources:
- crd
- rbac
- manager
# [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'.
#- ../prometheus

9 changes: 6 additions & 3 deletions config/base/manager/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
resources:
- manager.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- manager.yaml
- service.yaml

images:
- name: controller
newName: quay.io/operator-framework/operator-controller
newTag: devel
newTag: devel
23 changes: 1 addition & 22 deletions config/base/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ spec:
- /manager
args:
- "--health-probe-bind-address=:8081"
- "--metrics-bind-address=127.0.0.1:8080"
- "--metrics-bind-address=:8443"
- "--leader-elect"
image: controller:latest
imagePullPolicy: IfNotPresent
Expand Down Expand Up @@ -84,27 +84,6 @@ spec:
cpu: 10m
memory: 64Mi
terminationMessagePolicy: FallbackToLogsOnError
- name: kube-rbac-proxy
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- "ALL"
image: gcr.io/kubebuilder/kube-rbac-proxy:v0.15.0
args:
- --secure-listen-address=0.0.0.0:8443
- --http2-disable
- --upstream=http://127.0.0.1:8080/
- --logtostderr=true
ports:
- containerPort: 8443
protocol: TCP
name: https
resources:
requests:
cpu: 5m
memory: 64Mi
terminationMessagePolicy: FallbackToLogsOnError
serviceAccountName: operator-controller-controller-manager
terminationGracePeriodSeconds: 10
volumes:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: service
namespace: system
labels:
control-plane: operator-controller-controller-manager
name: controller-manager-metrics-service
namespace: system
spec:
ports:
- name: https
port: 8443
protocol: TCP
targetPort: https
targetPort: 8443
selector:
control-plane: operator-controller-controller-manager
2 changes: 0 additions & 2 deletions config/base/prometheus/kustomization.yaml

This file was deleted.

19 changes: 0 additions & 19 deletions config/base/prometheus/monitor.yaml

This file was deleted.

11 changes: 7 additions & 4 deletions config/base/rbac/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ resources:
- extension_editor_role.yaml
- extension_viewer_role.yaml

# Comment the following 4 lines if you want to disable
# the auth proxy (https://github.com/brancz/kube-rbac-proxy)
# which protects your /metrics endpoint.
- auth_proxy_service.yaml
# The following RBAC configurations are used to protect
# the metrics endpoint with authn/authz. These configurations
# ensure that only authorized users and service accounts
# can access the metrics endpoint. Comment the following
# permissions if you want to disable this protection.
# More info: https://book.kubebuilder.io/reference/metrics.html
- auth_proxy_role.yaml
- auth_proxy_role_binding.yaml
- auth_proxy_client_clusterrole.yaml

1 change: 0 additions & 1 deletion config/components/coverage/manager_e2e_coverage_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ spec:
template:
spec:
containers:
- name: kube-rbac-proxy
- name: manager
env:
- name: GOCOVERDIR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ spec:
template:
spec:
containers:
- name: kube-rbac-proxy
- name: manager
volumeMounts:
- name: e2e-registries-conf
Expand Down
8 changes: 7 additions & 1 deletion config/components/tls/patches/manager_deployment_cert.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
- op: add
path: /spec/template/spec/volumes/-
value: {"name":"olmv1-certificate", "secret":{"secretName":"olmv1-cert", "optional": false, "items": [{"key": "ca.crt", "path": "olm-ca.crt"}]}}
value: {"name":"olmv1-certificate", "secret":{"secretName":"olmv1-cert", "optional": false, "items": [{"key": "ca.crt", "path": "olm-ca.crt"}, {"key": "tls.crt", "path": "tls.cert"}, {"key": "tls.key", "path": "tls.key"}]}}
- op: add
path: /spec/template/spec/containers/0/volumeMounts/-
value: {"name":"olmv1-certificate", "readOnly": true, "mountPath":"/var/certs/"}
- op: add
path: /spec/template/spec/containers/0/args/-
value: "--ca-certs-dir=/var/certs"
- op: add
path: /spec/template/spec/containers/0/args/-
value: "--tls-cert=/var/certs/tls.cert"
- op: add
path: /spec/template/spec/containers/0/args/-
value: "--tls-key=/var/certs/tls.key"
4 changes: 2 additions & 2 deletions config/components/tls/resources/manager_cert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ metadata:
spec:
secretName: olmv1-cert
dnsNames:
- operator-controller.olmv1-system.svc
- operator-controller.olmv1-system.svc.cluster.local
- operator-controller-service.olmv1-system.svc
- operator-controller-service.olmv1-system.svc.cluster.local
privateKey:
algorithm: ECDSA
size: 256
Expand Down
5 changes: 4 additions & 1 deletion docs/project/olmv1_roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ hide:
- toc
---

# OLM v1 roadmap
# OLM v1 roadmap (Deprecated)

**Note**: The current roadmap is deprecated and it is not up-to-date. Refer to project [dashboard](https://github.com/orgs/operator-framework/projects/8/views/47) to get latest information.

## Functional Requirements
_Priority Rating: 1 highest, 2 medium, 3 lower (e.g. P2 = Medium Priority)_

Expand Down
Loading