-
Notifications
You must be signed in to change notification settings - Fork 2
feat: Add Tenant and Warehouse CRD. #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b1b633d
f4be058
1f182be
4de99a1
0afffcd
bbabe7c
4bb72e2
cfe3498
4c259eb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,29 +17,137 @@ limitations under the License. | |
| package v1alpha1 | ||
|
|
||
| import ( | ||
| corev1 "k8s.io/api/core/v1" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| ) | ||
|
|
||
| // EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! | ||
| // NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. | ||
|
|
||
| type UserAuthType string | ||
|
|
||
| const ( | ||
| MD5 UserAuthType = "md5" | ||
| NoPassword UserAuthType = "no_password" | ||
| ) | ||
|
|
||
| type Storage struct { | ||
| // Specification of S3 storage. | ||
| S3 *S3Storage `json:"s3,omitempty"` | ||
| } | ||
|
|
||
| type S3Storage struct { | ||
| // Authentication configuration of S3 storage. | ||
| S3Auth `json:",inline"` | ||
|
|
||
| // Whether to allow insecure connections to S3 storage. | ||
| // If set to true, users can establish HTTP connections to S3 storage. | ||
| // Otherwise, only HTTPS connections are allowed. Default to true. | ||
| // +kubebuilder:default=true | ||
| AllowInsecure bool `json:"allowInsecure,omitempty"` | ||
|
|
||
| // Root path of S3. | ||
| RootPath string `json:"rootPath,omitempty"` | ||
|
|
||
| // Name of S3 bucket. | ||
| BucketName string `json:"bucketName,omitempty"` | ||
|
|
||
| // Region of S3 storage. | ||
| Region string `json:"region,omitempty"` | ||
|
|
||
| // Endpoint of S3 storage. | ||
| Endpoint string `json:"endpoint,omitempty"` | ||
| } | ||
|
|
||
| type S3Auth struct { | ||
| // Secret Access Key of S3 storage. | ||
| SecretKey string `json:"secretKey,omitempty"` | ||
|
|
||
| // Access Key ID of S3 storage. | ||
| AccessKey string `json:"accessKey,omitempty"` | ||
|
|
||
| // Reference to the secret with SerectKey and AccessKey to S3 storage. | ||
| // Secret can be created in any namespace. | ||
| SecretRef *corev1.ObjectReference `json:"secretRef,omitempty"` | ||
| } | ||
|
|
||
| type MetaConfig struct { | ||
| // Authentication configurations to connect to Meta cluster. | ||
| MetaAuth `json:",inline"` | ||
|
|
||
| // Exposed endpoints of Meta cluster (must list all pod endpoints in the Meta cluster). | ||
| Endpoints []string `json:"endpoints,omitempty"` | ||
|
|
||
| // Timeout seconds of connections to Meta cluster. | ||
| // +kubebuilder:default=3 | ||
| TimeoutInSeconds int `json:"timeoutInSecond,omitempty"` | ||
|
|
||
| // Interval for warehouse to sync data from Meta cluster. | ||
| // +kubebuilder:default=60 | ||
| AutoSyncInterval int `json:"autoSyncInterval,omitempty"` | ||
| } | ||
|
|
||
| type MetaAuth struct { | ||
| // User of Meta cluster. | ||
| User string `json:"user,omitempty"` | ||
|
|
||
| // Password of Meta cluster. | ||
| Password string `json:"password,omitempty"` | ||
|
|
||
| // Reference to the secret with User and Password to Meta cluster. | ||
| // Secret can be created in any namespace. | ||
| PasswordSecretRef *corev1.ObjectReference `json:"passwordSecretRef,omitempty"` | ||
| } | ||
|
|
||
| type User struct { | ||
| // Name of warehouse user. | ||
| Name string `json:"name,omitempty"` | ||
|
|
||
| // Authentication type of warehouse password. | ||
| // Currently we support: md5, no_password. | ||
| // +kubebuilder:default="no_password" | ||
| AuthType UserAuthType `json:"authType,omitempty"` | ||
|
|
||
| // Password encrypted with AuthType. | ||
| AuthString string `json:"authString,omitempty"` | ||
|
Comment on lines
+111
to
+112
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was wondering, whether we need to add a field named There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i feel having a reference to secret is nice, might be like support both of styles:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think so. What about maintaining consistency with S3 and Meta configs? I think it would be better if we add a new field named There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
looks good to me 👍 |
||
|
|
||
| // Reference to the secret with AuthString of user. | ||
| // Secret can be created in any namespace. | ||
| AuthStringSecretRef *corev1.ObjectReference `json:"authStringSecretRef,omitempty"` | ||
| } | ||
|
|
||
| // TenantSpec defines the desired state of Tenant. | ||
| type TenantSpec struct { | ||
| // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster | ||
| // Important: Run "make" to regenerate code after modifying this file | ||
| // Object storage specifications. Currently we only support S3. | ||
| Storage `json:",inline"` | ||
|
|
||
| // Configurations to open connections to a Meta cluster. | ||
| Meta MetaConfig `json:"meta,omitempty"` | ||
|
|
||
| // Foo is an example field of Tenant. Edit tenant_types.go to remove/update | ||
| Foo string `json:"foo,omitempty"` | ||
| // Built-in users in the warehouse created by this tenant. | ||
| // If not set, we'll create "admin" user with password "admin". | ||
| // +listType=map | ||
| // +listMapKey=name | ||
| BuiltinUsers []User `json:"builtinUsers,omitempty"` | ||
| } | ||
|
|
||
| // TenantStatus defines the observed state of Tenant. | ||
| type TenantStatus struct { | ||
| // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster | ||
| // Important: Run "make" to regenerate code after modifying this file | ||
| // Conditions for the Tenant. | ||
| // +listType=map | ||
| // +listMapKey=type | ||
| // +patchStrategy=merge | ||
| // +patchMergeKey=type | ||
| Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"` | ||
| } | ||
|
|
||
| // +kubebuilder:object:root=true | ||
| // +kubebuilder:subresource:status | ||
| // +kubebuilder:printcolumn:name="State",type=string,JSONPath=`.status.conditions[-1:].type` | ||
| // +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp` | ||
| // +genclient | ||
| // +k8s:openapi-gen=true | ||
| // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
|
||
| // Tenant is the Schema for the tenants API. | ||
| type Tenant struct { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add an optional for the endpoint? when you're using s3, endpoint is not an required parameter in most of the time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's optional now, since I added
omitemptytag after the field.