Skip to content

Commit ee6ea6d

Browse files
committed
Helm PoC latest rebase
plug in resolver Deal with removal of HigherBundleVersion Removed in e079129 Signed-off-by: Todd Short <[email protected]> :sparkles: Starting Helm POC - pull in some rukpak (#756) * Fix suite_test.go Signed-off-by: Todd Short <[email protected]> * Copy over some rukpak code and replace BundleDeployment Replace BundleDeployment in the Unpack APIs with a combination of BundleSource and ClusterExtension. It builds... Signed-off-by: Todd Short <[email protected]> * fixup! Copy over some rukpak code and replace BundleDeployment --------- Signed-off-by: Todd Short <[email protected]> Plugin unpacker, add Handler (#757) Signed-off-by: Varsha Prasad Narsing <[email protected]> Co-authored-by: [email protected] <[email protected]> A bit of cleanup (#761) Signed-off-by: Todd Short <[email protected]> :warning: Install the helm chart (#762) * Install the helm chart Signed-off-by: Todd Short <[email protected]> * fixup! Install the helm chart Signed-off-by: Todd Short <[email protected]> --------- Signed-off-by: Todd Short <[email protected]> Set up right watches and all labels to postrenderer (#763) Co-authored-by: [email protected] <[email protected]> :warning: Update owner keys (#765) * Update owner keys Signed-off-by: Todd Short <[email protected]> * fixup! Update owner keys Signed-off-by: Todd Short <[email protected]> --------- Signed-off-by: Todd Short <[email protected]> No more panics (#767) Signed-off-by: Todd Short <[email protected]> Add relevant RBAC to enable controller to watch resources (#776) Co-authored-by: [email protected] <[email protected]> Changes required for ClusterExtension to install an operator (#789) * Add relevant RBAC to enable controller to watch resources * Debugging iteration - one * ClusterExtension installing the operator - working --------- Co-authored-by: [email protected] <[email protected]> Fix some lints (#793) Signed-off-by: Todd Short <[email protected]> :sparkles: Getting cluster extension running (#795) * Getting cluster extension running * Specify namespace to create secret Set resolved and installed versions (#806) Remove install references to rukpak (#805) Signed-off-by: Todd Short <[email protected]> Consolidate error message generation (#807) Signed-off-by: Todd Short <[email protected]> Add make kind-redeploy (#808) Signed-off-by: Todd Short <[email protected]> Use rukpak as a library (#821) Signed-off-by: Todd Short <[email protected]> Improve caching and fix constant reconciles (#825) Improve performance by caching objects that only have ClusterExtension as owners. Signed-off-by: Varsha Prasad Narsing <[email protected]> Fix linter (#826) Signed-off-by: Varsha Prasad Narsing <[email protected]> Move helm-operator-plugin (#828) Signed-off-by: Todd Short <[email protected]> Really fix linter (#833) Signed-off-by: Todd Short <[email protected]>
1 parent 9bbc444 commit ee6ea6d

25 files changed

+1541
-774
lines changed

.github/workflows/tilt.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ jobs:
2222
- uses: actions/checkout@v4
2323
with:
2424
path: operator-controller
25-
- uses: actions/checkout@v4
26-
with:
27-
repository: operator-framework/rukpak
28-
path: rukpak
2925
- uses: actions/checkout@v4
3026
with:
3127
repository: operator-framework/catalogd

CONTRIBUTING.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ The user experience captured in the OLM V1 PRD introduces many requirements that
1919
- [The Operator-Controller project](https://github.com/operator-framework/operator-controller/), which is the top level component allowing users to specify operators they'd like to install.
2020
- [The Catalogd project](https://github.com/operator-framework/catalogd/), which hosts operator content and helps users discover installable content.
2121
- [The Deppy project](https://github.com/operator-framework/deppy/), which enables the operator-controller to identify valid installs and upgrades from the list of installable content provided via the Catalogd project.
22-
- [The RukPak project](https://github.com/operator-framework/rukpak/), which facilitates the installation of operators.
2322

24-
Each of the projects listed above have their own governance, release milestones, and release cadence. However, from a technical perspective, the "OLM V1 experience" matches the experienced offered by the operator-controller project, the top level component which introduces dependencies on RukPak, Deppy, and the Catalogd projects.
23+
Each of the projects listed above have their own governance, release milestones, and release cadence. However, from a technical perspective, the "OLM V1 experience" matches the experienced offered by the operator-controller project, the top level component which introduces dependencies on Deppy and the Catalogd projects.
2524

2625
## How do we collaborate
2726

@@ -62,7 +61,7 @@ Ongoing or previous Operator-Controller milestones can always be found in the [m
6261

6362
### How are Subproject Issues Tracked?
6463

65-
As discussed earlier, the operator-controller adheres to a microservice architecture, where multiple projects contribute to the overall experience. As such, when designing an operator-controller milestone, the community may need to file an issue against RukPak, Deppy, or Catalogd. Unfortunately, the operator-controller milestone cannot contain issues from one of its subprojects. As such, we've introduced the concept of a "Dependency Issue", described below:
64+
As discussed earlier, the operator-controller adheres to a microservice architecture, where multiple projects contribute to the overall experience. As such, when designing an operator-controller milestone, the community may need to file an issue against Deppy or Catalogd. Unfortunately, the operator-controller milestone cannot contain issues from one of its subprojects. As such, we've introduced the concept of a "Dependency Issue", described below:
6665

6766
> Dependency Issues: An issue tracked in a milestone that "points" to an issue in another project with a URL.
6867
@@ -72,7 +71,6 @@ Unsure where to submit an issue?
7271
- [The Operator-Controller project](https://github.com/operator-framework/operator-controller/), which is the top level component allowing users to specify operators they'd like to install.
7372
- [The Catalogd project](https://github.com/operator-framework/catalogd/), which hosts operator content and helps users discover installable content.
7473
- [The Deppy project](https://github.com/operator-framework/deppy/), which enables the operator-controller to identify valid installs and upgrades from the list of installable content provided via the Catalogd project.
75-
- [The RukPak project](https://github.com/operator-framework/rukpak/), which facilitates the installation of operators.
7674

7775
Don't worry if you accidentally submit an issue against the wrong project, if we notice that an issue would fit better with a separate project we'll move it to the correct repository and mention it in the #olm-dev slack channel.
7876

Makefile

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ IMG := $(IMAGE_REPO):$(IMAGE_TAG)
1919
export CERT_MGR_VERSION := v1.9.0
2020
export CATALOGD_VERSION := $(shell go list -mod=mod -m -f "{{.Version}}" github.com/operator-framework/catalogd)
2121
export KAPP_VERSION := $(shell go list -mod=mod -m -f "{{.Version}}" github.com/vmware-tanzu/carvel-kapp-controller)
22-
export RUKPAK_VERSION := $(shell go list -mod=mod -m -f "{{.Version}}" github.com/operator-framework/rukpak)
2322
export WAIT_TIMEOUT := 60s
2423

2524
# By default setup-envtest will write to $XDG_DATA_HOME, or $HOME/.local/share if that is not defined.
@@ -164,10 +163,15 @@ e2e-coverage:
164163
kind-load: $(KIND) #EXHELP Loads the currently constructed image onto the cluster.
165164
$(CONTAINER_RUNTIME) save $(IMG) | $(KIND) load image-archive /dev/stdin --name $(KIND_CLUSTER_NAME)
166165

167-
kind-deploy: export MANIFEST := ./operator-controller.yaml
166+
.PHONY: kind-deploy
167+
kind-deploy: export MANIFEST="./operator-controller.yaml"
168168
kind-deploy: manifests $(KUSTOMIZE) #EXHELP Install controller and dependencies onto the kind cluster.
169169
$(KUSTOMIZE) build $(KUSTOMIZE_BUILD_DIR) > operator-controller.yaml
170-
envsubst '$$CATALOGD_VERSION,$$CERT_MGR_VERSION,$$KAPP_VERSION,$$RUKPAK_VERSION,$$MANIFEST' < scripts/install.tpl.sh | bash -s
170+
envsubst '$$CATALOGD_VERSION,$$CERT_MGR_VERSION,$$KAPP_VERSION,$$MANIFEST' < scripts/install.tpl.sh | bash -s
171+
172+
.PHONY: kind-redeploy
173+
kind-redeploy: generate docker-build kind-load kind-deploy #EXHELP Redeploy newly built executables
174+
kubectl delete pod -l control-plane=controller-manager -n $(OPERATOR_CONTROLLER_NAMESPACE)
171175

172176
.PHONY: kind-cluster
173177
kind-cluster: $(KIND) #EXHELP Standup a kind cluster.
@@ -252,7 +256,7 @@ release: $(GORELEASER) #EXHELP Runs goreleaser for the operator-controller. By d
252256
quickstart: export MANIFEST := https://github.com/operator-framework/operator-controller/releases/download/$(VERSION)/operator-controller.yaml
253257
quickstart: $(KUSTOMIZE) manifests #EXHELP Generate the installation release manifests and scripts.
254258
$(KUSTOMIZE) build $(KUSTOMIZE_BUILD_DIR) | sed "s/:devel/:$(VERSION)/g" > operator-controller.yaml
255-
envsubst '$$CATALOGD_VERSION,$$CERT_MGR_VERSION,$$KAPP_VERSION,$$RUKPAK_VERSION,$$MANIFEST' < scripts/install.tpl.sh > install.sh
259+
envsubst '$$CATALOGD_VERSION,$$CERT_MGR_VERSION,$$KAPP_VERSION,$$MANIFEST' < scripts/install.tpl.sh > install.sh
256260

257261
##@ Docs
258262

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ OLM v1 is the follow-up to OLM v0, located [here](https://github.com/operator-fr
1717
OLM v1 consists of four different components:
1818
* operator-controller (this repository)
1919
* [deppy](https://github.com/operator-framework/deppy)
20-
* [rukpak](https://github.com/operator-framework/rukpak)
2120
* [catalogd](https://github.com/operator-framework/catalogd)
2221

2322
For a more complete overview of OLM v1 and how it differs from OLM v0, see our [overview](./docs/olmv1_overview.md).
@@ -76,7 +75,7 @@ Install the CRDs and the operator-controller into a new [KIND cluster](https://k
7675
make run
7776
```
7877
This will build a local container image of the operator-controller, create a new KIND cluster and then deploy onto that cluster.
79-
This will also deploy the catalogd, rukpak and cert-manager dependencies.
78+
This will also deploy the catalogd and cert-manager dependencies.
8079

8180
### Modifying the API definitions
8281
If you are editing the API definitions, generate the manifests such as CRs or CRDs using:

Tiltfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ load('../tilt-support/Tiltfile', 'deploy_repo')
55

66
config.define_string_list('repos', args=True)
77
cfg = config.parse()
8-
repos = cfg.get('repos', ['operator-controller', 'rukpak', 'catalogd'])
8+
repos = cfg.get('repos', ['operator-controller', 'catalogd'])
99

1010
repo = {
1111
'image': 'quay.io/operator-framework/operator-controller',

api/v1alpha1/clusterextension_types.go

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ import (
2222
"github.com/operator-framework/operator-controller/internal/conditionsets"
2323
)
2424

25+
var (
26+
ClusterExtensionGVK = SchemeBuilder.GroupVersion.WithKind("ClusterExtension")
27+
ClusterExtensionKind = ClusterExtensionGVK.Kind
28+
)
29+
2530
type UpgradeConstraintPolicy string
2631

2732
const (
@@ -77,15 +82,20 @@ type ClusterExtensionSpec struct {
7782

7883
const (
7984
// TODO(user): add more Types, here and into init()
80-
TypeInstalled = "Installed"
81-
TypeResolved = "Resolved"
85+
TypeInstalled = "Installed"
86+
TypeResolved = "Resolved"
87+
TypeHasValidBundle = "HasValidBundle"
88+
TypeHealthy = "Healthy"
89+
8290
// TypeDeprecated is a rollup condition that is present when
8391
// any of the deprecated conditions are present.
8492
TypeDeprecated = "Deprecated"
8593
TypePackageDeprecated = "PackageDeprecated"
8694
TypeChannelDeprecated = "ChannelDeprecated"
8795
TypeBundleDeprecated = "BundleDeprecated"
8896

97+
ReasonErrorGettingClient = "ErrorGettingClient"
98+
ReasonBundleLoadFailed = "BundleLoadFailed"
8999
ReasonBundleLookupFailed = "BundleLookupFailed"
90100
ReasonInstallationFailed = "InstallationFailed"
91101
ReasonInstallationStatusUnknown = "InstallationStatusUnknown"
@@ -95,13 +105,18 @@ const (
95105
ReasonResolutionUnknown = "ResolutionUnknown"
96106
ReasonSuccess = "Success"
97107
ReasonDeprecated = "Deprecated"
108+
ReasonErrorGettingReleaseState = "ErrorGettingReleaseState"
109+
ReasonUpgradeFailed = "UpgradeFailed"
110+
ReasonCreateDynamicWatchFailed = "CreateDynamicWatchFailed"
98111
)
99112

100113
func init() {
101114
// TODO(user): add Types from above
102115
conditionsets.ConditionTypes = append(conditionsets.ConditionTypes,
103116
TypeInstalled,
104117
TypeResolved,
118+
TypeHasValidBundle,
119+
TypeHealthy,
105120
TypeDeprecated,
106121
TypePackageDeprecated,
107122
TypeChannelDeprecated,
@@ -118,6 +133,11 @@ func init() {
118133
ReasonInvalidSpec,
119134
ReasonSuccess,
120135
ReasonDeprecated,
136+
ReasonErrorGettingReleaseState,
137+
ReasonUpgradeFailed,
138+
ReasonCreateDynamicWatchFailed,
139+
ReasonBundleLoadFailed,
140+
ReasonErrorGettingClient,
121141
)
122142
}
123143

@@ -127,7 +147,6 @@ type ClusterExtensionStatus struct {
127147
InstalledBundle *BundleMetadata `json:"installedBundle,omitempty"`
128148
// +optional
129149
ResolvedBundle *BundleMetadata `json:"resolvedBundle,omitempty"`
130-
131150
// +patchMergeKey=type
132151
// +patchStrategy=merge
133152
// +listType=map

cmd/manager/main.go

Lines changed: 94 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,37 @@ limitations under the License.
1717
package main
1818

1919
import (
20+
"crypto/x509"
2021
"flag"
22+
"fmt"
2123
"net/http"
24+
"net/url"
2225
"os"
2326
"time"
2427

2528
"github.com/spf13/pflag"
2629
"go.uber.org/zap/zapcore"
30+
k8slabels "k8s.io/apimachinery/pkg/labels"
31+
"k8s.io/apimachinery/pkg/selection"
2732
_ "k8s.io/client-go/plugin/pkg/client/auth"
2833
ctrl "sigs.k8s.io/controller-runtime"
34+
crcache "sigs.k8s.io/controller-runtime/pkg/cache"
35+
"sigs.k8s.io/controller-runtime/pkg/client"
2936
"sigs.k8s.io/controller-runtime/pkg/healthz"
3037
"sigs.k8s.io/controller-runtime/pkg/log/zap"
3138
"sigs.k8s.io/controller-runtime/pkg/metrics/server"
3239

40+
helmclient "github.com/operator-framework/helm-operator-plugins/pkg/client"
41+
"github.com/operator-framework/rukpak/pkg/source"
42+
"github.com/operator-framework/rukpak/pkg/storage"
43+
"github.com/operator-framework/rukpak/pkg/util"
44+
45+
"github.com/operator-framework/operator-controller/api/v1alpha1"
3346
"github.com/operator-framework/operator-controller/internal/catalogmetadata/cache"
3447
catalogclient "github.com/operator-framework/operator-controller/internal/catalogmetadata/client"
3548
"github.com/operator-framework/operator-controller/internal/controllers"
49+
"github.com/operator-framework/operator-controller/internal/handler"
50+
"github.com/operator-framework/operator-controller/internal/labels"
3651
"github.com/operator-framework/operator-controller/pkg/features"
3752
"github.com/operator-framework/operator-controller/pkg/scheme"
3853
)
@@ -43,17 +58,25 @@ var (
4358

4459
func main() {
4560
var (
46-
metricsAddr string
47-
enableLeaderElection bool
48-
probeAddr string
49-
cachePath string
61+
metricsAddr string
62+
enableLeaderElection bool
63+
probeAddr string
64+
cachePath string
65+
httpExternalAddr string
66+
systemNamespace string
67+
unpackImage string
68+
provisionerStorageDirectory string
5069
)
5170
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
5271
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
72+
flag.StringVar(&httpExternalAddr, "http-external-address", "http://localhost:8080", "The external address at which the http server is reachable.")
5373
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
5474
"Enable leader election for controller manager. "+
5575
"Enabling this will ensure there is only one active controller manager.")
5676
flag.StringVar(&cachePath, "cache-path", "/var/cache", "The local directory path used for filesystem based caching")
77+
flag.StringVar(&systemNamespace, "system-namespace", "", "Configures the namespace that gets used to deploy system resources.")
78+
flag.StringVar(&unpackImage, "unpack-image", util.DefaultUnpackImage, "Configures the container image that gets used to unpack Bundle contents.")
79+
flag.StringVar(&provisionerStorageDirectory, "provisioner-storage-dir", storage.DefaultBundleCacheDir, "The directory that is used to store bundle contents.")
5780
opts := zap.Options{
5881
Development: true,
5982
}
@@ -65,12 +88,33 @@ func main() {
6588

6689
ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts), zap.StacktraceLevel(zapcore.DPanicLevel)))
6790

91+
if systemNamespace == "" {
92+
systemNamespace = util.PodNamespace()
93+
}
94+
95+
dependentRequirement, err := k8slabels.NewRequirement(labels.OwnerKindKey, selection.In, []string{v1alpha1.ClusterExtensionKind})
96+
if err != nil {
97+
setupLog.Error(err, "unable to create dependent label selector for cache")
98+
os.Exit(1)
99+
}
100+
dependentSelector := k8slabels.NewSelector().Add(*dependentRequirement)
101+
102+
fmt.Println("set up manager")
68103
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
69104
Scheme: scheme.Scheme,
70105
Metrics: server.Options{BindAddress: metricsAddr},
71106
HealthProbeBindAddress: probeAddr,
72107
LeaderElection: enableLeaderElection,
73108
LeaderElectionID: "9c4404e7.operatorframework.io",
109+
Cache: crcache.Options{
110+
ByObject: map[client.Object]crcache.ByObject{
111+
&v1alpha1.ClusterExtension{}: {},
112+
},
113+
DefaultNamespaces: map[string]crcache.Config{
114+
systemNamespace: {},
115+
crcache.AllNamespaces: {LabelSelector: dependentSelector},
116+
},
117+
},
74118
// LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily
75119
// when the Manager ends. This requires the binary to immediately end when the
76120
// Manager is stopped, otherwise, this setting is unsafe. Setting this significantly
@@ -91,21 +135,58 @@ func main() {
91135
cl := mgr.GetClient()
92136
catalogClient := catalogclient.New(cl, cache.NewFilesystemCache(cachePath, &http.Client{Timeout: 10 * time.Second}))
93137

94-
if err = (&controllers.ClusterExtensionReconciler{
95-
Client: cl,
96-
BundleProvider: catalogClient,
97-
}).SetupWithManager(mgr); err != nil {
98-
setupLog.Error(err, "unable to create controller", "controller", "ClusterExtension")
138+
cfgGetter, err := helmclient.NewActionConfigGetter(mgr.GetConfig(), mgr.GetRESTMapper(), helmclient.StorageNamespaceMapper(func(o client.Object) (string, error) {
139+
return systemNamespace, nil
140+
}))
141+
if err != nil {
142+
setupLog.Error(err, "unable to config for creating helm client")
143+
os.Exit(1)
144+
}
145+
146+
acg, err := helmclient.NewActionClientGetter(cfgGetter)
147+
if err != nil {
148+
setupLog.Error(err, "unable to create helm client")
149+
os.Exit(1)
150+
}
151+
152+
unpacker, err := source.NewDefaultUnpacker(mgr, systemNamespace, unpackImage, (*x509.CertPool)(nil))
153+
if err != nil {
154+
setupLog.Error(err, "unable to create unpacker")
155+
os.Exit(1)
156+
}
157+
158+
storageURL, err := url.Parse(fmt.Sprintf("%s/bundles/", httpExternalAddr))
159+
if err != nil {
160+
setupLog.Error(err, "unable to parse bundle content server URL")
99161
os.Exit(1)
100162
}
101163

102-
if err = (&controllers.ExtensionReconciler{
103-
Client: cl,
104-
BundleProvider: catalogClient,
164+
localStorage := &storage.LocalDirectory{
165+
RootDirectory: provisionerStorageDirectory,
166+
URL: *storageURL,
167+
}
168+
169+
if err = (&controllers.ClusterExtensionReconciler{
170+
Client: cl,
171+
ReleaseNamespace: systemNamespace,
172+
BundleProvider: catalogClient,
173+
Scheme: mgr.GetScheme(),
174+
ActionClientGetter: acg,
175+
Unpacker: unpacker,
176+
Storage: localStorage,
177+
Handler: handler.HandlerFunc(handler.HandleClusterExtension),
105178
}).SetupWithManager(mgr); err != nil {
106-
setupLog.Error(err, "unable to create controller", "controller", "Extension")
179+
setupLog.Error(err, "unable to create controller", "controller", "ClusterExtension")
107180
os.Exit(1)
108181
}
182+
183+
// if err = (&controllers.ExtensionReconciler{
184+
// Client: cl,
185+
// BundleProvider: catalogClient,
186+
// }).SetupWithManager(mgr); err != nil {
187+
// setupLog.Error(err, "unable to create controller", "controller", "Extension")
188+
// os.Exit(1)
189+
// }
109190
//+kubebuilder:scaffold:builder
110191

111192
if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {

config/manager/manager.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ spec:
6161
volumeMounts:
6262
- name: cache
6363
mountPath: /var/cache
64+
- name: bundle-cache
65+
mountPath: /var/cache/bundles
6466
securityContext:
6567
allowPrivilegeEscalation: false
6668
capabilities:
@@ -111,3 +113,5 @@ spec:
111113
volumes:
112114
- name: cache
113115
emptyDir: {}
116+
- name: bundle-cache
117+
emptyDir: {}

0 commit comments

Comments
 (0)