Skip to content

Commit

Permalink
add constants and update rsync source spec
Browse files Browse the repository at this point in the history
Signed-off-by: Shovan Maity <shovan.cse91@gmail.com>
  • Loading branch information
shovanmaity committed Aug 13, 2021
1 parent e3c9fd9 commit d89b0c4
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 205 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
QUAY_USERNAME ?= kvclone
QUAY_USERNAME ?= k8s-volume-copy
LATEST_TAG ?= ci
IMAGE_TAG ?= $(shell git rev-parse --short HEAD)

Expand Down
6 changes: 2 additions & 4 deletions apis/demo.io/v1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ func init() {
// addKnownTypes adds the set of types defined in this package to the supplied scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
//&RsyncSource{},
//&RsyncSourceList{},
&RsyncPopulator{},
&RsyncPopulatorList{},
&RsyncSource{},
&RsyncSourceList{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
Expand Down
53 changes: 12 additions & 41 deletions apis/demo.io/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,23 @@ type RsyncSource struct {

// RsyncSourceSpec contains the information of rsync source
type RsyncSourceSpec struct {
// Image name for rsync source pod
// Image name for rsync source or rsync daemon.
Image string `json:"image"`
// No of replicas required in the rsync daemon.
Replicas *int32 `json:"replicas"`
// +optional
// NodeName to schedule source pod to a node
NodeName string `json:"nodeName"`
// +optional
// HostName is kubernetes.io/hostname node label value for the given node name
// HostName is kubernetes.io/hostname label value for node.
// This is used to schedule rsync source to a node.
HostName string `json:"hostName"`
// Username to access this source by a client
// Username added as valid user for rsync daemon. Rsync client that
// has password can access the source uisng username and password.
Username string `json:"username"`
// Password to access this source by a client
// Password to access rsync sourceby any client that has access to
// username and pawword.
Password string `json:"password"`
// Volume that we want to make available to the client
// Volume that we want to make available to the client. This volume
// is mounted to the source as a readonly filesystem. Clisnt can only
// read that volume using credentials.
Volume corev1.Volume `json:"volume"`
}

Expand All @@ -49,36 +53,3 @@ type RsyncSourceList struct {
// List of RsyncSources
Items []RsyncSource `json:"items" protobuf:"bytes,2,rep,name=items"`
}

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// RsyncPopulator is a volume populator that helps
// to create a volume from any rsync source.
type RsyncPopulator struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// Spec contains details of rsync daemon. Rsync client will use these
// information to connect and get the data for the volume.
Spec RsyncPopulatorSpec `json:"spec"`
}

// RsyncPopulatorSpec contains the information of rsync daemon.
type RsyncPopulatorSpec struct {
// Username is used as credential to access rsync daemon by the client.
Username string `json:"username"`
// Password is used as credential to access rsync daemon by the client.
Password string `json:"password"`
// URL is rsync daemon url it can be dns:port or ip:port.
URL string `json:"url"`
// Path is mount path of the volume which we want to sync by the clinet.
Path string `json:"path"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// RsyncPopulatorList is a list of RsyncPopulator objects
type RsyncPopulatorList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// List of RsyncPopulators
Items []RsyncPopulator `json:"items" protobuf:"bytes,2,rep,name=items"`
}
78 changes: 5 additions & 73 deletions apis/demo.io/v1/zz_generated.deepcopy.go

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

72 changes: 0 additions & 72 deletions config/crd/demo.io_rsyncpopulators.yaml

This file was deleted.

25 changes: 16 additions & 9 deletions config/crd/demo.io_rsyncsources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,29 @@ spec:
description: Spec contains list of configurations for a rsync daemon.
properties:
hostName:
description: HostName is kubernetes.io/hostname node label value for
the given node name
description: HostName is kubernetes.io/hostname label value for node.
This is used to schedule rsync source to a node.
type: string
image:
description: Image name for rsync source pod
type: string
nodeName:
description: NodeName to schedule source pod to a node
description: Image name for rsync source or rsync daemon.
type: string
password:
description: Password to access this source by a client
description: Password to access rsync sourceby any client that has
access to username and pawword.
type: string
replicas:
description: No of replicas required in the rsync daemon.
format: int32
type: integer
username:
description: Username to access this source by a client
description: Username added as valid user for rsync daemon. Rsync
client that has password can access the source uisng username and
password.
type: string
volume:
description: Volume that we want to make available to the client
description: Volume that we want to make available to the client.
This volume is mounted to the source as a readonly filesystem. Clisnt
can only read that volume using credentials.
properties:
awsElasticBlockStore:
description: 'AWSElasticBlockStore represents an AWS Disk resource
Expand Down Expand Up @@ -1452,6 +1458,7 @@ spec:
required:
- image
- password
- replicas
- username
- volume
type: object
Expand Down
8 changes: 8 additions & 0 deletions constant/component.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package constant

const (
// ComponentNameRsyncSourceController is identity of rsync source
// controller. This is used to add label to the components those
// are created by rsync source controller.
ComponentNameRsyncSourceController = "rsync-source-controller"
)
7 changes: 7 additions & 0 deletions constant/finalizer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package constant

const (
// RsyncSourceProtectionFinalizer used to maintain resource created for rsync source.
// This finalizer is used to cleanup the resource created for a rsync source cr.
RsyncSourceProtectionFinalizer = "demo.io/rsync-source-protection"
)
10 changes: 6 additions & 4 deletions constant/gvr.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
package constant

const (
// VersionV1 is used to denote API resources of version v1.
VersionV1 = "v1"
)

const (
// GroupDemoIO is used to denote API resources of group demo.io.
GroupDemoIO = "demo.io"
)

const (
RsyncPopulatorKind = "RsyncPopulator"
RsyncSourceKind = "RsyncSource"
// RsyncSourceKind is used to denote API resources of kind RsyncSource.
RsyncSourceKind = "RsyncSource"
)

const (
RsyncPopulatorResource = "rsyncpopulators"
RsyncSourceResource = "rsyncsources"
// RsyncSourceSource is used to denote source of API resource RsyncSource.
RsyncSourceResource = "rsyncsources"
)
16 changes: 16 additions & 0 deletions constant/label.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package constant

const (
// CreatedByLabel label is added to the components those are created
// by any controller in this project.
CreatedByLabel = "demo.io/created-by"
// NameLabel label is added to the components those are created
// by any controller in this project.
NameLabel = "demo.io/name"
// AppLabel label is added to the components those are created
// by any controller in this project.
AppLabel = "demo.io/app"
// K8SIOHostName used for get resources with kubernetes.io/hostname label
// or assign this to some resources.
K8SIOHostName = "kubernetes.io/hostname"
)
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/kvclone/types
module github.com/k8s-volume-copy/types

go 1.14

Expand Down

0 comments on commit d89b0c4

Please sign in to comment.