Skip to content

Commit

Permalink
Add ImageContentSource to operator/v1alpha1
Browse files Browse the repository at this point in the history
Adding a new operator/v1alpha1 definition caled ImageContentSource
which will be used when using a CR to set the registry mirror rules
for resiliency and offline installs/upgrades.
A new CRD will be created to encompass this.

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
  • Loading branch information
umohnani8 committed Jun 25, 2019
1 parent 5fe27de commit 36cf2f0
Show file tree
Hide file tree
Showing 3 changed files with 195 additions and 0 deletions.
54 changes: 54 additions & 0 deletions operator/v1alpha1/types_image_content_source_policy.go
@@ -0,0 +1,54 @@
package v1alpha1

import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

// +genclient
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// ImageContentSourcePolicy holds cluster-wide information about how to handle registry mirror rules.
// When multple policies are defined, the outcome of the behavior is defined on each field.
type ImageContentSourcePolicy struct {
metav1.TypeMeta `json:",inline"`
// Standard object's metadata.
metav1.ObjectMeta `json:"metadata,omitempty"`

// spec holds user settable values for configuration
// +required
Spec ImageContentSourcePolicySpec `json:"spec"`
}

// ImageContentSourcePolicySpec is the specification of the ImageContentSourcePolicy CRD.
type ImageContentSourcePolicySpec struct {
// repositoryDigestMirrors allows images referenced by image digests in pods to be
// pulled from alternative mirrored repository locations. The image pull specification
// provided to the pod will be compared to the source locations described in RepositoryDigestMirrors
// and the image may be pulled down from any of the repositories in the list instead of the
// specified repository allowing administrators to choose a potentially faster mirror.
// Only image pull specifications that have an image disgest will have this behavior applied
// to them - tags will continue to be pulled from the specified repository in the pull spec.
// When multiple policies are defined, any overlaps found will be merged together when the mirror
// rules are written to `/etc/containers/registries.conf`. For example, if policy A has sources `a, b, c`
// and policy B has sources `c, d, e`. Then the mirror rule written to `registries.conf` will be `a, b, c, d, e`
// where the duplicate `c` is removed.
// +optional
RepositoryDigestMirrors []RepositoryDigestMirrors `json:"repositoryDigestMirrors"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// ImageContentSourcePolicyList lists the items in the ImageContentSourcePolicy CRD.
type ImageContentSourcePolicyList struct {
metav1.TypeMeta `json:",inline"`
// Standard object's metadata.
metav1.ListMeta `json:"metadata"`
Items []ImageContentSourcePolicy `json:"items"`
}

// RepositoryDigestMirrors holds cluster-wide information about how to handle mirros in the registries config.
// Note: the mirrors only work when pulling the images that are reference by their digests.
type RepositoryDigestMirrors struct {
// sources are repositories that are mirrors of each other.
// +optional
Sources []string `json:"sources,omitempty"`
}
104 changes: 104 additions & 0 deletions operator/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions operator/v1alpha1/zz_generated.swagger_doc_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 36cf2f0

Please sign in to comment.