forked from apache/cloudstack
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathKubernetesCluster.java
More file actions
170 lines (146 loc) · 7.91 KB
/
KubernetesCluster.java
File metadata and controls
170 lines (146 loc) · 7.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you 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 com.cloud.kubernetes.cluster;
import java.util.Date;
import org.apache.cloudstack.acl.ControlledEntity;
import org.apache.cloudstack.api.Displayable;
import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;
import com.cloud.utils.fsm.StateMachine2;
/**
* KubernetesCluster describes the properties of a Kubernetes cluster
* StateMachine maintains its states.
*
*/
public interface KubernetesCluster extends ControlledEntity, com.cloud.utils.fsm.StateObject<KubernetesCluster.State>, Identity, InternalIdentity, Displayable {
enum ClusterType {
CloudManaged, ExternalManaged;
};
enum Event {
StartRequested,
StopRequested,
DestroyRequested,
RecoveryRequested,
AutoscaleRequested,
ScaleUpRequested,
ScaleDownRequested,
AddNodeRequested,
RemoveNodeRequested,
UpgradeRequested,
OperationSucceeded,
OperationFailed,
CreateFailed,
FaultsDetected;
}
enum State {
Created("Initial State of Kubernetes cluster. At this state its just a logical/DB entry with no resources consumed"),
Starting("Resources needed for Kubernetes cluster are being provisioned"),
Running("Necessary resources are provisioned and Kubernetes cluster is in operational ready state to launch Kubernetes"),
Stopping("Resources for the Kubernetes cluster are being destroyed"),
Stopped("All resources for the Kubernetes cluster are destroyed, Kubernetes cluster may still have ephemeral resource like persistent volumes provisioned"),
Scaling("Transient state in which resources are either getting scaled up/down"),
Upgrading("Transient state in which cluster is getting upgraded"),
Importing("Transient state in which additional nodes are added as worker nodes to a cluster"),
RemovingNodes("Transient state in which additional nodes are removed from a cluster"),
Alert("State to represent Kubernetes clusters which are not in expected desired state (operationally in active control place, stopped cluster VM's etc)."),
Recovering("State in which Kubernetes cluster is recovering from alert state"),
Destroyed("End state of Kubernetes cluster in which all resources are destroyed, cluster will not be usable further"),
Destroying("State in which resources for the Kubernetes cluster is getting cleaned up or yet to be cleaned up by garbage collector"),
Error("State of the failed to create Kubernetes clusters");
protected static final StateMachine2<State, KubernetesCluster.Event, KubernetesCluster> s_fsm = new StateMachine2<State, KubernetesCluster.Event, KubernetesCluster>();
public static StateMachine2<State, KubernetesCluster.Event, KubernetesCluster> getStateMachine() { return s_fsm; }
static {
s_fsm.addTransition(State.Created, Event.StartRequested, State.Starting);
s_fsm.addTransition(State.Starting, Event.OperationSucceeded, State.Running);
s_fsm.addTransition(State.Starting, Event.OperationFailed, State.Alert);
s_fsm.addTransition(State.Starting, Event.CreateFailed, State.Error);
s_fsm.addTransition(State.Starting, Event.StopRequested, State.Stopping);
s_fsm.addTransition(State.Running, Event.StopRequested, State.Stopping);
s_fsm.addTransition(State.Alert, Event.StopRequested, State.Stopping);
s_fsm.addTransition(State.Stopping, Event.OperationSucceeded, State.Stopped);
s_fsm.addTransition(State.Stopping, Event.OperationFailed, State.Alert);
s_fsm.addTransition(State.Stopped, Event.StartRequested, State.Starting);
s_fsm.addTransition(State.Running, Event.FaultsDetected, State.Alert);
s_fsm.addTransition(State.Running, Event.AutoscaleRequested, State.Scaling);
s_fsm.addTransition(State.Running, Event.ScaleUpRequested, State.Scaling);
s_fsm.addTransition(State.Running, Event.ScaleDownRequested, State.Scaling);
s_fsm.addTransition(State.Scaling, Event.OperationSucceeded, State.Running);
s_fsm.addTransition(State.Scaling, Event.OperationFailed, State.Alert);
s_fsm.addTransition(State.Running, Event.UpgradeRequested, State.Upgrading);
s_fsm.addTransition(State.Upgrading, Event.OperationSucceeded, State.Running);
s_fsm.addTransition(State.Upgrading, Event.OperationFailed, State.Alert);
s_fsm.addTransition(State.Running, Event.AddNodeRequested, State.Importing);
s_fsm.addTransition(State.Alert, Event.AddNodeRequested, State.Importing);
s_fsm.addTransition(State.Importing, Event.OperationSucceeded, State.Running);
s_fsm.addTransition(State.Importing, Event.OperationFailed, State.Running);
s_fsm.addTransition(State.Alert, Event.OperationSucceeded, State.Running);
s_fsm.addTransition(State.Running, Event.RemoveNodeRequested, State.RemovingNodes);
s_fsm.addTransition(State.Alert, Event.RemoveNodeRequested, State.RemovingNodes);
s_fsm.addTransition(State.RemovingNodes, Event.OperationSucceeded, State.Running);
s_fsm.addTransition(State.RemovingNodes, Event.OperationFailed, State.Running);
s_fsm.addTransition(State.Alert, Event.RecoveryRequested, State.Recovering);
s_fsm.addTransition(State.Recovering, Event.OperationSucceeded, State.Running);
s_fsm.addTransition(State.Recovering, Event.OperationFailed, State.Alert);
s_fsm.addTransition(State.Running, Event.DestroyRequested, State.Destroying);
s_fsm.addTransition(State.Stopped, Event.DestroyRequested, State.Destroying);
s_fsm.addTransition(State.Alert, Event.DestroyRequested, State.Destroying);
s_fsm.addTransition(State.Error, Event.DestroyRequested, State.Destroying);
s_fsm.addTransition(State.Destroying, Event.OperationSucceeded, State.Destroyed);
}
String _description;
State(String description) {
_description = description;
}
}
long getId();
String getName();
String getDescription();
long getZoneId();
Long getKubernetesVersionId();
Long getServiceOfferingId();
Long getTemplateId();
Long getNetworkId();
long getDomainId();
long getAccountId();
long getControlNodeCount();
long getNodeCount();
long getTotalNodeCount();
String getKeyPair();
long getCores();
long getMemory();
long getNodeRootDiskSize();
String getEndpoint();
boolean isCheckForGc();
@Override
State getState();
Date getCreated();
boolean getAutoscalingEnabled();
Long getMinSize();
Long getMaxSize();
Long getSecurityGroupId();
ClusterType getClusterType();
Long getControlNodeServiceOfferingId();
Long getWorkerNodeServiceOfferingId();
Long getEtcdNodeServiceOfferingId();
Long getControlNodeTemplateId();
Long getWorkerNodeTemplateId();
Long getEtcdNodeTemplateId();
Long getEtcdNodeCount();
Long getCniConfigId();
String getCniConfigDetails();
boolean isCsiEnabled();
}