Skip to content

Commit 2b93a4b

Browse files
Merge pull request #1215 from njhale/unpack-bundles
Unpack bundles
2 parents 7053452 + 4cef16c commit 2b93a4b

File tree

439 files changed

+43605
-3991
lines changed

Some content is hidden

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

439 files changed

+43605
-3991
lines changed

cmd/catalog/main.go

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@ import (
77
"fmt"
88
"net/http"
99
"os"
10-
"strings"
1110
"time"
1211

1312
configv1client "github.com/openshift/client-go/config/clientset/versioned/typed/config/v1"
1413
"github.com/prometheus/client_golang/prometheus/promhttp"
1514
log "github.com/sirupsen/logrus"
16-
v1 "k8s.io/api/core/v1"
1715
utilclock "k8s.io/apimachinery/pkg/util/clock"
1816
"k8s.io/client-go/tools/clientcmd"
1917

@@ -44,9 +42,6 @@ var (
4442
wakeupInterval = flag.Duration(
4543
"interval", defaultWakeupInterval, "wakeup interval")
4644

47-
watchedNamespaces = flag.String(
48-
"watchedNamespaces", "", "comma separated list of namespaces that catalog watches, leave empty to watch all namespaces")
49-
5045
catalogNamespace = flag.String(
5146
"namespace", defaultCatalogNamespace, "namespace where catalog will run and install catalog resources")
5247

@@ -91,16 +86,6 @@ func main() {
9186
os.Exit(0)
9287
}
9388

94-
// `namespaces` will always contain at least one entry: if `*watchedNamespaces` is
95-
// the empty string, the resulting array will be `[]string{""}`.
96-
namespaces := strings.Split(*watchedNamespaces, ",")
97-
for _, ns := range namespaces {
98-
if ns == v1.NamespaceAll {
99-
namespaces = []string{v1.NamespaceAll}
100-
break
101-
}
102-
}
103-
10489
logger := log.New()
10590
if *debug {
10691
logger.SetLevel(log.DebugLevel)
@@ -183,7 +168,7 @@ func main() {
183168
}
184169

185170
// Create a new instance of the operator.
186-
op, err := catalog.NewOperator(ctx, *kubeConfigPath, utilclock.RealClock{}, logger, *wakeupInterval, *configmapServerImage, *catalogNamespace, namespaces...)
171+
op, err := catalog.NewOperator(ctx, *kubeConfigPath, utilclock.RealClock{}, logger, *wakeupInterval, *configmapServerImage, *catalogNamespace)
187172
if err != nil {
188173
log.Panicf("error configuring operator: %s", err.Error())
189174
}

deploy/chart/templates/0000_50_olm_04-installplan.crd.yaml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,87 @@ spec:
126126
uid:
127127
description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids'
128128
type: string
129+
bundleLookups:
130+
type: array
131+
items:
132+
type: object
133+
required:
134+
- catalogSourceRef
135+
- path
136+
- replaces
137+
properties:
138+
catalogSourceRef:
139+
description: ObjectReference contains enough information to let
140+
you inspect or modify the referred object.
141+
type: object
142+
properties:
143+
apiVersion:
144+
description: API version of the referent.
145+
type: string
146+
fieldPath:
147+
description: 'If referring to a piece of an object instead
148+
of an entire object, this string should contain a valid
149+
JSON/Go field access statement, such as desiredState.manifest.containers[2].
150+
For example, if the object reference is to a container within
151+
a pod, this would take on a value like: "spec.containers{name}"
152+
(where "name" refers to the name of the container that triggered
153+
the event) or if no container name is specified "spec.containers[2]"
154+
(container with index 2 in this pod). This syntax is chosen
155+
only to have some well-defined way of referencing a part
156+
of an object. TODO: this design is not final and this field
157+
is subject to change in the future.'
158+
type: string
159+
kind:
160+
description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
161+
type: string
162+
name:
163+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
164+
type: string
165+
namespace:
166+
description: 'Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/'
167+
type: string
168+
resourceVersion:
169+
description: 'Specific resourceVersion to which this reference
170+
is made, if any. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency'
171+
type: string
172+
uid:
173+
description: 'UID of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids'
174+
type: string
175+
conditions:
176+
type: array
177+
items:
178+
type: object
179+
required:
180+
- status
181+
- type
182+
properties:
183+
lastTransitionTime:
184+
description: Last time the condition transitioned from one
185+
status to another.
186+
type: string
187+
format: date-time
188+
lastUpdateTime:
189+
description: Last time the condition was probed
190+
type: string
191+
format: date-time
192+
message:
193+
description: A human readable message indicating details
194+
about the transition.
195+
type: string
196+
reason:
197+
description: The reason for the condition's last transition.
198+
type: string
199+
status:
200+
description: Status of the condition, one of True, False,
201+
Unknown.
202+
type: string
203+
type:
204+
description: Type of condition.
205+
type: string
206+
path:
207+
type: string
208+
replaces:
209+
type: string
129210
catalogSources:
130211
type: array
131212
items:

deploy/chart/templates/0000_50_olm_08-catalog-operator.deployment.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ spec:
2626
command:
2727
- /bin/catalog
2828
args:
29-
{{- if .Values.watchedNamespaces }}
30-
- -watchedNamespaces
31-
- {{ .Values.watchedNamespaces }}
32-
{{- end }}
3329
- '-namespace'
3430
- {{ .Values.catalog_namespace }}
3531
{{- if .Values.debug }}

doc/design/resolving-bundle-images.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Resolving Bundle Images
2+
3+
An operator [UpdateGraph](https://operator-framework.github.io/olm-book/docs/glossary.html#upgrade-graph) may refer to an operator [Bundle](https://operator-framework.github.io/olm-book/docs/glossary.html#bundle) with a reference to a [Bundle Image](https://operator-framework.github.io/olm-book/docs/glossary.html#bundle-image) containing its content. This means that the content of these referenced bundles is not immediately available for application to a cluster and must first be pulled and unpacked.
4+
5+
## Resolving
6+
7+
The same metadata available for bundles queried from a [`CatalogSource`](https://operator-framework.github.io/olm-book/docs/glossary.html#catalogsources) is available for bundle images. This lets OLM resolve dependencies and updates without pulling them to the cluster. Once the final set of operators has been identified for install, OLM codifies the information needed to pull any included bundle images in the `status.BundleLookups` field of the resulting `InstallPlan`:
8+
9+
```yaml
10+
status:
11+
bundleLookups:
12+
- path: quay.io/coreos/prometheus-operator@sha256...
13+
replaces: ""
14+
catalogSourceRef:
15+
Namespace: operators
16+
Name: monitoring
17+
```
18+
19+
## Unpacking
20+
21+
OLM uses the `status.bundleLookups` field, added to `InstallPlans` during dependency resolution, to determine which bundle images need to be unpacked.
22+
23+
Given an `InstallPlan` with the following `status`:
24+
25+
```yaml
26+
status:
27+
bundleLookups:
28+
- path: quay.io/coreos/prometheus-operator@sha256...
29+
replaces: ""
30+
catalogSourceRef:
31+
Namespace: operators
32+
Name: monitoring
33+
- path: quay.io/coreos/etcd-operator@sha256...
34+
replaces: "etcd-operator.v4.1"
35+
catalogSourceRef:
36+
Namespace: operators
37+
Name: storage
38+
```
39+
40+
__Note:__ Image tag references may be used in place of digests, but once a tag has been unpacked, updates to the underlying image will not be respected unless the resources described below are deleted._
41+
42+
Each unique `BundlePath` will result in OLM creating four top-level resources in the namespace of the referenced `CatalogSource`:
43+
44+
1. A `ConfigMap` to hold the unpacked manifests
45+
2. A `Role` allowing `create`, `get`, and `update` on that `ConfigMap`
46+
3. A `RoleBinding` granting that `Role` to the default `ServiceAccount`
47+
4. An unpack `Job` using the default `ServiceAccount` to export the bundle image's content into that `ConfigMap`
48+
49+
OLM uses the same reproducible name for all of these resources; the `sha256` checksum of the respective `BundlePath`.
50+
51+
__Note:__ _This choice of name allows OLM to reuse previously unpacked bundles between `InstallPlans` by making them discoverable and ensuring resource uniqueness._
52+
53+
The `Role`, `RoleBinding`, and `Job` have `OwnerReferences` to the `ConfigMap`, while the `ConfigMap` has an `OwnerReference` to the `CatalogSource` referenced by its respective `BundleLookup`. If the referenced `CatalogSource` is not found, a `BundleLookupPending` condition is added to the `BundleLookup`:
54+
55+
```yaml
56+
path: quay.io/coreos/prometheus-operator@sha256...
57+
replaces: ""
58+
catalogSourceRef:
59+
Namespace: operators
60+
Name: monitoring
61+
conditions:
62+
type: BundleLookupPending
63+
status: "True"
64+
reason: CatalogSourceMissing
65+
message: "referenced catalogsource not found"
66+
lastTransitionTime: "2020-01-08T23:42:59Z"
67+
```
68+
69+
A given unpack `Job` will start a `Pod` consisting of two containers:
70+
71+
1. An init container that has a release of the [`opm`](https://github.com/operator-framework/operator-registry/tree/master/cmd/opm) binary
72+
2. A container from the bundle image reference
73+
74+
These two containers share a volume mount into which the init container copies its `opm` binary. After initalization, the bundle image container uses this copy to execute the `opm bundle extract` command, extracting the bundle content from its filesystem into the bundle's respective `ConfigMap`.
75+
76+
When an unpack `Job` exists but is not in a `Complete` state, a `BundleLookupPending` condition is added to its `BundleLookup`:
77+
78+
```yaml
79+
path: quay.io/coreos/prometheus-operator@sha256...
80+
replaces: ""
81+
catalogSourceRef:
82+
Namespace: operators
83+
Name: monitoring
84+
conditions:
85+
type: BundleLookupPending
86+
status: "True"
87+
reason: JobIncomplete
88+
message: "unpack job not completed"
89+
lastTransitionTime: "2020-01-08T23:43:30Z"
90+
```
91+
92+
Once an unpack `Job` runs to completion, the data in the respective `ConfigMap` is converted into a set of install steps and is added to the status the `InstallPlan`. In the same transaction, the `BundleLookup` entry is removed.

go.mod

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,52 +8,49 @@ require (
88
github.com/coreos/go-semver v0.3.0
99
github.com/coreos/go-systemd v0.0.0-20190620071333-e64a0ec8b42a // indirect
1010
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
11-
github.com/emicklei/go-restful v2.9.6+incompatible // indirect
12-
github.com/evanphx/json-patch v4.5.0+incompatible // indirect
1311
github.com/fsnotify/fsnotify v1.4.7
1412
github.com/ghodss/yaml v1.0.0
15-
github.com/go-openapi/spec v0.19.2
16-
github.com/golang/groupcache v0.0.0-20181024230925-c65c006176ff // indirect
13+
github.com/go-openapi/spec v0.19.4
1714
github.com/golang/mock v1.3.1
18-
github.com/google/btree v1.0.0 // indirect
19-
github.com/googleapis/gnostic v0.3.0 // indirect
2015
github.com/grpc-ecosystem/go-grpc-middleware v1.1.0 // indirect
2116
github.com/grpc-ecosystem/grpc-gateway v1.9.4 // indirect
22-
github.com/maxbrunsfeld/counterfeiter/v6 v6.2.1
17+
github.com/maxbrunsfeld/counterfeiter/v6 v6.2.2
2318
github.com/mikefarah/yq/v2 v2.4.1
2419
github.com/mitchellh/hashstructure v1.0.0
2520
github.com/munnerz/goautoneg v0.0.0-20190414153302-2ae31c8b6b30 // indirect
2621
github.com/openshift/api v3.9.1-0.20190924102528-32369d4db2ad+incompatible
2722
github.com/openshift/client-go v0.0.0-20190923180330-3b6373338c9b
28-
github.com/operator-framework/operator-registry v1.5.3
23+
github.com/operator-framework/operator-registry v1.5.6
2924
github.com/pkg/errors v0.8.1
30-
github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829
25+
github.com/prometheus/client_golang v1.2.1
3126
github.com/sirupsen/logrus v1.4.2
3227
github.com/soheilhy/cmux v0.1.4 // indirect
3328
github.com/spf13/cobra v0.0.5
3429
github.com/stretchr/testify v1.4.0
3530
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 // indirect
3631
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
37-
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4
32+
golang.org/x/time v0.0.0-20191024005414-555d28b269f0
3833
gonum.org/v1/gonum v0.0.0-20190710053202-4340aa3071a0 // indirect
39-
google.golang.org/grpc v1.23.0
40-
k8s.io/api v0.0.0
34+
google.golang.org/grpc v1.24.0
35+
k8s.io/api v0.17.0
4136
k8s.io/apiextensions-apiserver v0.0.0
42-
k8s.io/apimachinery v0.0.0
37+
k8s.io/apimachinery v0.17.0
4338
k8s.io/apiserver v0.0.0
4439
k8s.io/client-go v8.0.0+incompatible
4540
k8s.io/code-generator v0.0.0
4641
k8s.io/component-base v0.0.0
47-
k8s.io/klog v0.4.0
42+
k8s.io/klog v1.0.0
4843
k8s.io/kube-aggregator v0.0.0
49-
k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf
44+
k8s.io/kube-openapi v0.0.0-20190918143330-0270cf2f1c1d
5045
k8s.io/kubernetes v1.16.0
5146
sigs.k8s.io/controller-tools v0.2.4
5247
)
5348

5449
replace (
50+
github.com/docker/docker => github.com/moby/moby v0.7.3-0.20190826074503-38ab9da00309 // Required by Helm
5551
github.com/openshift/api => github.com/openshift/api v3.9.1-0.20190924102528-32369d4db2ad+incompatible
5652
github.com/openshift/client-go => github.com/openshift/client-go v0.0.0-20190923180330-3b6373338c9b
53+
github.com/prometheus/client_golang => github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829
5754

5855
// Pin to kube 1.16
5956
k8s.io/api => k8s.io/api v0.0.0-20190918155943-95b840bb6a1f

0 commit comments

Comments
 (0)