|
| 1 | +# Related Images |
| 2 | + |
| 3 | +Status: Pending |
| 4 | + |
| 5 | +Version: Alpha |
| 6 | + |
| 7 | +Implementation Owner: ecordell |
| 8 | + |
| 9 | +## Motivation |
| 10 | + |
| 11 | +Operators often need to make use of other container images to perform their functions as operators. |
| 12 | + |
| 13 | +## Proposal |
| 14 | + |
| 15 | +Introduce a new field `relatedImages` to the `ClusterServiceVersion` spec. |
| 16 | + |
| 17 | +### ClusterServiceVersion Spec Changes |
| 18 | + |
| 19 | +A new section `relatedImages` is added to the ClusterServiceVersionSpec. |
| 20 | + |
| 21 | +```yaml |
| 22 | +kind: ClusterServiceVersion |
| 23 | +metadata: |
| 24 | + name: etcd-operator |
| 25 | +spec: |
| 26 | + relatedImages: |
| 27 | + - name: default |
| 28 | + image: quay.io/coreos/etcd@sha256:12345 |
| 29 | + annotation: default |
| 30 | + - name: etcd-2.1.5 |
| 31 | + image: quay.io/coreos/etcd@sha256:12345 |
| 32 | + - name: etcd-3.1.1 |
| 33 | + image: quay.io/coreos/etcd@sha256:12345 |
| 34 | +``` |
| 35 | +
|
| 36 | +These will be made available as annotations on the operator deployments, so that they can be used via downward API if desired. This may be particularly useful for operators that are tightly coupled to another particular image. |
| 37 | +
|
| 38 | +```yaml |
| 39 | +kind: Deployment |
| 40 | +metadata: |
| 41 | + name: etcd-operator |
| 42 | + annotations: |
| 43 | + default: quay.io/coreos/etcd@sha256:12345 |
| 44 | + olm.relatedImage.etcd-2.1.5: quay.io/coreos/etcd@sha256:12345 |
| 45 | + olm.relatedImage.etcd-3.1.1: quay.io/coreos/etcd@sha256:12345 |
| 46 | +spec: |
| 47 | + replicas: 1 |
| 48 | + selector: |
| 49 | + matchLabels: |
| 50 | + name: etcd-operator |
| 51 | + template: |
| 52 | + metadata: |
| 53 | + name: etcd-operator |
| 54 | + labels: |
| 55 | + name: etcd-operator |
| 56 | + spec: |
| 57 | + serviceAccountName: etcd-operator |
| 58 | + containers: |
| 59 | + - name: etcd-operator |
| 60 | + command: |
| 61 | + - etcd-operator |
| 62 | + - --create-crd=false |
| 63 | + - --defaultImage=${DEFAULT} |
| 64 | + image: quay.io/coreos/etcd-operator@sha256:c0301e4686c3ed4206e370b42de5a3bd2229b9fb4906cf85f3f30650424abec2 |
| 65 | + env: |
| 66 | + - name: NAMESPACE |
| 67 | + valueFrom: |
| 68 | + fieldRef: |
| 69 | + fieldPath: metadata.namespace |
| 70 | + - name: DEFAULT |
| 71 | + valueFrom: |
| 72 | + fieldRef: |
| 73 | + fieldPath: metadata.annotations['default'] |
| 74 | +``` |
| 75 | +
|
| 76 | +### Implementation |
| 77 | +
|
| 78 | +#### ClusterServiceVersion Spec and Status |
| 79 | +
|
| 80 | +Spec needs to be updated to include the fields described above, and the openapi validation should be updated as well. |
| 81 | +
|
| 82 | +Note that the `name` field for related images must satisfy the annotation name conventions. |
| 83 | + |
| 84 | +#### Install Strategy |
| 85 | + |
| 86 | +Most of the change will take place in the install strategy; which knows how to take the deployment spec defined in a CSV and check if the cluster is up-to-date, and apply changes if needed. |
| 87 | + |
| 88 | +- The install strategy will now need to know about related images. |
| 89 | + - `CheckInstalled` will check that the annotations on the operator deployments include the `relatedImages` annotations. |
| 90 | + - `Install` will also need to project the relatedImages as annotations on the deployment. |
| 91 | + |
| 92 | +#### Implementation Stages |
| 93 | + |
| 94 | +- [ ] API Changes |
| 95 | +- [ ] Annotation Projection on Deployments |
| 96 | + |
| 97 | +### User Documentation |
| 98 | + |
| 99 | +#### Associating Related Images |
| 100 | + |
| 101 | +Operators often need to make use of other container images to perform their functions. For example, the etcd operator |
| 102 | +makes use of etcd container images to create etcd clusters as requested by the user. |
| 103 | + |
| 104 | +To indicate that such images are used by the operator, a ClusterServiceVersion author can fill out the `relatedImages` |
| 105 | +field on the CSV spec. |
| 106 | + |
| 107 | +These fields are optional, but should be filled out whenever possible. Tooling can take advantage of this information |
| 108 | +to ensure that all required images are available in the cluster. |
| 109 | + |
| 110 | +```yaml |
| 111 | +kind: ClusterServiceVersion |
| 112 | +metadata: |
| 113 | + name: etcd-operator |
| 114 | +spec: |
| 115 | + relatedImages: |
| 116 | + - name: default |
| 117 | + image: quay.io/coreos/etcd@sha256:12345 |
| 118 | + annotation: default |
| 119 | + - name: etcd-2.1.5 |
| 120 | + image: quay.io/coreos/etcd@sha256:12345 |
| 121 | + - name: etcd-3.1.1 |
| 122 | + image: quay.io/coreos/etcd@sha256:12345 |
| 123 | +``` |
| 124 | + |
| 125 | + |
| 126 | +#### Using related images via downwardAPI |
| 127 | + |
| 128 | +The related images can be consumed by the operator deployment. This may be useful if, for example, the operator |
| 129 | +and operand images are tightly coupled. The `annotation` field from the `relatedImages` is used as the name of the annotation. |
| 130 | + |
| 131 | +These will be made available as annotations on the operator deployments, so that they can be used via downward API if desired. This may be particularly useful for operators that are tightly coupled to another particular image. |
| 132 | + |
| 133 | +```yaml |
| 134 | +kind: Deployment |
| 135 | +metadata: |
| 136 | + name: etcd-operator |
| 137 | + annotations: |
| 138 | + default: quay.io/coreos/etcd@sha256:12345 |
| 139 | + olm.relatedImage.etcd-2.1.5: quay.io/coreos/etcd@sha256:12345 |
| 140 | + olm.relatedImage.etcd-3.1.1: quay.io/coreos/etcd@sha256:12345 |
| 141 | +spec: |
| 142 | + replicas: 1 |
| 143 | + selector: |
| 144 | + matchLabels: |
| 145 | + name: etcd-operator |
| 146 | + template: |
| 147 | + metadata: |
| 148 | + name: etcd-operator |
| 149 | + labels: |
| 150 | + name: etcd-operator |
| 151 | + spec: |
| 152 | + serviceAccountName: etcd-operator |
| 153 | + containers: |
| 154 | + - name: etcd-operator |
| 155 | + command: |
| 156 | + - etcd-operator |
| 157 | + - --create-crd=false |
| 158 | + - --defaultImage=${DEFAULT} |
| 159 | + image: quay.io/coreos/etcd-operator@sha256:c0301e4686c3ed4206e370b42de5a3bd2229b9fb4906cf85f3f30650424abec2 |
| 160 | + env: |
| 161 | + - name: NAMESPACE |
| 162 | + valueFrom: |
| 163 | + fieldRef: |
| 164 | + fieldPath: metadata.namespace |
| 165 | + - name: DEFAULT |
| 166 | + valueFrom: |
| 167 | + fieldRef: |
| 168 | + fieldPath: metadata.annotations['default'] |
| 169 | +``` |
| 170 | + |
| 171 | +### Future Work |
| 172 | + |
| 173 | +#### Required Images |
| 174 | + |
| 175 | +Any of the related images may be marked required. This would prevent the operator from installing if the required image is unavailable. |
| 176 | + |
| 177 | + |
| 178 | +```yaml |
| 179 | +kind: ClusterServiceVersion |
| 180 | +metadata: |
| 181 | + name: etcd-operator |
| 182 | +spec: |
| 183 | + relatedImages: |
| 184 | + - name: default |
| 185 | + image: quay.io/coreos/etcd@sha256:12345 |
| 186 | + annotation: default |
| 187 | + required: true |
| 188 | + - name: etcd-2.1.5 |
| 189 | + image: quay.io/coreos/etcd@sha256:12345 |
| 190 | + - name: etcd-3.1.1 |
| 191 | + image: quay.io/coreos/etcd@sha256:12345 |
| 192 | +``` |
0 commit comments