Skip to content

Commit c1cdd8c

Browse files
Merge pull request #1440 from bshephar/imagedigestmirrorset
Support IDMS for disconnected automation
2 parents 686eb0f + 8721230 commit c1cdd8c

File tree

6 files changed

+37
-9
lines changed

6 files changed

+37
-9
lines changed

bindata/rbac/rbac.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,14 @@ rules:
241241
- get
242242
- patch
243243
- update
244+
- apiGroups:
245+
- config.openshift.io
246+
resources:
247+
- imagedigestmirrorsets
248+
verbs:
249+
- get
250+
- list
251+
- watch
244252
- apiGroups:
245253
- config.openshift.io
246254
resources:

config/rbac/role.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,14 @@ rules:
198198
- get
199199
- patch
200200
- update
201+
- apiGroups:
202+
- config.openshift.io
203+
resources:
204+
- imagedigestmirrorsets
205+
verbs:
206+
- get
207+
- list
208+
- watch
201209
- apiGroups:
202210
- config.openshift.io
203211
resources:

controllers/dataplane/openstackdataplanenodeset_controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ func (r *OpenStackDataPlaneNodeSetReconciler) GetLogger(ctx context.Context) log
125125

126126
// RBAC for ImageContentSourcePolicy and MachineConfig
127127
// +kubebuilder:rbac:groups="operator.openshift.io",resources=imagecontentsourcepolicies,verbs=get;list;watch
128+
// +kubebuilder:rbac:groups="config.openshift.io",resources=imagedigestmirrorsets,verbs=get;list;watch
128129
// +kubebuilder:rbac:groups="machineconfiguration.openshift.io",resources=machineconfigs,verbs=get;list;watch
129130

130131
// Reconcile is part of the main kubernetes reconciliation loop which aims to

docs/assemblies/proc_deploying-in-disconnected-environments.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ Deploying in disconnected environments can be achieved largely by following the
88
== Technical Implementation
99
The details provided in this section are for informational purposes only. Users should not need to interact with anything additional after completing the above mentioned OLM mirroring process.
1010

11-
The `openstack-operator` contains a list of related images that will ensure all required images for the deployment are mirrored following the above OpenShift process. Once images are mirrored, the `ImageContentSourcePolicy` custom resource (CR) is created. This process results in a `MachineConfig` called `99-master-genereted-registries` being updated in the cluster. The `99-master-generated-registries` `MachineConfig` contains a `registries.conf` file that is applied to all of the OpenShift nodes in the cluster.
11+
The `openstack-operator` contains a list of related images that will ensure all required images for the deployment are mirrored following the above OpenShift process. Once images are mirrored, either an `ImageContentSourcePolicy` custom resource (CR), or a `ImageDigestMirrorSet` CR is created. This process results in a `MachineConfig` called `99-master-genereted-registries` being updated in the cluster. The `99-master-generated-registries` `MachineConfig` contains a `registries.conf` file that is applied to all of the OpenShift nodes in the cluster.
1212

13-
In order for dataplane nodes to integrate cleanly with this process, openstack-operator checks for the existence of an `ImageContentSourcePolicy`. If one is found, it will read the `registries.conf` file from the `99-master-generated-registries` `MachineConfig`. The openstack-operator will then set two variables in the Ansible inventory for the nodes.
13+
In order for dataplane nodes to integrate cleanly with this process, openstack-operator checks for the existence of an `ImageContentSourcePolicy` or an `ImageDigestMirrorSet`. If one is found, it will read the `registries.conf` file from the `99-master-generated-registries` `MachineConfig`. The openstack-operator will then set two variables in the Ansible inventory for the nodes.
1414

1515
[,yaml]
1616
----

pkg/dataplane/util/image_registry.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ import (
77
"fmt"
88
"strings"
99

10+
ocpidms "github.com/openshift/api/config/v1"
1011
mc "github.com/openshift/api/machineconfiguration/v1"
11-
ocpimage "github.com/openshift/api/operator/v1alpha1"
12+
ocpicsp "github.com/openshift/api/operator/v1alpha1"
1213
"github.com/openstack-k8s-operators/lib-common/modules/common/helper"
1314
"sigs.k8s.io/controller-runtime/pkg/client"
1415

@@ -35,22 +36,29 @@ type machineConfigIgnition struct {
3536
} `json:"storage"`
3637
}
3738

38-
// IsDisconnectedOCP - Will retrieve a ImageContentSourcePolicyList. If the list is not
39+
// IsDisconnectedOCP - Will retrieve a CR's related to disconnected OCP deployments. If the list is not
3940
// empty, we can infer that the OCP cluster is a disconnected deployment.
4041
func IsDisconnectedOCP(ctx context.Context, helper *helper.Helper) (bool, error) {
41-
icspList := ocpimage.ImageContentSourcePolicyList{}
42+
icspList := ocpicsp.ImageContentSourcePolicyList{}
43+
idmsList := ocpidms.ImageDigestMirrorSetList{}
4244

4345
listOpts := []client.ListOption{}
44-
err := helper.GetClient().List(ctx, &icspList, listOpts...)
46+
47+
var err error
48+
err = helper.GetClient().List(ctx, &icspList, listOpts...)
49+
if err != nil {
50+
return false, err
51+
}
52+
err = helper.GetClient().List(ctx, &idmsList, listOpts...)
4553
if err != nil {
4654
return false, err
4755
}
4856

49-
if len(icspList.Items) != 0 {
50-
return true, nil
57+
if len(icspList.Items) != 0 || len(idmsList.Items) != 0 {
58+
return true, err
5159
}
5260

53-
return false, nil
61+
return false, err
5462
}
5563

5664
// GetMCRegistryConf - will unmarshal the MachineConfig ignition file the machineConfigIgnition object.

tests/functional/dataplane/suite_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ var _ = BeforeSuite(func() {
106106
Expect(err).ShouldNot(HaveOccurred())
107107
imageContentSourcePolicyCRDs, err := test.GetCRDDirFromModule("github.com/openshift/api", gomod, "operator/v1alpha1/zz_generated.crd-manifests/")
108108
Expect(err).ShouldNot(HaveOccurred())
109+
imageDigestMirrorSetCRDs, err := test.GetCRDDirFromModule("github.com/openshift/api", gomod, "config/v1/zz_generated.crd-manifests/0000_10_config-operator_01_imagedigestmirrorsets.crd.yaml")
110+
Expect(err).ShouldNot(HaveOccurred())
109111
machineConfigCRDs, err := test.GetCRDDirFromModule("github.com/openshift/api", gomod, "machineconfiguration/v1/zz_generated.crd-manifests/0000_80_machine-config_01_machineconfigs.crd.yaml")
110112
Expect(err).ShouldNot(HaveOccurred())
111113

@@ -118,6 +120,7 @@ var _ = BeforeSuite(func() {
118120
certmgrv1CRDs,
119121
openstackCRDs,
120122
imageContentSourcePolicyCRDs,
123+
imageDigestMirrorSetCRDs,
121124
machineConfigCRDs,
122125
},
123126
WebhookInstallOptions: envtest.WebhookInstallOptions{

0 commit comments

Comments
 (0)