-
Notifications
You must be signed in to change notification settings - Fork 93
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
Support Deployments and StatefulSet #52
Conversation
@@ -141,6 +141,9 @@ type DruidNodeSpec struct { | |||
// Required: Port used by Druid Process | |||
DruidPort int32 `json:"druid.port"` | |||
|
|||
// Required: Define kind for node. Deployment or Statefulsets are supported | |||
Kind string `json:"kind"` |
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.
can we make it optional and default to StatefulSet
to keep things backward compatible and also to not necessarily having to specify this.
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.
sure, makes sense to have backward compatible. Ill do the changes :)
@himanshug any updates ? |
@AdheipSingh sorry, I haven't had a chance to look at it till now, will review it this week for sure. I am hoping to get some more time to spend on druid-operator in future :) |
no hurries, just wanted to check :) |
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.
Looks good overall, few small comments. Thanks
// Optional: maxSurge for deployment object | ||
MaxSurge *int32 `json:"maxSurge"` | ||
|
||
// Optional: MaxUnavailable for deployment object | ||
MaxUnavailable *int32 `json:"maxUnavailable"` | ||
|
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.
nit
// Optional: maxSurge for deployment object | |
MaxSurge *int32 `json:"maxSurge"` | |
// Optional: MaxUnavailable for deployment object | |
MaxUnavailable *int32 `json:"maxUnavailable"` | |
// Optional: maxSurge for deployment object, only applicable if kind=Deployment | |
MaxSurge *int32 `json:"maxSurge"` | |
// Optional: MaxUnavailable for deployment object, only applicable if kind=Deployment | |
MaxUnavailable *int32 `json:"maxUnavailable"` | |
pkg/controller/druid/handler.go
Outdated
// Check StatefulSet rolling update status, if in-progress then stop here | ||
done, err := isStsFullyDeployed(sdk, nodeSpecUniqueStr, m) | ||
if !done { | ||
if nodeSpec.Kind == "Deployment" { |
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.
two "if" clause above should be combined as ...
if nodeSpec.Kind == "Deployment" {
// do stuff for Deployment
} else {
// do stuff for StatefulSet
}
sendEvent(sdk, drd, v1.EventTypeWarning, "GET_FAIL", e.Error()) | ||
return false, e | ||
} else { | ||
if deploy.Status.ReadyReplicas != deploy.Status.Replicas { |
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.
have you tested same concept works for Deployment resource? what I wrote for StatefulSet in isStsFullyDeployed(..)
was only tested for sts.
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.
yes, i have been running this in my cluster, this is checking if desired replicas have come back in ready state. Behaves same as sts during upgrades.
pkg/controller/druid/handler.go
Outdated
@@ -560,31 +617,43 @@ func getServiceName(nameTemplate, nodeSpecUniqueStr string) string { | |||
} | |||
} | |||
|
|||
func makeStatefulSet(nodeSpec *v1alpha1.DruidNodeSpec, m *v1alpha1.Druid, ls map[string]string, nodeSpecUniqueStr, configMapSHA, serviceName string) (*appsv1.StatefulSet, error) { | |||
templateHolder := []v1.PersistentVolumeClaim{} | |||
func templateHolder(nodeSpec *v1alpha1.DruidNodeSpec, m *v1alpha1.Druid) []v1.PersistentVolumeClaim { |
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.
nit: like other similar methods, this could be a getXxx
func templateHolder(nodeSpec *v1alpha1.DruidNodeSpec, m *v1alpha1.Druid) []v1.PersistentVolumeClaim { | |
func getPersistentVolumeClaims(nodeSpec *v1alpha1.DruidNodeSpec, m *v1alpha1.Druid) []v1.PersistentVolumeClaim { |
pkg/controller/druid/handler.go
Outdated
volumeMountHolder := []v1.VolumeMount{ | ||
} | ||
|
||
func volumeMountHolder(nodeSpec *v1alpha1.DruidNodeSpec, m *v1alpha1.Druid) []v1.VolumeMount { |
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.
nit: like other similar methods, this could be a getXxx
func volumeMountHolder(nodeSpec *v1alpha1.DruidNodeSpec, m *v1alpha1.Druid) []v1.VolumeMount { | |
func getVolumeMounts(nodeSpec *v1alpha1.DruidNodeSpec, m *v1alpha1.Druid) []v1.VolumeMount { |
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.
LGTM, 👍
pkg/controller/druid/handler.go
Outdated
done, err := isStsFullyDeployed(sdk, nodeSpecUniqueStr, m) | ||
if !done { | ||
// Check Deployment rolling update status, if in-progress then stop here | ||
done, err := isDeployFullyDeployed(sdk, nodeSpecUniqueStr, m) |
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.
nit: rename to isDeploymentFullyDeployed
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.
done
Fixes #49 .
Description
NodeSpec
have added a keykind
which can take inputs for deployments or statefulsets.Required
param and is validated by the operator.makeStatefulSet
func has been split up so that the underlyingpodSpec
remains common. Hence less code to maintain, plus in case we add more features to the podSpec it remains common to both deployments and statefulsets.This PR has:
Key changed/added files in this PR
types.go
handler.go
tiny-cluster.yaml