|
1 | 1 | # Pull Bundle on a Cluster
|
2 | 2 |
|
| 3 | +The purpose of this proposal is to allow bundle data to be pulled at install time. At a high level, this starts with launching the bundle inside a pod and then writing the data found inside of the container into a configmap. |
| 4 | + |
| 5 | +## Launching a bundle image for data extraction |
| 6 | + |
| 7 | +The function to call for launching the bundle looks like: |
| 8 | + |
| 9 | +LaunchBundleImage(kubeclient kubernetes.Interface, bundleImage, initImage, namespace string) (*corev1.ConfigMap, *batchv1.Job, error) |
| 10 | + |
| 11 | +Here the bundle image, init image, and namespace are the core parameters. Note that it is a requirement that the service account have permissions to update configmaps in the specified namespace. In the expected usage however, the namespace of OLM will be used and permissions will not be a problem. The configmap and job are returned for the caller to delete when done. |
| 12 | + |
| 13 | +Within the launch function a job is called using a spec simliar to what is described below. Unique random names are able to be depended upon by using generateName for both the job and configmap. |
| 14 | + |
| 15 | +```yaml |
| 16 | +apiVersion: batch/v1 |
| 17 | +kind: Job |
| 18 | +metadata: |
| 19 | + generateName: deploy-bundle-image- |
| 20 | +spec: |
| 21 | + #ttlSecondsAfterFinished: 0 # alpha feature - https://github.com/kubernetes/enhancements/issues/592, https://github.com/kubernetes/kubernetes/pull/82082 |
| 22 | + template: |
| 23 | + metadata: |
| 24 | + name: bundle-image |
| 25 | + spec: |
| 26 | + containers: |
| 27 | + - name: bundle-image |
| 28 | + image: &image bundle-image |
| 29 | + command: ['/injected/operator-registry', 'serve'] |
| 30 | + env: |
| 31 | + - name: CONTAINER_IMAGE |
| 32 | + value: *image |
| 33 | + volumeMounts: |
| 34 | + - name: copydir |
| 35 | + mountPath: /injected |
| 36 | + initContainers: |
| 37 | + - name: copy-binary |
| 38 | + image: init-operator-manifest |
| 39 | + imagePullPolicy: Never |
| 40 | + command: ['/bin/cp', '/operator-registry', '/copy-dest'] |
| 41 | + volumeMounts: |
| 42 | + - name: copydir |
| 43 | + mountPath: /copy-dest |
| 44 | + volumes: |
| 45 | + - name: copydir |
| 46 | + emptyDir: {} |
| 47 | + restartPolicy: OnFailure |
| 48 | +``` |
| 49 | +
|
| 50 | +## Serving the bundle data |
| 51 | +
|
| 52 | +A new command will be made in operator-registry to provide functionality for traversing the directies of the bundle image for writing to a configmap (example above is "operator-registry serve"). The configmap format is described in more detail in the next section. The pre-generated configmap name is specified to be updated with the bundle data. As previously noted, after the configmap data has been read it is the responsibility of the caller to delete both the job and configmap. As a sanity check, the configmap is also updated with the image name as an annotation (olm.imageSource). |
| 53 | +
|
3 | 54 | ## Store a bundle in a `ConfigMap`
|
4 | 55 | Below is the directory layout of the operator bundle inside the image.
|
5 | 56 | ```bash
|
@@ -49,9 +100,9 @@ The `key` of a `ConfigMap` has the following format
|
49 | 100 |
|
50 | 101 | Notes:
|
51 | 102 | * The resource file name needs to be manipulated if it contains special characters.
|
52 |
| -* The consumer of the `ConfigMap` does will not use the key name in `Data` section to identify the type of resource. It should inspect the content. |
| 103 | +* The consumer of the `ConfigMap` does not use the key name in `Data` section to identify the type of resource. It should inspect the content. |
53 | 104 | * The consumer will iterate through the `Data` section and and add each resource to the bundle.
|
54 |
| -* The annotations from the `annotations.yaml` file is copied to `metadata.annotations` to the `ConfigMap` |
| 105 | +* The annotations from the `annotations.yaml` file is copied to `metadata.annotations` to the `ConfigMap`. |
55 | 106 | * The `ConfigMap` may have a resource that contains a `PackageManifest` resource. The consumer needs to handle this properly.
|
56 | 107 |
|
57 | 108 |
|
|
0 commit comments