liuxunorg commented on a change in pull request #129: SUBMARINE-316. Support
listen k8s event in submarine operator
URL: https://github.com/apache/submarine/pull/129#discussion_r357906534
##########
File path: submarine-cloud/pkg/apis/submarine/v1alpha1/types.go
##########
@@ -14,36 +14,209 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package v1alpha1
import (
+ "fmt"
+ kapiv1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// +genclient
-// +genclient:noStatus
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
-type SubmarineServer struct {
+// SubmarineCluster represents a Submarine Cluster
+// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
+type SubmarineCluster struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
- Spec SubmarineServerSpec `json:"spec"`
+
+ // Spec represents the desired SubmarineCluster specification
+ Spec SubmarineClusterSpec `json:"spec,omitempty"`
+
+ // Status represents the current SubmarineCluster status
+ Status SubmarineClusterStatus `json:"status,omitempty"`
}
-type SubmarineServerSpec struct {
+// SubmarineClusterList is a list of Submarine resources
+// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
+type SubmarineClusterList struct {
+ metav1.TypeMeta `json:",inline"`
+ metav1.ListMeta `json:"metadata"`
+
+ Items []SubmarineCluster `json:"items"`
+}
+
+// SubmarineClusterSpec contains SubmarineCluster specification
+type SubmarineClusterSpec struct {
+ NumberOfMaster *int32 `json:"numberOfMaster,omitempty"`
+ ReplicationFactor *int32 `json:"replicationFactor,omitempty"`
+
+ // ServiceName name used to create the Kubernetes Service that
reference the Submarine Cluster nodes.
+ // if ServiceName is empty, the SubmarineCluster.Name will be use for
creating the service.
+ ServiceName string `json:"serviceName,omitempty"`
+
+ // PodTemplate contains the pod specificaton that should run the
Submarine-server process
+ PodTemplate *kapiv1.PodTemplateSpec `json:"podTemplate,omitempty"`
+
+ // Labels for created Submarine-cluster (deployment, rs, pod) (if any)
+ AdditionalLabels map[string]string `json:"AdditionalLabels,omitempty"`
+
Name string `json:"name"`
School string `json:"school"`
Email string `json:"email"`
Address string `json:"address"`
}
-// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
+// SubmarineClusterNode represent a SubmarineCluster Node
+type SubmarineClusterNode struct {
+ ID string `json:"id"`
+ Role SubmarineClusterNodeRole `json:"role"`
+ IP string `json:"ip"`
+ Port string `json:"port"`
+ Slots []string `json:"slots,omitempty"`
+ MasterRef string `json:"masterRef,omitempty"`
+ PodName string `json:"podName"`
+ Pod *kapiv1.Pod `json:"-"`
+}
-// StudentList is a list of Student resources
-type SubmarineServerList struct {
- metav1.TypeMeta `json:",inline"`
- metav1.ListMeta `json:"metadata"`
+func (n SubmarineClusterNode) String() string {
+ if n.Role != SubmarineClusterNodeRoleSlave {
+ return fmt.Sprintf("(Master:%s, Addr:%s:%s, PodName:%s,
Slots:%v)", n.ID, n.IP, n.Port, n.PodName, n.Slots)
+ }
+ return fmt.Sprintf("(Slave:%s, Addr:%s:%s, PodName:%s, MasterRef:%s)",
n.ID, n.IP, n.Port, n.PodName, n.MasterRef)
+}
+
+// SubmarineClusterConditionType is the type of SubmarineClusterCondition
+type SubmarineClusterConditionType string
+
+const (
+ // SubmarineClusterOK means the SubmarineCluster is in a good shape
+ SubmarineClusterOK SubmarineClusterConditionType = "ClusterOK"
+
+ // SubmarineClusterScaling means the SubmarineCluster is currenlty in a
scaling stage
+ SubmarineClusterScaling SubmarineClusterConditionType = "Scaling"
+
+ // SubmarineClusterRebalancing means the SubmarineCluster is currenlty
rebalancing slots and keys
+ SubmarineClusterRebalancing SubmarineClusterConditionType =
"Rebalancing"
+
+ // SubmarineClusterRollingUpdate means the SubmarineCluster is
currenlty performing a rolling update of its nodes
+ SubmarineClusterRollingUpdate SubmarineClusterConditionType =
"RollingUpdate"
+)
+
+// SubmarineClusterNodeRole SubmarineCluster Node Role type
+type SubmarineClusterNodeRole string
- Items []SubmarineServer `json:"items"`
+const (
+ // SubmarineClusterNodeRoleMaster SubmarineCluster Master node role
+ SubmarineClusterNodeRoleMaster SubmarineClusterNodeRole = "Master"
+
+ // SubmarineClusterNodeRoleSlave SubmarineCluster Master node role
+ SubmarineClusterNodeRoleSlave SubmarineClusterNodeRole = "Slave"
+
+ // SubmarineClusterNodeRoleNone None node role
+ SubmarineClusterNodeRoleNone SubmarineClusterNodeRole = "None"
+)
+
+// ClusterStatus Submarine Cluster status
+type ClusterStatus string
+
+const (
+ // ClusterStatusOK ClusterStatus OK
+ ClusterStatusOK ClusterStatus = "OK"
+
+ // ClusterStatusKO ClusterStatus KO
+ ClusterStatusKO ClusterStatus = "KO"
Review comment:
Change to `Error`.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]