mirror of
https://github.com/lukaszraczylo/kubernetes-images-sync-operator.git
synced 2026-06-06 22:59:14 +00:00
Initial commit for the operator
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
Copyright 2024.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// ClusterImageSpec defines the desired state of ClusterImage
|
||||
// +kubebuilder:printcolumn:name="Image",type="string",JSONPath=".spec.image"
|
||||
// +kubebuilder:printcolumn:name="Tag",type="string",JSONPath=".spec.tag"
|
||||
// +kubebuilder:printcolumn:name="SHA",type="string",JSONPath=".spec.sha"
|
||||
// +kubebuilder:printcolumn:name="Storage",type="string",JSONPath=".spec.storage"
|
||||
// +kubebuilder:printcolumn:name="Path",type="string",JSONPath=".spec.exportPath"
|
||||
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
|
||||
type ClusterImageSpec struct {
|
||||
Image string `json:"image,omitempty"`
|
||||
Tag string `json:"tag,omitempty"`
|
||||
Sha string `json:"sha,omitempty"`
|
||||
FullName string `json:"fullName,omitempty"` // Because I'm lazy and it's easier to pull that way
|
||||
Storage string `json:"storage,omitempty"`
|
||||
ExportName string `json:"exportName"`
|
||||
ExportPath string `json:"exportPath,omitempty"`
|
||||
}
|
||||
|
||||
// ClusterImageStatus defines the observed state of ClusterImage
|
||||
type ClusterImageStatus struct {
|
||||
Progress string `json:"progress,omitempty"`
|
||||
// default value is 0
|
||||
// +kubebuilder:default:=0
|
||||
RetryCount int `json:"retryCount,omitempty"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
// +kubebuilder:subresource:status
|
||||
// ClusterImage is the Schema for the clusterimages API
|
||||
// +kubebuilder:printcolumn:name="Ref",type="string",JSONPath=".spec.exportName"
|
||||
// +kubebuilder:printcolumn:name="Image",type="string",JSONPath=".spec.image"
|
||||
// +kubebuilder:printcolumn:name="Tag",type="string",JSONPath=".spec.tag"
|
||||
// +kubebuilder:printcolumn:name="SHA",type="string",JSONPath=".spec.sha"
|
||||
// +kubebuilder:printcolumn:name="Storage",type="string",JSONPath=".spec.storage"
|
||||
// +kubebuilder:printcolumn:name="Path",type="string",JSONPath=".spec.exportPath"
|
||||
// +kubebuilder:printcolumn:name="Progress",type="string",JSONPath=".status.progress"
|
||||
// +kubebuilder:printcolumn:name="Retries",type="integer",JSONPath=".status.retryCount"
|
||||
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
|
||||
type ClusterImage struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec ClusterImageSpec `json:"spec,omitempty"`
|
||||
Status ClusterImageStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
|
||||
// ClusterImageList contains a list of ClusterImage
|
||||
type ClusterImageList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []ClusterImage `json:"items"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
SchemeBuilder.Register(&ClusterImage{}, &ClusterImageList{})
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
Copyright 2024.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
type ClusterImageStorageS3 struct {
|
||||
// Bucket name
|
||||
Bucket string `json:"bucket"`
|
||||
Region string `json:"region"`
|
||||
// S3 bucket credentials
|
||||
AccessKey string `json:"accessKey,omitempty"`
|
||||
SecretKey string `json:"secretKey,omitempty"`
|
||||
UseRole bool `json:"useRole,omitempty"`
|
||||
// RoleARN is the ARN of the role to be used for the deployment
|
||||
RoleARN string `json:"roleARN,omitempty"`
|
||||
// Defines the endpoint for the S3 storage
|
||||
// If none specified - default AWS endpoint will be used
|
||||
Endpoint string `json:"endpoint,omitempty"`
|
||||
// Defines the secret name for credentials
|
||||
SecretName string `json:"secretName,omitempty"`
|
||||
}
|
||||
|
||||
// ClusterImageStorageSpec defines the desired state of ClusterImageStorage
|
||||
type ClusterImageStorageSpec struct {
|
||||
// +kubebuilder:validation:Enum=file;S3
|
||||
StorageTarget string `json:"target"`
|
||||
S3 ClusterImageStorageS3 `json:"s3,omitempty"`
|
||||
}
|
||||
|
||||
// ClusterImageExportSpec defines the desired state of ClusterImageExport
|
||||
// +kubebuilder:printcolumn:name="BasePath",type="string",JSONPath=".spec.basePath"
|
||||
// +kubebuilder:printcolumn:name="Storage",type="string",JSONPath=".spec.storage.target"
|
||||
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
|
||||
type ClusterImageExportSpec struct {
|
||||
Name string `json:"name"`
|
||||
CreatedAt metav1.Time `json:"createdAt,omitempty"`
|
||||
// Exclude images which contain these strings
|
||||
Excludes []string `json:"excludes,omitempty"`
|
||||
// Include only images which contain these strings
|
||||
Includes []string `json:"includes,omitempty"`
|
||||
// Base path for the export - both file and S3
|
||||
// +kubebuilder:validation:MinLength=1
|
||||
// +kubebuilder:validation:MaxLength=255
|
||||
BasePath string `json:"basePath"`
|
||||
Storage ClusterImageStorageSpec `json:"storage"`
|
||||
// +kubebuilder:validation.Minimum=1
|
||||
// +kubebuilder:validation.Maximum=100
|
||||
MaxConcurrentJobs int `json:"maxConcurrentJobs"`
|
||||
}
|
||||
|
||||
// ClusterImageExportStatus defines the observed state of ClusterImageExport
|
||||
type ClusterImageExportStatus struct {
|
||||
Progress string `json:"progress,omitempty"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
// +kubebuilder:subresource:status
|
||||
|
||||
// ClusterImageExport is the Schema for the clusterimageexports API
|
||||
// +kubebuilder:printcolumn:name="BasePath",type="string",JSONPath=".spec.basePath"
|
||||
// +kubebuilder:printcolumn:name="Storage",type="string",JSONPath=".spec.storage.target"
|
||||
// +kubebuilder:printcolumn:name="Progress",type="string",JSONPath=".status.progress"
|
||||
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
|
||||
type ClusterImageExport struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
Spec ClusterImageExportSpec `json:"spec,omitempty"`
|
||||
Status ClusterImageExportStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// +kubebuilder:object:root=true
|
||||
|
||||
// ClusterImageExportList contains a list of ClusterImageExport
|
||||
type ClusterImageExportList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata,omitempty"`
|
||||
Items []ClusterImageExport `json:"items"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
SchemeBuilder.Register(&ClusterImageExport{}, &ClusterImageExportList{})
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
Copyright 2024.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Package v1 contains API Schema definitions for the raczylo.com v1 API group
|
||||
// +kubebuilder:object:generate=true
|
||||
// +groupName=raczylo.com
|
||||
package v1
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"sigs.k8s.io/controller-runtime/pkg/scheme"
|
||||
)
|
||||
|
||||
var (
|
||||
// GroupVersion is group version used to register these objects
|
||||
GroupVersion = schema.GroupVersion{Group: "raczylo.com", Version: "v1"}
|
||||
|
||||
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
|
||||
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
|
||||
|
||||
// AddToScheme adds the types in this group-version to the given scheme.
|
||||
AddToScheme = SchemeBuilder.AddToScheme
|
||||
)
|
||||
@@ -0,0 +1,246 @@
|
||||
//go:build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright 2024.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by controller-gen. DO NOT EDIT.
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ClusterImage) DeepCopyInto(out *ClusterImage) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
out.Spec = in.Spec
|
||||
out.Status = in.Status
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterImage.
|
||||
func (in *ClusterImage) DeepCopy() *ClusterImage {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ClusterImage)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *ClusterImage) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ClusterImageExport) DeepCopyInto(out *ClusterImageExport) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
out.Status = in.Status
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterImageExport.
|
||||
func (in *ClusterImageExport) DeepCopy() *ClusterImageExport {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ClusterImageExport)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *ClusterImageExport) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ClusterImageExportList) DeepCopyInto(out *ClusterImageExportList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]ClusterImageExport, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterImageExportList.
|
||||
func (in *ClusterImageExportList) DeepCopy() *ClusterImageExportList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ClusterImageExportList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *ClusterImageExportList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ClusterImageExportSpec) DeepCopyInto(out *ClusterImageExportSpec) {
|
||||
*out = *in
|
||||
in.CreatedAt.DeepCopyInto(&out.CreatedAt)
|
||||
if in.Excludes != nil {
|
||||
in, out := &in.Excludes, &out.Excludes
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
if in.Includes != nil {
|
||||
in, out := &in.Includes, &out.Includes
|
||||
*out = make([]string, len(*in))
|
||||
copy(*out, *in)
|
||||
}
|
||||
out.Storage = in.Storage
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterImageExportSpec.
|
||||
func (in *ClusterImageExportSpec) DeepCopy() *ClusterImageExportSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ClusterImageExportSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ClusterImageExportStatus) DeepCopyInto(out *ClusterImageExportStatus) {
|
||||
*out = *in
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterImageExportStatus.
|
||||
func (in *ClusterImageExportStatus) DeepCopy() *ClusterImageExportStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ClusterImageExportStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ClusterImageList) DeepCopyInto(out *ClusterImageList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ListMeta.DeepCopyInto(&out.ListMeta)
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]ClusterImage, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterImageList.
|
||||
func (in *ClusterImageList) DeepCopy() *ClusterImageList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ClusterImageList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *ClusterImageList) DeepCopyObject() runtime.Object {
|
||||
if c := in.DeepCopy(); c != nil {
|
||||
return c
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ClusterImageSpec) DeepCopyInto(out *ClusterImageSpec) {
|
||||
*out = *in
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterImageSpec.
|
||||
func (in *ClusterImageSpec) DeepCopy() *ClusterImageSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ClusterImageSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ClusterImageStatus) DeepCopyInto(out *ClusterImageStatus) {
|
||||
*out = *in
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterImageStatus.
|
||||
func (in *ClusterImageStatus) DeepCopy() *ClusterImageStatus {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ClusterImageStatus)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ClusterImageStorageS3) DeepCopyInto(out *ClusterImageStorageS3) {
|
||||
*out = *in
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterImageStorageS3.
|
||||
func (in *ClusterImageStorageS3) DeepCopy() *ClusterImageStorageS3 {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ClusterImageStorageS3)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ClusterImageStorageSpec) DeepCopyInto(out *ClusterImageStorageSpec) {
|
||||
*out = *in
|
||||
out.S3 = in.S3
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterImageStorageSpec.
|
||||
func (in *ClusterImageStorageSpec) DeepCopy() *ClusterImageStorageSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ClusterImageStorageSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
Reference in New Issue
Block a user