support for EdgeFS ISGW link CRD
Signed-off-by: Dmitry Yusupov <dmitry.yusupov@nexenta.com>
This commit is contained in:
1 parent
8035f1c372
commit
f4bfee8165
27 files changed
+1548
-20
No files matched your search
@@ -57,6 +57,8 @@ Settings can be specified at the global level to apply to the cluster as a whole
|
||||
- **WARNING**: For test scenarios, if you delete a cluster and start a new cluster on the same hosts, the path used by `dataDirHostPath` must be deleted. Otherwise, stale information and other config will remain from the previous cluster and the new target will fail to start.
|
||||
If this value is empty, each pod will get an ephemeral directory to store their config files that is tied to the lifetime of the pod running on that node. More details can be found in the Kubernetes [empty dir docs](https://kubernetes.io/docs/concepts/storage/volumes/#emptydir).
|
||||
- `dataVolumeSize`: Alternative to `dataDirHostPath`. If defined then Cluster CRD operator will disregard `dataDirHostPath` setting and instead will automatically claim persistent volume. If `storage` settings not provided then provisioned volume will also be used as a storage device for Target pods (automatic provisioning via `rtlfs`).
|
||||
- `dashboard`: This specification may be used to override and enable additional [EdgeFS UI Dashboard](edgefs-ui.md) functionality.
|
||||
- `localAddr`: Specifies local IP address to be used as Kubernetes external IP.
|
||||
- `network`: If defined then host network will be enabled for the cluster and services. This is optional and if not defined then `eth0` will be used to construct cluster bucket network.
|
||||
- `serverIfName`: Specifies data daemon networking interface name. If not defined then `eth0` is assumed.
|
||||
- `brokerIfName`: Specifies broker daemon networking interface name. If not defined then `eth0` is assumed.
|
||||
|
||||
@@ -0,0 +1,210 @@
|
||||
---
|
||||
title: EdgeFS ISGW Link CRD
|
||||
weight: 4200
|
||||
indent: true
|
||||
---
|
||||
|
||||
# EdgeFS ISGW (Inter-Segment GateWay) CRD
|
||||
|
||||
EdgeFS Inter-Segment Gateway link is a building block for EdgeFS cross-site, cross-cloud global namespace synchronization functionality.
|
||||
|
||||
It distributes modified chunks of data asynchronously and enables seamless as well as geographically transparent access to files, objects and block devices.
|
||||
It is important to note that a file or a block device consists of one or more objects, and so, within EdgeFS scope, ultimately everything is an object, globally immutable and self-validated.
|
||||
|
||||
To create an analogy, EdgeFS concept of global immutability of modifications very similar to how git operates with repository commits and branches.
|
||||
As such, this technique empowers EdgeFS users to construct and operate comprehensive wide-spread global namespaces with management overhead greatly simplified.
|
||||
A file or object modified at a source site where ISGW link is setup will be immediately noticed by ISGW endpoint links, thus spread out the change.
|
||||
Eventually, all the connected sites will receive file modification where only modified blocks get transferred.
|
||||
|
||||

|
||||
|
||||
Not only ISGW link reduces the amount of data needed to be transferred, it also deduplicating the transfers.
|
||||
Matching globally unique cryptographic signatures of a file change will not be transferred, thus enabling global namespace deduplication.
|
||||
|
||||
ISGW link can be bi-directional, i.e. enabling same file/object modifications across the namespaces.
|
||||
It works well for many use cases where application logic can ensure serialization of changes.
|
||||
Single bi-directional link can connect two sites but it is possible to create as many non-overlapping links as needed.
|
||||
|
||||
ISGW link can also transparently synchronize file, object, directory, bucket or tenant level snapshots, grouped into so-called SnapView construct.
|
||||
Thus, modification to a block device, for instance, can be consistently viewed across entire global namespace.
|
||||
|
||||
Because EdgeFS metadata is also globally immutable and unique, it is possible to enable a mode of transferring only metadata changes.
|
||||
With this mode enabled, users can construct efficient access endpoints where modifications can be fetched on demand, as a result creating globally and geographically distributed cache fog aggregation with a built-in E-LRU eviction policy.
|
||||
|
||||
Local I/O at each site executed with the speed of media devices used. Modifications transferred eventually, and not slowing down local site running application workflow.
|
||||
|
||||
EdgeFS Rook Operator allows creation and customization of High-Performance Inter-Segment synchronization links through the custom resource definitions (CRDs).
|
||||
|
||||
The following settings are available for customization of ISGW services.
|
||||
|
||||
## Sample
|
||||
|
||||
```yaml
|
||||
apiVersion: edgefs.rook.io/v1alpha1
|
||||
kind: ISGW
|
||||
metadata:
|
||||
name: isgw01 # Inter-Segment Gateway service name
|
||||
namespace: rook-edgefs
|
||||
spec:
|
||||
direction: "send+recieve"
|
||||
remoteURL: "ccow://192.168.1.43:14000"
|
||||
#replicationType: "initial"
|
||||
#metadataOnly: true
|
||||
#dynamicFetchPort: 49600
|
||||
#localPort: 10000
|
||||
#useEncryptedTunnel: true
|
||||
#placement:
|
||||
# nodeAffinity:
|
||||
# requiredDuringSchedulingIgnoredDuringExecution:
|
||||
# nodeSelectorTerms:
|
||||
# - matchExpressions:
|
||||
# - key: rook-edgefs-nodetype
|
||||
# operator: In
|
||||
# values:
|
||||
# - isgw
|
||||
# tolerations:
|
||||
# - key: node230
|
||||
# operator: Exists
|
||||
# podAffinity:
|
||||
# podAntiAffinity:
|
||||
#resources:
|
||||
# limits:
|
||||
# cpu: "2"
|
||||
# memory: "4Gi"
|
||||
# requests:
|
||||
# cpu: "2"
|
||||
# memory: "4Gi"
|
||||
```
|
||||
|
||||
### Metadata
|
||||
|
||||
- `name`: The name of the ISGW link service to create, which must match existing EdgeFS service. Provided CRD metadata can override existing EdgeFS service metadata.
|
||||
- `namespace`: The namespace of the Rook cluster where the ISGW service is created.
|
||||
- `direction`: I/O flow direction: `send`, `recieve` or `send+receive` (default).
|
||||
- `remoteURL`: I/O flow with destination pointing to the other ISGW endpoint service, locally mounted directory or other (non-EdgeFS) S3 compatible service. Format should be of form PROTOCOL://LOCATION, where PROTOCOL can be of "ccow", "file", "s3" and LOCATION depends on the PROTOCOL. In case of "ccow" LOCATION needs to specify a HOST:PORT of the other EdgeFS site, e.g. ccow://192.168.1.43:14000. In case of "file" LOCATION needs to be a path to a local POSIX directory, e.g. file://volumeDir. In cae of "s3" LOCATION can either point to an existing bucket, e.g. s3://mybucket.aws.com or to the other S3 compatible server IP:HOST, e.g. s3://214.4.34.22:4567. It is important to note that file:// and s3:// protocols only provided for easy integration with existing infrastructure.
|
||||
- `replicationType`: Defines how tenant's buckets needs to be replicated. Can be sepcified as `initial`, `continuous` or `initial+continuous` (default). In case of `initial` replication type, ISGW service will only sync served buckets once with ability to manually trigger re-sync again. In case of `continuous` replication type, ISGW service will enable asynchronous syncing from the moment a bucket added to a served list of buckets, so that only recent changes will be synchronized, continuosly. In case of `initial+continuous` replication type, ISGW service will first initate syncing of all existing served buckets contents and once all is copied, it will automatically enable `continuous` mode of operation, guaranteeing that none of the source objects are skipped.
|
||||
- `metadataOnly`: If true, then only immutable metadata changes will be transfered. This also enables on-demand data fetch and E-LRU cache capability. In case of metadata only transfers, dynamically fetched data will be cached at the accessing endpoints ISGW links locations. If an application would want to read an offset of a data which isn't found, global search request will be formed and distributed across all the connected ISGW bi-directional links serving source bucket. Missing data chunks will be found and fetched, delivered transparently to application.
|
||||
- `dynamicFetchPort`: Defines local cluster pod service port. Used by EdgeFS gateways (S3, S3X, NFS or iSCSI) to distribute missing chunk fetch requests. Default is 49678.
|
||||
- `localAddr`: Defines local cluster pod service address and port. Used by ISGW link endpoint. Kubernetes ExternalIP will be automatically constructed if address is provided. Default is 0.0.0.0:14000.
|
||||
- `useEncryptedTunnel`: If true, enables usage of encrypted SSH tunnel. By default, transfered metadata and data chunks are just compressed but unencrypted. Enable encryption if ISGW links crossing boundaries of single data center or multiple clouds.
|
||||
- `placement`: The ISGW pods can be given standard Kubernetes placement restrictions with `nodeAffinity`, `tolerations`, `podAffinity`, and `podAntiAffinity` similar to placement defined for daemons configured by the [cluster CRD](/cluster/examples/kubernetes/edgefs/cluster.yaml).
|
||||
- `resources`: Set resource requests/limits for the ISGW pods, see [Resource Requirements/Limits](edgefs-cluster-crd.md#resource-requirementslimits).
|
||||
|
||||
### Setting up two-sites bi-directional syncing EdgeFS namespace and tenants
|
||||
|
||||
This example will demonstrate creation of simple syncing namespace between two sites.
|
||||
|
||||
For more detailed instructions please refer to [EdgeFS Wiki](https://github.com/Nexenta/edgefs/wiki).
|
||||
|
||||
Simple procedure to get things initialized and configured:
|
||||
|
||||
## Setting up FlexHash and Site root object
|
||||
|
||||
Before new local namespace (or local site) can be used, it has to be initialized with FlexHash and special purpose root object.
|
||||
|
||||
FlexHash consists of dynamically discovered configuration and checkpoint of accepted distribution table. FlexHash is responsible for I/O direction and plays important role in dynamic load balancing logic. It defines so-called Negotiating Groups (typically across zoned 8-24 disks) and final table distribution across all the participating components, e.g. data nodes, service gateways and tools.
|
||||
|
||||
Root object holds system information and table of namespaces registered to a local site. Root object is always local and never shared between the sites.
|
||||
|
||||
For each cluster, to initialize system and prepare logical definitions, login to the toolbox as shown in this example:
|
||||
|
||||
<pre>
|
||||
kubectl get po --all-namespaces | grep edgefs-mgr
|
||||
kubectl exec -it -n rook-edgefs rook-edgefs-mgr-6cb9598469-czr7p -- env COLUMNS=$COLUMNS LINES=$LINES TERM=linux toolbox
|
||||
</pre>
|
||||
|
||||
Assumption at this point is that nodes are all configured and can be seen via the following command:
|
||||
|
||||
<pre>
|
||||
efscli system status
|
||||
</pre>
|
||||
|
||||
1. Initialize cluster
|
||||
|
||||
Verify that HW (or better say emulated in this case) configuration look normal and accept it
|
||||
|
||||
<pre>
|
||||
efscli system init
|
||||
</pre>
|
||||
|
||||
At this point new dynamically discovered configuration checkpoint will be created at $NEDGE_HOME/var/run/flexhash-checkpoint.json
|
||||
This will also create system "root" object, holding Site's Namespace. Namespace may consist of more then single region.
|
||||
|
||||
2. Create new local namespace (or we also call it "Region" or "Segment")
|
||||
|
||||
<pre>
|
||||
efscli cluster create Hawaii
|
||||
</pre>
|
||||
|
||||
3. Create logical tenants of cluster namespace "Hawaii", also buckets if needed
|
||||
|
||||
<pre>
|
||||
efscli tenant create Hawaii/Cola
|
||||
efscli bucket create Hawaii/Cola/bk1
|
||||
efscli tenant create Hawaii/Pepsi
|
||||
efscli bucket create Hawaii/Pepsi/bk1
|
||||
</pre>
|
||||
|
||||
Now that Hawaii serving namespace cluster is setup, repeat steps on the secondary site:
|
||||
|
||||
<pre>
|
||||
efscli cluster create Hawaii
|
||||
efscli tenant create Hawaii/Cola -r 2
|
||||
efscli tenant create Hawaii/Pepsi -r 2
|
||||
</pre>
|
||||
|
||||
This steps also includes a possibility to override destination defaults on per-tenant (Cola and Pepsi) basis.
|
||||
In the example above we setting replication count to 2 on the secondary site.
|
||||
|
||||
4. Create ISGW link services on both EdgeFS sites
|
||||
|
||||
Order of creation of ISGW links doesn't matter.
|
||||
Link status change will be noticed automatically and syncing can be delayed for up to 7 days by default.
|
||||
|
||||
On the primary site:
|
||||
|
||||
<pre>
|
||||
efscli service create isgw hawaii
|
||||
efscli service serve hawaii Hawaii/Cola/bk1
|
||||
efscli service serve hawaii Hawaii/Pepsi/bk1
|
||||
</pre>
|
||||
|
||||
Because we creating bi-directional link, on the secondary site we would need to create exactly same configuration except X-ISGW-Remote (remoteURL in CRD) where it should point back to primary. Synchronization is enabled on per-bucket level. Buckets which do not yet exist will be automatically created with tenant parameter overrides taken into an account.
|
||||
|
||||
5. Create ISGW Link CRDs on both EdgeFS sites
|
||||
|
||||
```yaml
|
||||
apiVersion: edgefs.rook.io/v1alpha1
|
||||
kind: ISGW
|
||||
metadata:
|
||||
name: hawaii
|
||||
namespace: rook-edgefs
|
||||
spec:
|
||||
direction: send+receive
|
||||
remoteURL: ccow://10.3.32.240:14000
|
||||
localAddr: 10.3.30.75:14000
|
||||
```
|
||||
|
||||
```yaml
|
||||
apiVersion: edgefs.rook.io/v1alpha1
|
||||
kind: ISGW
|
||||
metadata:
|
||||
name: hawaii
|
||||
namespace: rook-edgefs
|
||||
spec:
|
||||
direction: send+receive
|
||||
remoteURL: ccow://10.3.30.75:14000
|
||||
localAddr: 10.3.32.240:14000
|
||||
```
|
||||
|
||||
It also maybe a bit easier to create services and CRDs using [EdgeFS UI Dashboard](edgefs-ui.md). ISGW Link page may look like this:
|
||||
|
||||

|
||||
|
||||
EdgeFS UI Dashboard automates the process of CRD composing but also has a capability to execute and monitor running Kubernetes Rook CRDs.
|
||||
|
||||
At this point two ISGW link services should be operational. Verify its operation with `show` command:
|
||||
|
||||
<pre>
|
||||
efscli service show hawaii -s
|
||||
</pre>
|
||||
@@ -31,7 +31,7 @@ REST API endpoint is used by Console and Graphical UIs. It exposing ClusterIPs w
|
||||
The `rook-edgefs-ui` service is used to expose browser based User Interface ports.
|
||||
Using NodePort you will be able to connect to the dashboard by direct node IP and provided port number, in this example at `http://NODEIP:32048`.
|
||||
|
||||
The `rook-edgefs-mgr` service is for gRPC communication between the [EdgeFS CSI Provisioner](edgefs-si.md), REST API and services. It exposes cluster internal port 6789.
|
||||
The `rook-edgefs-mgr` service is for gRPC communication between the [EdgeFS CSI Provisioner](edgefs-csi.md), REST API and services. It exposes cluster internal port 6789.
|
||||
|
||||
## Dynamic EdgeFS Service CRD editing
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 84 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 225 KiB |
@@ -116,6 +116,8 @@ spec:
|
||||
dataDirHostPath: /var/lib/edgefs
|
||||
#dataVolumeSize: 10Gi
|
||||
#devicesResurrectMode: "restoreZapWait"
|
||||
#dashboard:
|
||||
# localAddr: 10.3.30.75
|
||||
#network: # cluster level networking configuration aka "host network"
|
||||
# serverIfName: "enp2s0f0"
|
||||
# brokerIfName: "enp2s0f0"
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
apiVersion: edgefs.rook.io/v1alpha1
|
||||
kind: ISGW
|
||||
metadata:
|
||||
name: isgw01 # Inter-Segment Gateway service name
|
||||
namespace: rook-edgefs
|
||||
spec:
|
||||
direction: "send+recieve" # I/O flow direction: send, recieve or send-receive
|
||||
remoteURL: "ccow://192.168.1.43:14000" # I/O flow with destination antoher EdgeFS cluster, pointing to ISGW endpoint service
|
||||
#remoteURL: "file://volumeDir" # I/O flow with destination as locally mounted POSIX directory
|
||||
#remoteURL: "s3://mybucket.aws.com" # I/O flow with destination as remote S3 bucket
|
||||
#remoteURL: "s3://214.4.34.22:4567" # I/O flow with destination as remote S3 compatible server
|
||||
#replicationType: "initial" # Replication: initial, continuous, initial+continuous (default)
|
||||
#metadataOnly: true # Replicate only metadata, thus enable on-demand fetch at destination (ccow protocol only)
|
||||
#useEncryptedTunnel: true # Enables usage of encrypted SSH tunnel (ccow protocol only)
|
||||
#dynamicFetchPort: 49600 # Override dynamic fetch service port (default 49678)
|
||||
#localAddr: 0.0.0.0:10000 # Override endpoint listening port (default 0.0.0.0:14000)
|
||||
#placement:
|
||||
# nodeAffinity:
|
||||
# requiredDuringSchedulingIgnoredDuringExecution:
|
||||
# nodeSelectorTerms:
|
||||
# - matchExpressions:
|
||||
# - key: rook-edgefs-nodetype
|
||||
# operator: In
|
||||
# values:
|
||||
# - isgw
|
||||
# tolerations:
|
||||
# - key: node230
|
||||
# operator: Exists
|
||||
# podAffinity:
|
||||
# podAntiAffinity:
|
||||
#resources:
|
||||
# limits:
|
||||
# cpu: "2"
|
||||
# memory: "4Gi"
|
||||
# requests:
|
||||
# cpu: "2"
|
||||
# memory: "4Gi"
|
||||
@@ -73,6 +73,20 @@ spec:
|
||||
scope: Namespaced
|
||||
version: v1alpha1
|
||||
---
|
||||
apiVersion: apiextensions.k8s.io/v1beta1
|
||||
kind: CustomResourceDefinition
|
||||
metadata:
|
||||
name: isgws.edgefs.rook.io
|
||||
spec:
|
||||
group: edgefs.rook.io
|
||||
names:
|
||||
kind: ISGW
|
||||
listKind: ISGWList
|
||||
plural: isgws
|
||||
singular: isgw
|
||||
scope: Namespaced
|
||||
version: v1alpha1
|
||||
---
|
||||
# The cluster role for managing all the cluster-specific resources in a namespace
|
||||
apiVersion: rbac.authorization.k8s.io/v1beta1
|
||||
kind: ClusterRole
|
||||
|
||||
@@ -63,6 +63,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
|
||||
&S3XList{},
|
||||
&ISCSI{},
|
||||
&ISCSIList{},
|
||||
&ISGW{},
|
||||
&ISGWList{},
|
||||
)
|
||||
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
|
||||
return nil
|
||||
|
||||
@@ -57,6 +57,7 @@ type ClusterSpec struct {
|
||||
// The placement-related configuration to pass to kubernetes (affinity, node selector, tolerations).
|
||||
Placement rook.PlacementSpec `json:"placement,omitempty"`
|
||||
Network NetworkSpec `json:"network,omitempty"`
|
||||
Dashboard DashboardSpec `json:"dashboard,omitempty"`
|
||||
// Resources set resource requests and limits
|
||||
Resources v1.ResourceRequirements `json:"resources,omitempty"`
|
||||
// The path on the host where config and data can be persisted.
|
||||
@@ -68,6 +69,10 @@ type ClusterSpec struct {
|
||||
SkipHostPrepare bool `json:"skipHostPrepare,omitempty"`
|
||||
}
|
||||
|
||||
type DashboardSpec struct {
|
||||
LocalAddr string `json:"localAddr"`
|
||||
}
|
||||
|
||||
type NetworkSpec struct {
|
||||
ServerIfName string `json:"serverIfName"`
|
||||
BrokerIfName string `json:"brokerIfName"`
|
||||
@@ -219,3 +224,45 @@ type TargetParametersSpec struct {
|
||||
MaxBurstLength uint `json:"maxBurstLength"`
|
||||
MaxQueueCmd uint `json:"maxQueueCmd"`
|
||||
}
|
||||
|
||||
// +genclient
|
||||
// +genclient:noStatus
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
type ISGW struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata"`
|
||||
Spec ISGWSpec `json:"spec"`
|
||||
}
|
||||
|
||||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
|
||||
|
||||
type ISGWList struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ListMeta `json:"metadata"`
|
||||
Items []ISGW `json:"items"`
|
||||
}
|
||||
|
||||
// ISGWSpec represent the spec of a isgw service
|
||||
type ISGWSpec struct {
|
||||
// The affinity to place the ISGW pods (default is to place on any available nodes in EdgeFS running namespace)
|
||||
Placement rook.Placement `json:"placement"`
|
||||
// Resources set resource requests and limits
|
||||
Resources v1.ResourceRequirements `json:"resources,omitempty"`
|
||||
// The number of pods in the ISGW replicaset
|
||||
Instances int32 `json:"instances"`
|
||||
// ISGW I/O flow direction
|
||||
Direction string `json:"direction,omitempty"`
|
||||
// ISGW remote URL
|
||||
RemoteURL string `json:"remoteURL,omitempty"`
|
||||
// ISGW Replication Type
|
||||
ReplicationType string `json:"replicationType,omitempty"`
|
||||
// ISGW Metadata Only flag
|
||||
MetadataOnly bool `json:"metadataOnly,omitempty"`
|
||||
// ISGW Dynamic Fetch Port (default 49678)
|
||||
DynamicFetchPort uint `json:"dynamicFetchPort,omitempty"`
|
||||
// ISGW Endpoint local address (default value 0.0.0.0:14000)
|
||||
LocalAddr string `json:"localAddr,omitempty"`
|
||||
// ISGW Encrypted Tunnel flag
|
||||
UseEncryptedTunnel bool `json:"useEncryptedTunnel,omitempty"`
|
||||
}
|
||||
@@ -230,6 +230,7 @@ func (in *ClusterSpec) DeepCopyInto(out *ClusterSpec) {
|
||||
}
|
||||
}
|
||||
out.Network = in.Network
|
||||
out.Dashboard = in.Dashboard
|
||||
in.Resources.DeepCopyInto(&out.Resources)
|
||||
out.DataVolumeSize = in.DataVolumeSize.DeepCopy()
|
||||
return
|
||||
@@ -261,6 +262,22 @@ func (in *ClusterStatus) DeepCopy() *ClusterStatus {
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *DashboardSpec) DeepCopyInto(out *DashboardSpec) {
|
||||
*out = *in
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DashboardSpec.
|
||||
func (in *DashboardSpec) DeepCopy() *DashboardSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(DashboardSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *DevicesConfig) DeepCopyInto(out *DevicesConfig) {
|
||||
*out = *in
|
||||
@@ -374,6 +391,84 @@ func (in *ISCSISpec) DeepCopy() *ISCSISpec {
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *ISGW) DeepCopyInto(out *ISGW) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
|
||||
in.Spec.DeepCopyInto(&out.Spec)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ISGW.
|
||||
func (in *ISGW) DeepCopy() *ISGW {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ISGW)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *ISGW) 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 *ISGWList) DeepCopyInto(out *ISGWList) {
|
||||
*out = *in
|
||||
out.TypeMeta = in.TypeMeta
|
||||
out.ListMeta = in.ListMeta
|
||||
if in.Items != nil {
|
||||
in, out := &in.Items, &out.Items
|
||||
*out = make([]ISGW, len(*in))
|
||||
for i := range *in {
|
||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ISGWList.
|
||||
func (in *ISGWList) DeepCopy() *ISGWList {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ISGWList)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
|
||||
func (in *ISGWList) 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 *ISGWSpec) DeepCopyInto(out *ISGWSpec) {
|
||||
*out = *in
|
||||
in.Placement.DeepCopyInto(&out.Placement)
|
||||
in.Resources.DeepCopyInto(&out.Resources)
|
||||
return
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ISGWSpec.
|
||||
func (in *ISGWSpec) DeepCopy() *ISGWSpec {
|
||||
if in == nil {
|
||||
return nil
|
||||
}
|
||||
out := new(ISGWSpec)
|
||||
in.DeepCopyInto(out)
|
||||
return out
|
||||
}
|
||||
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *NFS) DeepCopyInto(out *NFS) {
|
||||
*out = *in
|
||||
|
||||
@@ -29,6 +29,7 @@ type EdgefsV1alpha1Interface interface {
|
||||
RESTClient() rest.Interface
|
||||
ClustersGetter
|
||||
ISCSIsGetter
|
||||
ISGWsGetter
|
||||
NFSsGetter
|
||||
S3sGetter
|
||||
S3XsGetter
|
||||
@@ -47,6 +48,10 @@ func (c *EdgefsV1alpha1Client) ISCSIs(namespace string) ISCSIInterface {
|
||||
return newISCSIs(c, namespace)
|
||||
}
|
||||
|
||||
func (c *EdgefsV1alpha1Client) ISGWs(namespace string) ISGWInterface {
|
||||
return newISGWs(c, namespace)
|
||||
}
|
||||
|
||||
func (c *EdgefsV1alpha1Client) NFSs(namespace string) NFSInterface {
|
||||
return newNFSs(c, namespace)
|
||||
}
|
||||
|
||||
+4
@@ -36,6 +36,10 @@ func (c *FakeEdgefsV1alpha1) ISCSIs(namespace string) v1alpha1.ISCSIInterface {
|
||||
return &FakeISCSIs{c, namespace}
|
||||
}
|
||||
|
||||
func (c *FakeEdgefsV1alpha1) ISGWs(namespace string) v1alpha1.ISGWInterface {
|
||||
return &FakeISGWs{c, namespace}
|
||||
}
|
||||
|
||||
func (c *FakeEdgefsV1alpha1) NFSs(namespace string) v1alpha1.NFSInterface {
|
||||
return &FakeNFSs{c, namespace}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
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 client-gen. DO NOT EDIT.
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
v1alpha1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1alpha1"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
labels "k8s.io/apimachinery/pkg/labels"
|
||||
schema "k8s.io/apimachinery/pkg/runtime/schema"
|
||||
types "k8s.io/apimachinery/pkg/types"
|
||||
watch "k8s.io/apimachinery/pkg/watch"
|
||||
testing "k8s.io/client-go/testing"
|
||||
)
|
||||
|
||||
// FakeISGWs implements ISGWInterface
|
||||
type FakeISGWs struct {
|
||||
Fake *FakeEdgefsV1alpha1
|
||||
ns string
|
||||
}
|
||||
|
||||
var isgwsResource = schema.GroupVersionResource{Group: "edgefs.rook.io", Version: "v1alpha1", Resource: "isgws"}
|
||||
|
||||
var isgwsKind = schema.GroupVersionKind{Group: "edgefs.rook.io", Version: "v1alpha1", Kind: "ISGW"}
|
||||
|
||||
// Get takes name of the iSGW, and returns the corresponding iSGW object, and an error if there is any.
|
||||
func (c *FakeISGWs) Get(name string, options v1.GetOptions) (result *v1alpha1.ISGW, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewGetAction(isgwsResource, c.ns, name), &v1alpha1.ISGW{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1alpha1.ISGW), err
|
||||
}
|
||||
|
||||
// List takes label and field selectors, and returns the list of ISGWs that match those selectors.
|
||||
func (c *FakeISGWs) List(opts v1.ListOptions) (result *v1alpha1.ISGWList, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewListAction(isgwsResource, isgwsKind, c.ns, opts), &v1alpha1.ISGWList{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
label, _, _ := testing.ExtractFromListOptions(opts)
|
||||
if label == nil {
|
||||
label = labels.Everything()
|
||||
}
|
||||
list := &v1alpha1.ISGWList{ListMeta: obj.(*v1alpha1.ISGWList).ListMeta}
|
||||
for _, item := range obj.(*v1alpha1.ISGWList).Items {
|
||||
if label.Matches(labels.Set(item.Labels)) {
|
||||
list.Items = append(list.Items, item)
|
||||
}
|
||||
}
|
||||
return list, err
|
||||
}
|
||||
|
||||
// Watch returns a watch.Interface that watches the requested iSGWs.
|
||||
func (c *FakeISGWs) Watch(opts v1.ListOptions) (watch.Interface, error) {
|
||||
return c.Fake.
|
||||
InvokesWatch(testing.NewWatchAction(isgwsResource, c.ns, opts))
|
||||
|
||||
}
|
||||
|
||||
// Create takes the representation of a iSGW and creates it. Returns the server's representation of the iSGW, and an error, if there is any.
|
||||
func (c *FakeISGWs) Create(iSGW *v1alpha1.ISGW) (result *v1alpha1.ISGW, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewCreateAction(isgwsResource, c.ns, iSGW), &v1alpha1.ISGW{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1alpha1.ISGW), err
|
||||
}
|
||||
|
||||
// Update takes the representation of a iSGW and updates it. Returns the server's representation of the iSGW, and an error, if there is any.
|
||||
func (c *FakeISGWs) Update(iSGW *v1alpha1.ISGW) (result *v1alpha1.ISGW, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewUpdateAction(isgwsResource, c.ns, iSGW), &v1alpha1.ISGW{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1alpha1.ISGW), err
|
||||
}
|
||||
|
||||
// Delete takes name of the iSGW and deletes it. Returns an error if one occurs.
|
||||
func (c *FakeISGWs) Delete(name string, options *v1.DeleteOptions) error {
|
||||
_, err := c.Fake.
|
||||
Invokes(testing.NewDeleteAction(isgwsResource, c.ns, name), &v1alpha1.ISGW{})
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// DeleteCollection deletes a collection of objects.
|
||||
func (c *FakeISGWs) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
|
||||
action := testing.NewDeleteCollectionAction(isgwsResource, c.ns, listOptions)
|
||||
|
||||
_, err := c.Fake.Invokes(action, &v1alpha1.ISGWList{})
|
||||
return err
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched iSGW.
|
||||
func (c *FakeISGWs) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.ISGW, err error) {
|
||||
obj, err := c.Fake.
|
||||
Invokes(testing.NewPatchSubresourceAction(isgwsResource, c.ns, name, data, subresources...), &v1alpha1.ISGW{})
|
||||
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
return obj.(*v1alpha1.ISGW), err
|
||||
}
|
||||
@@ -22,6 +22,8 @@ type ClusterExpansion interface{}
|
||||
|
||||
type ISCSIExpansion interface{}
|
||||
|
||||
type ISGWExpansion interface{}
|
||||
|
||||
type NFSExpansion interface{}
|
||||
|
||||
type S3Expansion interface{}
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
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 client-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
v1alpha1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1alpha1"
|
||||
scheme "github.com/rook/rook/pkg/client/clientset/versioned/scheme"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
types "k8s.io/apimachinery/pkg/types"
|
||||
watch "k8s.io/apimachinery/pkg/watch"
|
||||
rest "k8s.io/client-go/rest"
|
||||
)
|
||||
|
||||
// ISGWsGetter has a method to return a ISGWInterface.
|
||||
// A group's client should implement this interface.
|
||||
type ISGWsGetter interface {
|
||||
ISGWs(namespace string) ISGWInterface
|
||||
}
|
||||
|
||||
// ISGWInterface has methods to work with ISGW resources.
|
||||
type ISGWInterface interface {
|
||||
Create(*v1alpha1.ISGW) (*v1alpha1.ISGW, error)
|
||||
Update(*v1alpha1.ISGW) (*v1alpha1.ISGW, error)
|
||||
Delete(name string, options *v1.DeleteOptions) error
|
||||
DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error
|
||||
Get(name string, options v1.GetOptions) (*v1alpha1.ISGW, error)
|
||||
List(opts v1.ListOptions) (*v1alpha1.ISGWList, error)
|
||||
Watch(opts v1.ListOptions) (watch.Interface, error)
|
||||
Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.ISGW, err error)
|
||||
ISGWExpansion
|
||||
}
|
||||
|
||||
// iSGWs implements ISGWInterface
|
||||
type iSGWs struct {
|
||||
client rest.Interface
|
||||
ns string
|
||||
}
|
||||
|
||||
// newISGWs returns a ISGWs
|
||||
func newISGWs(c *EdgefsV1alpha1Client, namespace string) *iSGWs {
|
||||
return &iSGWs{
|
||||
client: c.RESTClient(),
|
||||
ns: namespace,
|
||||
}
|
||||
}
|
||||
|
||||
// Get takes name of the iSGW, and returns the corresponding iSGW object, and an error if there is any.
|
||||
func (c *iSGWs) Get(name string, options v1.GetOptions) (result *v1alpha1.ISGW, err error) {
|
||||
result = &v1alpha1.ISGW{}
|
||||
err = c.client.Get().
|
||||
Namespace(c.ns).
|
||||
Resource("isgws").
|
||||
Name(name).
|
||||
VersionedParams(&options, scheme.ParameterCodec).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// List takes label and field selectors, and returns the list of ISGWs that match those selectors.
|
||||
func (c *iSGWs) List(opts v1.ListOptions) (result *v1alpha1.ISGWList, err error) {
|
||||
result = &v1alpha1.ISGWList{}
|
||||
err = c.client.Get().
|
||||
Namespace(c.ns).
|
||||
Resource("isgws").
|
||||
VersionedParams(&opts, scheme.ParameterCodec).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Watch returns a watch.Interface that watches the requested iSGWs.
|
||||
func (c *iSGWs) Watch(opts v1.ListOptions) (watch.Interface, error) {
|
||||
opts.Watch = true
|
||||
return c.client.Get().
|
||||
Namespace(c.ns).
|
||||
Resource("isgws").
|
||||
VersionedParams(&opts, scheme.ParameterCodec).
|
||||
Watch()
|
||||
}
|
||||
|
||||
// Create takes the representation of a iSGW and creates it. Returns the server's representation of the iSGW, and an error, if there is any.
|
||||
func (c *iSGWs) Create(iSGW *v1alpha1.ISGW) (result *v1alpha1.ISGW, err error) {
|
||||
result = &v1alpha1.ISGW{}
|
||||
err = c.client.Post().
|
||||
Namespace(c.ns).
|
||||
Resource("isgws").
|
||||
Body(iSGW).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Update takes the representation of a iSGW and updates it. Returns the server's representation of the iSGW, and an error, if there is any.
|
||||
func (c *iSGWs) Update(iSGW *v1alpha1.ISGW) (result *v1alpha1.ISGW, err error) {
|
||||
result = &v1alpha1.ISGW{}
|
||||
err = c.client.Put().
|
||||
Namespace(c.ns).
|
||||
Resource("isgws").
|
||||
Name(iSGW.Name).
|
||||
Body(iSGW).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
|
||||
// Delete takes name of the iSGW and deletes it. Returns an error if one occurs.
|
||||
func (c *iSGWs) Delete(name string, options *v1.DeleteOptions) error {
|
||||
return c.client.Delete().
|
||||
Namespace(c.ns).
|
||||
Resource("isgws").
|
||||
Name(name).
|
||||
Body(options).
|
||||
Do().
|
||||
Error()
|
||||
}
|
||||
|
||||
// DeleteCollection deletes a collection of objects.
|
||||
func (c *iSGWs) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error {
|
||||
return c.client.Delete().
|
||||
Namespace(c.ns).
|
||||
Resource("isgws").
|
||||
VersionedParams(&listOptions, scheme.ParameterCodec).
|
||||
Body(options).
|
||||
Do().
|
||||
Error()
|
||||
}
|
||||
|
||||
// Patch applies the patch and returns the patched iSGW.
|
||||
func (c *iSGWs) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.ISGW, err error) {
|
||||
result = &v1alpha1.ISGW{}
|
||||
err = c.client.Patch(pt).
|
||||
Namespace(c.ns).
|
||||
Resource("isgws").
|
||||
SubResource(subresources...).
|
||||
Name(name).
|
||||
Body(data).
|
||||
Do().
|
||||
Into(result)
|
||||
return
|
||||
}
|
||||
@@ -28,6 +28,8 @@ type Interface interface {
|
||||
Clusters() ClusterInformer
|
||||
// ISCSIs returns a ISCSIInformer.
|
||||
ISCSIs() ISCSIInformer
|
||||
// ISGWs returns a ISGWInformer.
|
||||
ISGWs() ISGWInformer
|
||||
// NFSs returns a NFSInformer.
|
||||
NFSs() NFSInformer
|
||||
// S3s returns a S3Informer.
|
||||
@@ -57,6 +59,11 @@ func (v *version) ISCSIs() ISCSIInformer {
|
||||
return &iSCSIInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
|
||||
}
|
||||
|
||||
// ISGWs returns a ISGWInformer.
|
||||
func (v *version) ISGWs() ISGWInformer {
|
||||
return &iSGWInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
|
||||
}
|
||||
|
||||
// NFSs returns a NFSInformer.
|
||||
func (v *version) NFSs() NFSInformer {
|
||||
return &nFSInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
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 informer-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
time "time"
|
||||
|
||||
edgefsrookiov1alpha1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1alpha1"
|
||||
versioned "github.com/rook/rook/pkg/client/clientset/versioned"
|
||||
internalinterfaces "github.com/rook/rook/pkg/client/informers/externalversions/internalinterfaces"
|
||||
v1alpha1 "github.com/rook/rook/pkg/client/listers/edgefs.rook.io/v1alpha1"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
watch "k8s.io/apimachinery/pkg/watch"
|
||||
cache "k8s.io/client-go/tools/cache"
|
||||
)
|
||||
|
||||
// ISGWInformer provides access to a shared informer and lister for
|
||||
// ISGWs.
|
||||
type ISGWInformer interface {
|
||||
Informer() cache.SharedIndexInformer
|
||||
Lister() v1alpha1.ISGWLister
|
||||
}
|
||||
|
||||
type iSGWInformer struct {
|
||||
factory internalinterfaces.SharedInformerFactory
|
||||
tweakListOptions internalinterfaces.TweakListOptionsFunc
|
||||
namespace string
|
||||
}
|
||||
|
||||
// NewISGWInformer constructs a new informer for ISGW type.
|
||||
// Always prefer using an informer factory to get a shared informer instead of getting an independent
|
||||
// one. This reduces memory footprint and number of connections to the server.
|
||||
func NewISGWInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
|
||||
return NewFilteredISGWInformer(client, namespace, resyncPeriod, indexers, nil)
|
||||
}
|
||||
|
||||
// NewFilteredISGWInformer constructs a new informer for ISGW type.
|
||||
// Always prefer using an informer factory to get a shared informer instead of getting an independent
|
||||
// one. This reduces memory footprint and number of connections to the server.
|
||||
func NewFilteredISGWInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
|
||||
return cache.NewSharedIndexInformer(
|
||||
&cache.ListWatch{
|
||||
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
|
||||
if tweakListOptions != nil {
|
||||
tweakListOptions(&options)
|
||||
}
|
||||
return client.EdgefsV1alpha1().ISGWs(namespace).List(options)
|
||||
},
|
||||
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
|
||||
if tweakListOptions != nil {
|
||||
tweakListOptions(&options)
|
||||
}
|
||||
return client.EdgefsV1alpha1().ISGWs(namespace).Watch(options)
|
||||
},
|
||||
},
|
||||
&edgefsrookiov1alpha1.ISGW{},
|
||||
resyncPeriod,
|
||||
indexers,
|
||||
)
|
||||
}
|
||||
|
||||
func (f *iSGWInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
|
||||
return NewFilteredISGWInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
|
||||
}
|
||||
|
||||
func (f *iSGWInformer) Informer() cache.SharedIndexInformer {
|
||||
return f.factory.InformerFor(&edgefsrookiov1alpha1.ISGW{}, f.defaultInformer)
|
||||
}
|
||||
|
||||
func (f *iSGWInformer) Lister() v1alpha1.ISGWLister {
|
||||
return v1alpha1.NewISGWLister(f.Informer().GetIndexer())
|
||||
}
|
||||
@@ -98,6 +98,8 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource
|
||||
return &genericInformer{resource: resource.GroupResource(), informer: f.Edgefs().V1alpha1().Clusters().Informer()}, nil
|
||||
case edgefsrookiov1alpha1.SchemeGroupVersion.WithResource("iscsis"):
|
||||
return &genericInformer{resource: resource.GroupResource(), informer: f.Edgefs().V1alpha1().ISCSIs().Informer()}, nil
|
||||
case edgefsrookiov1alpha1.SchemeGroupVersion.WithResource("isgws"):
|
||||
return &genericInformer{resource: resource.GroupResource(), informer: f.Edgefs().V1alpha1().ISGWs().Informer()}, nil
|
||||
case edgefsrookiov1alpha1.SchemeGroupVersion.WithResource("nfss"):
|
||||
return &genericInformer{resource: resource.GroupResource(), informer: f.Edgefs().V1alpha1().NFSs().Informer()}, nil
|
||||
case edgefsrookiov1alpha1.SchemeGroupVersion.WithResource("s3s"):
|
||||
|
||||
@@ -34,6 +34,14 @@ type ISCSIListerExpansion interface{}
|
||||
// ISCSINamespaceLister.
|
||||
type ISCSINamespaceListerExpansion interface{}
|
||||
|
||||
// ISGWListerExpansion allows custom methods to be added to
|
||||
// ISGWLister.
|
||||
type ISGWListerExpansion interface{}
|
||||
|
||||
// ISGWNamespaceListerExpansion allows custom methods to be added to
|
||||
// ISGWNamespaceLister.
|
||||
type ISGWNamespaceListerExpansion interface{}
|
||||
|
||||
// NFSListerExpansion allows custom methods to be added to
|
||||
// NFSLister.
|
||||
type NFSListerExpansion interface{}
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
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 lister-gen. DO NOT EDIT.
|
||||
|
||||
package v1alpha1
|
||||
|
||||
import (
|
||||
v1alpha1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1alpha1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
)
|
||||
|
||||
// ISGWLister helps list ISGWs.
|
||||
type ISGWLister interface {
|
||||
// List lists all ISGWs in the indexer.
|
||||
List(selector labels.Selector) (ret []*v1alpha1.ISGW, err error)
|
||||
// ISGWs returns an object that can list and get ISGWs.
|
||||
ISGWs(namespace string) ISGWNamespaceLister
|
||||
ISGWListerExpansion
|
||||
}
|
||||
|
||||
// iSGWLister implements the ISGWLister interface.
|
||||
type iSGWLister struct {
|
||||
indexer cache.Indexer
|
||||
}
|
||||
|
||||
// NewISGWLister returns a new ISGWLister.
|
||||
func NewISGWLister(indexer cache.Indexer) ISGWLister {
|
||||
return &iSGWLister{indexer: indexer}
|
||||
}
|
||||
|
||||
// List lists all ISGWs in the indexer.
|
||||
func (s *iSGWLister) List(selector labels.Selector) (ret []*v1alpha1.ISGW, err error) {
|
||||
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
|
||||
ret = append(ret, m.(*v1alpha1.ISGW))
|
||||
})
|
||||
return ret, err
|
||||
}
|
||||
|
||||
// ISGWs returns an object that can list and get ISGWs.
|
||||
func (s *iSGWLister) ISGWs(namespace string) ISGWNamespaceLister {
|
||||
return iSGWNamespaceLister{indexer: s.indexer, namespace: namespace}
|
||||
}
|
||||
|
||||
// ISGWNamespaceLister helps list and get ISGWs.
|
||||
type ISGWNamespaceLister interface {
|
||||
// List lists all ISGWs in the indexer for a given namespace.
|
||||
List(selector labels.Selector) (ret []*v1alpha1.ISGW, err error)
|
||||
// Get retrieves the ISGW from the indexer for a given namespace and name.
|
||||
Get(name string) (*v1alpha1.ISGW, error)
|
||||
ISGWNamespaceListerExpansion
|
||||
}
|
||||
|
||||
// iSGWNamespaceLister implements the ISGWNamespaceLister
|
||||
// interface.
|
||||
type iSGWNamespaceLister struct {
|
||||
indexer cache.Indexer
|
||||
namespace string
|
||||
}
|
||||
|
||||
// List lists all ISGWs in the indexer for a given namespace.
|
||||
func (s iSGWNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.ISGW, err error) {
|
||||
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
|
||||
ret = append(ret, m.(*v1alpha1.ISGW))
|
||||
})
|
||||
return ret, err
|
||||
}
|
||||
|
||||
// Get retrieves the ISGW from the indexer for a given namespace and name.
|
||||
func (s iSGWNamespaceLister) Get(name string) (*v1alpha1.ISGW, error) {
|
||||
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !exists {
|
||||
return nil, errors.NewNotFound(v1alpha1.Resource("isgw"), name)
|
||||
}
|
||||
return obj.(*v1alpha1.ISGW), nil
|
||||
}
|
||||
@@ -143,7 +143,7 @@ func (c *cluster) createInstance(rookImage string) error {
|
||||
// Create and start EdgeFS manager Deployment (gRPC proxy, Prometheus metrics)
|
||||
//
|
||||
c.mgrs = mgr.New(c.context, c.Namespace, "latest", c.Spec.ServiceAccount, c.Spec.DataDirHostPath, c.Spec.DataVolumeSize,
|
||||
edgefsv1alpha1.GetMgrPlacement(c.Spec.Placement), c.Spec.Network,
|
||||
edgefsv1alpha1.GetMgrPlacement(c.Spec.Placement), c.Spec.Network, c.Spec.Dashboard,
|
||||
v1.ResourceRequirements{}, c.ownerRef)
|
||||
err = c.mgrs.Start(rookImage)
|
||||
if err != nil {
|
||||
|
||||
@@ -30,6 +30,7 @@ import (
|
||||
"github.com/rook/rook/pkg/clusterd"
|
||||
"github.com/rook/rook/pkg/operator/discover"
|
||||
"github.com/rook/rook/pkg/operator/edgefs/iscsi"
|
||||
"github.com/rook/rook/pkg/operator/edgefs/isgw"
|
||||
"github.com/rook/rook/pkg/operator/edgefs/nfs"
|
||||
"github.com/rook/rook/pkg/operator/edgefs/s3"
|
||||
"github.com/rook/rook/pkg/operator/edgefs/s3x"
|
||||
@@ -212,6 +213,15 @@ func (c *ClusterController) onAdd(obj interface{}) {
|
||||
cluster.ownerRef)
|
||||
ISCSIController.StartWatch(cluster.Namespace, cluster.stopCh)
|
||||
|
||||
// Start ISGW service CRD watcher
|
||||
ISGWController := isgw.NewISGWController(c.context, c.containerImage,
|
||||
isHostNetworkDefined(cluster.Spec.Network),
|
||||
cluster.Spec.DataDirHostPath, cluster.Spec.DataVolumeSize,
|
||||
edgefsv1alpha1.GetTargetPlacement(cluster.Spec.Placement),
|
||||
cluster.Spec.Resources,
|
||||
cluster.ownerRef)
|
||||
ISGWController.StartWatch(cluster.Namespace, cluster.stopCh)
|
||||
|
||||
// add the finalizer to the crd
|
||||
err = c.addFinalizer(clusterObj)
|
||||
if err != nil {
|
||||
|
||||
@@ -19,6 +19,7 @@ package mgr
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -64,7 +65,8 @@ type Cluster struct {
|
||||
dataVolumeSize resource.Quantity
|
||||
placement rookalpha.Placement
|
||||
context *clusterd.Context
|
||||
HostNetworkSpec edgefsv1alpha1.NetworkSpec
|
||||
hostNetworkSpec edgefsv1alpha1.NetworkSpec
|
||||
dashboardSpec edgefsv1alpha1.DashboardSpec
|
||||
resources v1.ResourceRequirements
|
||||
ownerRef metav1.OwnerReference
|
||||
}
|
||||
@@ -75,7 +77,9 @@ func New(
|
||||
serviceAccount string,
|
||||
dataDirHostPath string,
|
||||
dataVolumeSize resource.Quantity,
|
||||
placement rookalpha.Placement, HostNetworkSpec edgefsv1alpha1.NetworkSpec,
|
||||
placement rookalpha.Placement,
|
||||
hostNetworkSpec edgefsv1alpha1.NetworkSpec,
|
||||
dashboardSpec edgefsv1alpha1.DashboardSpec,
|
||||
resources v1.ResourceRequirements,
|
||||
ownerRef metav1.OwnerReference,
|
||||
) *Cluster {
|
||||
@@ -95,7 +99,8 @@ func New(
|
||||
Replicas: 1,
|
||||
dataDirHostPath: dataDirHostPath,
|
||||
dataVolumeSize: dataVolumeSize,
|
||||
HostNetworkSpec: HostNetworkSpec,
|
||||
hostNetworkSpec: hostNetworkSpec,
|
||||
dashboardSpec: dashboardSpec,
|
||||
resources: resources,
|
||||
ownerRef: ownerRef,
|
||||
}
|
||||
@@ -170,7 +175,7 @@ func (c *Cluster) makeMgrService(name string) *v1.Service {
|
||||
},
|
||||
Spec: v1.ServiceSpec{
|
||||
Selector: labels,
|
||||
Type: v1.ServiceTypeNodePort,
|
||||
Type: v1.ServiceTypeClusterIP,
|
||||
Ports: []v1.ServicePort{
|
||||
{
|
||||
Name: "mgr",
|
||||
@@ -195,7 +200,7 @@ func (c *Cluster) makeRestapiService(name string) *v1.Service {
|
||||
},
|
||||
Spec: v1.ServiceSpec{
|
||||
Selector: labels,
|
||||
Type: v1.ServiceTypeNodePort,
|
||||
Type: v1.ServiceTypeClusterIP,
|
||||
Ports: []v1.ServicePort{
|
||||
{
|
||||
Name: "http-metrics",
|
||||
@@ -247,6 +252,22 @@ func (c *Cluster) makeUiService(name string) *v1.Service {
|
||||
}
|
||||
|
||||
k8sutil.SetOwnerRef(c.context.Clientset, c.Namespace, &svc.ObjectMeta, &c.ownerRef)
|
||||
|
||||
if c.dashboardSpec.LocalAddr != "" {
|
||||
ip := net.ParseIP(c.dashboardSpec.LocalAddr)
|
||||
if ip == nil {
|
||||
logger.Errorf("wrong dashboard localAddr format")
|
||||
return svc
|
||||
}
|
||||
|
||||
if !ip.IsUnspecified() {
|
||||
logger.Infof("Cluster dashboard assigned with externalIP=%s", c.dashboardSpec.LocalAddr)
|
||||
svc.Spec.ExternalIPs = []string{c.dashboardSpec.LocalAddr}
|
||||
} else {
|
||||
logger.Errorf("Cluster dashboard externalIP cannot be assigned to %s", c.dashboardSpec.LocalAddr)
|
||||
}
|
||||
}
|
||||
|
||||
return svc
|
||||
}
|
||||
|
||||
@@ -296,11 +317,11 @@ func (c *Cluster) makeDeployment(name, clusterName, rookImage string, replicas i
|
||||
RestartPolicy: v1.RestartPolicyAlways,
|
||||
Volumes: volumes,
|
||||
HostIPC: true,
|
||||
HostNetwork: isHostNetworkDefined(c.HostNetworkSpec),
|
||||
HostNetwork: isHostNetworkDefined(c.hostNetworkSpec),
|
||||
NodeSelector: map[string]string{c.Namespace: "cluster"},
|
||||
},
|
||||
}
|
||||
if isHostNetworkDefined(c.HostNetworkSpec) {
|
||||
if isHostNetworkDefined(c.hostNetworkSpec) {
|
||||
podSpec.Spec.DNSPolicy = v1.DNSClusterFirstWithHostNet
|
||||
}
|
||||
c.placement.ApplyToPodSpec(&podSpec.Spec)
|
||||
|
||||
@@ -46,7 +46,8 @@ func TestStartMGR(t *testing.T) {
|
||||
ConfigDir: configDir,
|
||||
Clientset: testop.New(3)}
|
||||
volSize := resource.NewQuantity(100000.0, resource.BinarySI)
|
||||
c := New(context, "ns", "myversion", "", "", *volSize, rookalpha.Placement{}, edgefsv1alpha1.NetworkSpec{}, v1.ResourceRequirements{}, metav1.OwnerReference{})
|
||||
c := New(context, "ns", "myversion", "", "", *volSize, rookalpha.Placement{}, edgefsv1alpha1.NetworkSpec{},
|
||||
edgefsv1alpha1.DashboardSpec{}, v1.ResourceRequirements{}, metav1.OwnerReference{})
|
||||
|
||||
// start a basic service
|
||||
err := c.Start("edgefs")
|
||||
@@ -71,14 +72,15 @@ func validateStart(t *testing.T, c *Cluster) {
|
||||
|
||||
func TestPodSpec(t *testing.T) {
|
||||
volSize := resource.NewQuantity(100000.0, resource.BinarySI)
|
||||
c := New(&clusterd.Context{Clientset: testop.New(1)}, "ns", "rook/rook:myversion", "", "", *volSize, rookalpha.Placement{}, edgefsv1alpha1.NetworkSpec{}, v1.ResourceRequirements{
|
||||
Limits: v1.ResourceList{
|
||||
v1.ResourceCPU: *resource.NewQuantity(100.0, resource.BinarySI),
|
||||
},
|
||||
Requests: v1.ResourceList{
|
||||
v1.ResourceMemory: *resource.NewQuantity(1337.0, resource.BinarySI),
|
||||
},
|
||||
}, metav1.OwnerReference{})
|
||||
c := New(&clusterd.Context{Clientset: testop.New(1)}, "ns", "rook/rook:myversion", "", "", *volSize, rookalpha.Placement{},
|
||||
edgefsv1alpha1.NetworkSpec{}, edgefsv1alpha1.DashboardSpec{}, v1.ResourceRequirements{
|
||||
Limits: v1.ResourceList{
|
||||
v1.ResourceCPU: *resource.NewQuantity(100.0, resource.BinarySI),
|
||||
},
|
||||
Requests: v1.ResourceList{
|
||||
v1.ResourceMemory: *resource.NewQuantity(1337.0, resource.BinarySI),
|
||||
},
|
||||
}, metav1.OwnerReference{})
|
||||
|
||||
d := c.makeDeployment("mgr-a", "rook-edgefs", "edgefs", 1)
|
||||
assert.NotNil(t, d)
|
||||
@@ -112,7 +114,8 @@ func TestPodSpec(t *testing.T) {
|
||||
|
||||
func TestServiceSpec(t *testing.T) {
|
||||
volSize := resource.NewQuantity(100000.0, resource.BinarySI)
|
||||
c := New(&clusterd.Context{}, "ns", "myversion", "", "", *volSize, rookalpha.Placement{}, edgefsv1alpha1.NetworkSpec{}, v1.ResourceRequirements{}, metav1.OwnerReference{})
|
||||
c := New(&clusterd.Context{}, "ns", "myversion", "", "", *volSize, rookalpha.Placement{},
|
||||
edgefsv1alpha1.NetworkSpec{}, edgefsv1alpha1.DashboardSpec{}, v1.ResourceRequirements{}, metav1.OwnerReference{})
|
||||
|
||||
s := c.makeMgrService("rook-edgefs-mgr")
|
||||
assert.NotNil(t, s)
|
||||
@@ -122,7 +125,8 @@ func TestServiceSpec(t *testing.T) {
|
||||
|
||||
func TestHostNetwork(t *testing.T) {
|
||||
volSize := resource.NewQuantity(100000.0, resource.BinarySI)
|
||||
c := New(&clusterd.Context{Clientset: testop.New(1)}, "ns", "myversion", "", "", *volSize, rookalpha.Placement{}, edgefsv1alpha1.NetworkSpec{ServerIfName: "eth0"}, v1.ResourceRequirements{}, metav1.OwnerReference{})
|
||||
c := New(&clusterd.Context{Clientset: testop.New(1)}, "ns", "myversion", "", "", *volSize, rookalpha.Placement{},
|
||||
edgefsv1alpha1.NetworkSpec{ServerIfName: "eth0"}, edgefsv1alpha1.DashboardSpec{}, v1.ResourceRequirements{}, metav1.OwnerReference{})
|
||||
|
||||
d := c.makeDeployment("mgr-a", "a", "edgefs", 1)
|
||||
assert.NotNil(t, d)
|
||||
|
||||
@@ -0,0 +1,171 @@
|
||||
/*
|
||||
Copyright 2016 The Rook Authors. All rights reserved.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// scale-out, multi-cloud Edge-X ISGW (Inter-Segment Gateway) services controller
|
||||
package isgw
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
|
||||
"github.com/coreos/pkg/capnslog"
|
||||
opkit "github.com/rook/operator-kit"
|
||||
edgefsv1alpha1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1alpha1"
|
||||
rookalpha "github.com/rook/rook/pkg/apis/rook.io/v1alpha2"
|
||||
"github.com/rook/rook/pkg/clusterd"
|
||||
"k8s.io/api/core/v1"
|
||||
apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
)
|
||||
|
||||
const (
|
||||
customResourceName = "isgw"
|
||||
customResourceNamePlural = "isgws"
|
||||
)
|
||||
|
||||
var logger = capnslog.NewPackageLogger("github.com/rook/rook", "edgefs-op-isgw")
|
||||
|
||||
// ISGWResource represents the isgw custom resource
|
||||
var ISGWResource = opkit.CustomResource{
|
||||
Name: customResourceName,
|
||||
Plural: customResourceNamePlural,
|
||||
Group: edgefsv1alpha1.CustomResourceGroup,
|
||||
Version: edgefsv1alpha1.Version,
|
||||
Scope: apiextensionsv1beta1.NamespaceScoped,
|
||||
Kind: reflect.TypeOf(edgefsv1alpha1.ISGW{}).Name(),
|
||||
}
|
||||
|
||||
// ISGWController represents a controller object for isgw custom resources
|
||||
type ISGWController struct {
|
||||
context *clusterd.Context
|
||||
rookImage string
|
||||
hostNetwork bool
|
||||
dataDirHostPath string
|
||||
dataVolumeSize resource.Quantity
|
||||
placement rookalpha.Placement
|
||||
resources v1.ResourceRequirements
|
||||
ownerRef metav1.OwnerReference
|
||||
}
|
||||
|
||||
// NewISGWController create controller for watching ISGW custom resources created
|
||||
func NewISGWController(
|
||||
context *clusterd.Context, rookImage string,
|
||||
hostNetwork bool,
|
||||
dataDirHostPath string,
|
||||
dataVolumeSize resource.Quantity,
|
||||
placement rookalpha.Placement,
|
||||
resources v1.ResourceRequirements,
|
||||
ownerRef metav1.OwnerReference,
|
||||
) *ISGWController {
|
||||
return &ISGWController{
|
||||
context: context,
|
||||
rookImage: rookImage,
|
||||
hostNetwork: hostNetwork,
|
||||
dataDirHostPath: dataDirHostPath,
|
||||
dataVolumeSize: dataVolumeSize,
|
||||
placement: placement,
|
||||
resources: resources,
|
||||
ownerRef: ownerRef,
|
||||
}
|
||||
}
|
||||
|
||||
// StartWatch watches for instances of ISGW custom resources and acts on them
|
||||
func (c *ISGWController) StartWatch(namespace string, stopCh chan struct{}) error {
|
||||
|
||||
resourceHandlerFuncs := cache.ResourceEventHandlerFuncs{
|
||||
AddFunc: c.onAdd,
|
||||
UpdateFunc: c.onUpdate,
|
||||
DeleteFunc: c.onDelete,
|
||||
}
|
||||
|
||||
logger.Infof("start watching isgw resources in namespace %s", namespace)
|
||||
watcher := opkit.NewWatcher(ISGWResource, namespace, resourceHandlerFuncs, c.context.RookClientset.EdgefsV1alpha1().RESTClient())
|
||||
go watcher.Watch(&edgefsv1alpha1.ISGW{}, stopCh)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *ISGWController) onAdd(obj interface{}) {
|
||||
isgw, err := getISGWObject(obj)
|
||||
if err != nil {
|
||||
logger.Errorf("failed to get isgw object: %+v", err)
|
||||
return
|
||||
}
|
||||
|
||||
if err = c.CreateService(*isgw, c.serviceOwners(isgw)); err != nil {
|
||||
logger.Errorf("failed to create isgw %s. %+v", isgw.Name, err)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ISGWController) onUpdate(oldObj, newObj interface{}) {
|
||||
oldService, err := getISGWObject(oldObj)
|
||||
if err != nil {
|
||||
logger.Errorf("failed to get old isgw object: %+v", err)
|
||||
return
|
||||
}
|
||||
newService, err := getISGWObject(newObj)
|
||||
if err != nil {
|
||||
logger.Errorf("failed to get new isgw object: %+v", err)
|
||||
return
|
||||
}
|
||||
|
||||
if !serviceChanged(oldService.Spec, newService.Spec) {
|
||||
logger.Debugf("isgw %s did not change", newService.Name)
|
||||
return
|
||||
}
|
||||
|
||||
logger.Infof("applying isgw %s changes", newService.Name)
|
||||
if err = c.UpdateService(*newService, c.serviceOwners(newService)); err != nil {
|
||||
logger.Errorf("failed to create (modify) isgw %s. %+v", newService.Name, err)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ISGWController) onDelete(obj interface{}) {
|
||||
isgw, err := getISGWObject(obj)
|
||||
if err != nil {
|
||||
logger.Errorf("failed to get isgw object: %+v", err)
|
||||
return
|
||||
}
|
||||
|
||||
if err = c.DeleteService(*isgw); err != nil {
|
||||
logger.Errorf("failed to delete isgw %s. %+v", isgw.Name, err)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ISGWController) serviceOwners(service *edgefsv1alpha1.ISGW) []metav1.OwnerReference {
|
||||
// Only set the cluster crd as the owner of the ISGW resources.
|
||||
// If the ISGW crd is deleted, the operator will explicitly remove the ISGW resources.
|
||||
// If the ISGW crd still exists when the cluster crd is deleted, this will make sure the ISGW
|
||||
// resources are cleaned up.
|
||||
return []metav1.OwnerReference{c.ownerRef}
|
||||
}
|
||||
|
||||
func serviceChanged(oldService, newService edgefsv1alpha1.ISGWSpec) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func getISGWObject(obj interface{}) (isgw *edgefsv1alpha1.ISGW, err error) {
|
||||
var ok bool
|
||||
isgw, ok = obj.(*edgefsv1alpha1.ISGW)
|
||||
if ok {
|
||||
// the isgw object is of the latest type, simply return it
|
||||
return isgw.DeepCopy(), nil
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("not a known isgw object: %+v", obj)
|
||||
}
|
||||
@@ -0,0 +1,417 @@
|
||||
/*
|
||||
Copyright 2016 The Rook Authors. All rights reserved.
|
||||
|
||||
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 ISGW for the Edgefs manager.
|
||||
package isgw
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"strconv"
|
||||
|
||||
edgefsv1alpha1 "github.com/rook/rook/pkg/apis/edgefs.rook.io/v1alpha1"
|
||||
"github.com/rook/rook/pkg/clusterd"
|
||||
"github.com/rook/rook/pkg/operator/k8sutil"
|
||||
"k8s.io/api/core/v1"
|
||||
extensions "k8s.io/api/extensions/v1beta1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
const (
|
||||
appName = "rook-edgefs-isgw"
|
||||
|
||||
/* ISGW definitions */
|
||||
defaultReplicationType = "initial+continuous"
|
||||
defaultDynamicFetchPort = 49678
|
||||
defaultLocalIPAddr = "0.0.0.0"
|
||||
defaultLocalIPv6Addr = "::"
|
||||
defaultLocalPort = 14000
|
||||
dataVolumeName = "edgefs-datadir"
|
||||
stateVolumeFolder = ".state"
|
||||
etcVolumeFolder = ".etc"
|
||||
)
|
||||
|
||||
// Start the ISGW manager
|
||||
func (c *ISGWController) CreateService(s edgefsv1alpha1.ISGW, ownerRefs []metav1.OwnerReference) error {
|
||||
return c.CreateOrUpdate(s, false, ownerRefs)
|
||||
}
|
||||
|
||||
func (c *ISGWController) UpdateService(s edgefsv1alpha1.ISGW, ownerRefs []metav1.OwnerReference) error {
|
||||
return c.CreateOrUpdate(s, true, ownerRefs)
|
||||
}
|
||||
|
||||
// Start the isgw instance
|
||||
func (c *ISGWController) CreateOrUpdate(s edgefsv1alpha1.ISGW, update bool, ownerRefs []metav1.OwnerReference) error {
|
||||
logger.Infof("starting update=%v service=%s", update, s.Name)
|
||||
|
||||
logger.Infof("ISGW Base image is %s", c.rookImage)
|
||||
// validate ISGW service settings
|
||||
if err := validateService(c.context, s); err != nil {
|
||||
return fmt.Errorf("invalid ISGW service %s arguments. %+v", s.Name, err)
|
||||
}
|
||||
|
||||
if s.Spec.ReplicationType == "" {
|
||||
s.Spec.ReplicationType = defaultReplicationType
|
||||
}
|
||||
|
||||
if s.Spec.DynamicFetchPort == 0 {
|
||||
s.Spec.DynamicFetchPort = defaultDynamicFetchPort
|
||||
}
|
||||
|
||||
if s.Spec.LocalAddr == "" {
|
||||
s.Spec.LocalAddr = defaultLocalIPAddr + ":" + strconv.Itoa(defaultLocalPort)
|
||||
}
|
||||
|
||||
// check if ISGW service already exists
|
||||
exists, err := serviceExists(c.context, s)
|
||||
if err == nil && exists {
|
||||
if !update {
|
||||
logger.Infof("ISGW service %s exists in namespace %s", s.Name, s.Namespace)
|
||||
return nil
|
||||
}
|
||||
logger.Infof("ISGW service %s exists in namespace %s. checking for updates", s.Name, s.Namespace)
|
||||
}
|
||||
|
||||
// start the deployment
|
||||
deployment := c.makeDeployment(s.Name, s.Namespace, c.rookImage, s.Spec)
|
||||
if _, err := c.context.Clientset.ExtensionsV1beta1().Deployments(s.Namespace).Create(deployment); err != nil {
|
||||
if !errors.IsAlreadyExists(err) {
|
||||
return fmt.Errorf("failed to create %s deployment. %+v", appName, err)
|
||||
}
|
||||
logger.Infof("%s deployment already exists", appName)
|
||||
} else {
|
||||
logger.Infof("%s deployment started", appName)
|
||||
}
|
||||
|
||||
// create the isgw service
|
||||
service := c.makeISGWService(instanceName(s.Name), s.Name, s.Namespace, s.Spec)
|
||||
if _, err := c.context.Clientset.CoreV1().Services(s.Namespace).Create(service); err != nil {
|
||||
if !errors.IsAlreadyExists(err) {
|
||||
return fmt.Errorf("failed to create ISGW service. %+v", err)
|
||||
}
|
||||
logger.Infof("ISGW service %s already exists", service)
|
||||
} else {
|
||||
logger.Infof("ISGW service %s started", service)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func getDirection(isgwSpec edgefsv1alpha1.ISGWSpec) int {
|
||||
direction := 0
|
||||
if isgwSpec.Direction == "send" {
|
||||
direction = 1
|
||||
} else if isgwSpec.Direction == "receive" {
|
||||
direction = 2
|
||||
} else {
|
||||
direction = 3
|
||||
}
|
||||
return direction
|
||||
}
|
||||
|
||||
func (c *ISGWController) makeISGWService(name, svcname, namespace string, isgwSpec edgefsv1alpha1.ISGWSpec) *v1.Service {
|
||||
direction := getDirection(isgwSpec)
|
||||
labels := getLabels(name, svcname, namespace)
|
||||
svc := &v1.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: namespace,
|
||||
Labels: labels,
|
||||
},
|
||||
Spec: v1.ServiceSpec{
|
||||
Selector: labels,
|
||||
Type: v1.ServiceTypeNodePort,
|
||||
Ports: []v1.ServicePort{
|
||||
{Name: "grpc", Port: 49000, Protocol: v1.ProtocolTCP},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
if direction == 2 || direction == 3 {
|
||||
laddr, port, err := net.SplitHostPort(isgwSpec.LocalAddr)
|
||||
if err != nil {
|
||||
logger.Errorf("wrong localAddr format")
|
||||
return svc
|
||||
}
|
||||
lport, _ := strconv.Atoi(port)
|
||||
|
||||
svc.Spec.Ports = append(svc.Spec.Ports, v1.ServicePort{Name: "lport", Port: int32(lport), Protocol: v1.ProtocolTCP})
|
||||
|
||||
if laddr != defaultLocalIPAddr && laddr != defaultLocalIPv6Addr {
|
||||
logger.Infof("ISGW service %s assigned with externalIP=%s", svcname, laddr)
|
||||
svc.Spec.ExternalIPs = []string{laddr}
|
||||
}
|
||||
}
|
||||
if direction == 1 || direction == 3 {
|
||||
svc.Spec.Ports = append(svc.Spec.Ports, v1.ServicePort{Name: "dfport", Port: int32(isgwSpec.DynamicFetchPort), Protocol: v1.ProtocolTCP})
|
||||
}
|
||||
|
||||
k8sutil.SetOwnerRef(c.context.Clientset, namespace, &svc.ObjectMeta, &c.ownerRef)
|
||||
return svc
|
||||
}
|
||||
|
||||
func (c *ISGWController) makeDeployment(svcname, namespace, rookImage string, isgwSpec edgefsv1alpha1.ISGWSpec) *extensions.Deployment {
|
||||
|
||||
name := instanceName(svcname)
|
||||
volumes := []v1.Volume{}
|
||||
|
||||
if c.dataVolumeSize.Value() > 0 {
|
||||
// dataVolume case
|
||||
volumes = append(volumes, v1.Volume{
|
||||
Name: dataVolumeName,
|
||||
VolumeSource: v1.VolumeSource{
|
||||
PersistentVolumeClaim: &v1.PersistentVolumeClaimVolumeSource{
|
||||
ClaimName: dataVolumeName,
|
||||
},
|
||||
},
|
||||
})
|
||||
} else {
|
||||
// dataDir case
|
||||
volumes = append(volumes, v1.Volume{
|
||||
Name: dataVolumeName,
|
||||
VolumeSource: v1.VolumeSource{
|
||||
HostPath: &v1.HostPathVolumeSource{
|
||||
Path: c.dataDirHostPath,
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
podSpec := v1.PodTemplateSpec{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: name,
|
||||
Labels: getLabels(name, svcname, namespace),
|
||||
},
|
||||
Spec: v1.PodSpec{
|
||||
Containers: []v1.Container{c.isgwContainer(svcname, name, rookImage, isgwSpec)},
|
||||
RestartPolicy: v1.RestartPolicyAlways,
|
||||
Volumes: volumes,
|
||||
HostIPC: true,
|
||||
HostNetwork: c.hostNetwork,
|
||||
NodeSelector: map[string]string{namespace: "cluster"},
|
||||
},
|
||||
}
|
||||
if c.hostNetwork {
|
||||
podSpec.Spec.DNSPolicy = v1.DNSClusterFirstWithHostNet
|
||||
}
|
||||
|
||||
// apply current ISGW CRD options to pod's specification
|
||||
isgwSpec.Placement.ApplyToPodSpec(&podSpec.Spec)
|
||||
|
||||
instancesCount := int32(1)
|
||||
d := &extensions.Deployment{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: namespace,
|
||||
},
|
||||
Spec: extensions.DeploymentSpec{Template: podSpec, Replicas: &instancesCount},
|
||||
}
|
||||
k8sutil.SetOwnerRef(c.context.Clientset, namespace, &d.ObjectMeta, &c.ownerRef)
|
||||
return d
|
||||
}
|
||||
|
||||
func (c *ISGWController) isgwContainer(svcname, name, containerImage string, isgwSpec edgefsv1alpha1.ISGWSpec) v1.Container {
|
||||
|
||||
runAsUser := int64(0)
|
||||
readOnlyRootFilesystem := false
|
||||
securityContext := &v1.SecurityContext{
|
||||
RunAsUser: &runAsUser,
|
||||
ReadOnlyRootFilesystem: &readOnlyRootFilesystem,
|
||||
Capabilities: &v1.Capabilities{
|
||||
Add: []v1.Capability{"SYS_NICE", "SYS_RESOURCE", "IPC_LOCK"},
|
||||
},
|
||||
}
|
||||
|
||||
direction := getDirection(isgwSpec)
|
||||
|
||||
replication := 3
|
||||
if isgwSpec.ReplicationType == "initial" {
|
||||
replication = 1
|
||||
} else if isgwSpec.ReplicationType == "continuous" {
|
||||
replication = 2
|
||||
} else {
|
||||
replication = 3
|
||||
}
|
||||
|
||||
volumeMounts := []v1.VolumeMount{
|
||||
{
|
||||
Name: dataVolumeName,
|
||||
MountPath: "/opt/nedge/etc.target",
|
||||
SubPath: etcVolumeFolder,
|
||||
},
|
||||
{
|
||||
Name: dataVolumeName,
|
||||
MountPath: "/opt/nedge/var/run",
|
||||
SubPath: stateVolumeFolder,
|
||||
},
|
||||
}
|
||||
|
||||
cont := v1.Container{
|
||||
Name: name,
|
||||
Image: containerImage,
|
||||
ImagePullPolicy: v1.PullAlways,
|
||||
Args: []string{"isgw"},
|
||||
Env: []v1.EnvVar{
|
||||
{
|
||||
Name: "CCOW_LOG_LEVEL",
|
||||
Value: "5",
|
||||
},
|
||||
{
|
||||
Name: "CCOW_SVCNAME",
|
||||
Value: svcname,
|
||||
},
|
||||
{
|
||||
Name: "HOST_HOSTNAME",
|
||||
ValueFrom: &v1.EnvVarSource{
|
||||
FieldRef: &v1.ObjectFieldSelector{
|
||||
FieldPath: "spec.nodeName",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "KUBERNETES_NAMESPACE",
|
||||
ValueFrom: &v1.EnvVarSource{
|
||||
FieldRef: &v1.ObjectFieldSelector{
|
||||
FieldPath: "metadata.namespace",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "EFSISGW_DIRECTION",
|
||||
Value: strconv.Itoa(direction),
|
||||
},
|
||||
{
|
||||
Name: "EFSISGW_REMOTE_URL",
|
||||
Value: isgwSpec.RemoteURL,
|
||||
},
|
||||
{
|
||||
Name: "EFSISGW_LOCAL_ADDR",
|
||||
Value: isgwSpec.LocalAddr,
|
||||
},
|
||||
{
|
||||
Name: "EFSISGW_DYNAMIC_FETCH_PORT",
|
||||
Value: strconv.Itoa(int(isgwSpec.DynamicFetchPort)),
|
||||
},
|
||||
{
|
||||
Name: "EFSISGW_REPLICATION_TYPE",
|
||||
Value: strconv.Itoa(replication),
|
||||
},
|
||||
{
|
||||
Name: "EFSISGW_USE_ENCRYPTED_TUNNEL",
|
||||
Value: (map[bool]string{true: "1", false: "0"})[isgwSpec.UseEncryptedTunnel],
|
||||
},
|
||||
{
|
||||
Name: "EFSISGW_METADATA_ONLY",
|
||||
Value: (map[bool]string{true: "1", false: "0"})[isgwSpec.MetadataOnly],
|
||||
},
|
||||
},
|
||||
SecurityContext: securityContext,
|
||||
Resources: isgwSpec.Resources,
|
||||
Ports: []v1.ContainerPort{
|
||||
{Name: "grpc", ContainerPort: 49000, Protocol: v1.ProtocolTCP},
|
||||
},
|
||||
VolumeMounts: volumeMounts,
|
||||
}
|
||||
|
||||
if direction == 2 || direction == 3 {
|
||||
_, port, err := net.SplitHostPort(isgwSpec.LocalAddr)
|
||||
if err != nil {
|
||||
logger.Errorf("wrong localAddr format")
|
||||
return cont
|
||||
}
|
||||
lport, _ := strconv.Atoi(port)
|
||||
cont.Ports = append(cont.Ports, v1.ContainerPort{Name: "lport", ContainerPort: int32(lport), Protocol: v1.ProtocolTCP})
|
||||
}
|
||||
if direction == 1 || direction == 3 {
|
||||
cont.Ports = append(cont.Ports, v1.ContainerPort{Name: "dfport", ContainerPort: int32(isgwSpec.DynamicFetchPort), Protocol: v1.ProtocolTCP})
|
||||
}
|
||||
return cont
|
||||
}
|
||||
|
||||
// Delete ISGW service and possibly some artifacts.
|
||||
func (c *ISGWController) DeleteService(s edgefsv1alpha1.ISGW) error {
|
||||
// check if service exists
|
||||
exists, err := serviceExists(c.context, s)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to detect if there is a ISGW service to delete. %+v", err)
|
||||
}
|
||||
if !exists {
|
||||
logger.Infof("ISGW service %s does not exist in namespace %s", s.Name, s.Namespace)
|
||||
return nil
|
||||
}
|
||||
|
||||
logger.Infof("Deleting ISGW service %s from namespace %s", s.Name, s.Namespace)
|
||||
|
||||
var gracePeriod int64
|
||||
propagation := metav1.DeletePropagationForeground
|
||||
options := &metav1.DeleteOptions{GracePeriodSeconds: &gracePeriod, PropagationPolicy: &propagation}
|
||||
|
||||
// Delete the isgw service
|
||||
err = c.context.Clientset.CoreV1().Services(s.Namespace).Delete(instanceName(s.Name), options)
|
||||
if err != nil && !errors.IsNotFound(err) {
|
||||
logger.Warningf("failed to delete ISGW service. %+v", err)
|
||||
}
|
||||
|
||||
// Make a best effort to delete the ISGW pods
|
||||
err = k8sutil.DeleteDeployment(c.context.Clientset, s.Namespace, instanceName(s.Name))
|
||||
if err != nil {
|
||||
logger.Warningf(err.Error())
|
||||
}
|
||||
|
||||
logger.Infof("Completed deleting ISGW service %s", s.Name)
|
||||
return nil
|
||||
}
|
||||
|
||||
func getLabels(name, svcname, namespace string) map[string]string {
|
||||
return map[string]string{
|
||||
k8sutil.AppAttr: appName,
|
||||
k8sutil.ClusterAttr: namespace,
|
||||
"edgefs_svcname": svcname,
|
||||
"edgefs_svctype": "isgw",
|
||||
}
|
||||
}
|
||||
|
||||
// Validate the ISGW arguments
|
||||
func validateService(context *clusterd.Context, s edgefsv1alpha1.ISGW) error {
|
||||
if s.Name == "" {
|
||||
return fmt.Errorf("missing name")
|
||||
}
|
||||
if s.Namespace == "" {
|
||||
return fmt.Errorf("missing namespace")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func instanceName(svcname string) string {
|
||||
return fmt.Sprintf("%s-%s", appName, svcname)
|
||||
}
|
||||
|
||||
// Check if the ISGW service exists
|
||||
func serviceExists(context *clusterd.Context, s edgefsv1alpha1.ISGW) (bool, error) {
|
||||
_, err := context.Clientset.ExtensionsV1beta1().Deployments(s.Namespace).Get(instanceName(s.Name), metav1.GetOptions{})
|
||||
if err == nil {
|
||||
// the deployment was found
|
||||
return true, nil
|
||||
}
|
||||
if err != nil && !errors.IsNotFound(err) {
|
||||
return false, err
|
||||
}
|
||||
|
||||
// not found
|
||||
return false, nil
|
||||
}
|
||||
Reference in new issue
Block a user