support upgrade
This commit is contained in:
parent
4ea680c4c9
commit
4bb6f99cd8
|
@ -31,6 +31,9 @@ type SeaweedSpec struct {
|
||||||
// MetricsAddress is Prometheus gateway address
|
// MetricsAddress is Prometheus gateway address
|
||||||
MetricsAddress string `json:"metricsAddress,omitempty"`
|
MetricsAddress string `json:"metricsAddress,omitempty"`
|
||||||
|
|
||||||
|
// Image
|
||||||
|
Image string `json:"image,omitempty"`
|
||||||
|
|
||||||
// VolumeServerCount is the number of volume servers, default to 1
|
// VolumeServerCount is the number of volume servers, default to 1
|
||||||
VolumeServerCount int32 `json:"volumeServerCount,omitempty"`
|
VolumeServerCount int32 `json:"volumeServerCount,omitempty"`
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,9 @@ spec:
|
||||||
description: FilerCount is the number of filers, default to 1
|
description: FilerCount is the number of filers, default to 1
|
||||||
format: int32
|
format: int32
|
||||||
type: integer
|
type: integer
|
||||||
|
image:
|
||||||
|
description: Image
|
||||||
|
type: string
|
||||||
metricsAddress:
|
metricsAddress:
|
||||||
description: MetricsAddress is Prometheus gateway address
|
description: MetricsAddress is Prometheus gateway address
|
||||||
type: string
|
type: string
|
||||||
|
|
|
@ -4,5 +4,6 @@ metadata:
|
||||||
name: seaweed1
|
name: seaweed1
|
||||||
spec:
|
spec:
|
||||||
# Add fields here
|
# Add fields here
|
||||||
|
image: chrislusf/seaweedfs:2.03
|
||||||
volumeServerCount: 4
|
volumeServerCount: 4
|
||||||
filerCount: 2
|
filerCount: 2
|
||||||
|
|
|
@ -49,8 +49,10 @@ func (r *SeaweedReconciler) ensureFilerStatefulSet(seaweedCR *seaweedv1.Seaweed)
|
||||||
return ReconcileResult(err)
|
return ReconcileResult(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if *filerStatefulSet.Spec.Replicas != seaweedCR.Spec.FilerCount {
|
if *filerStatefulSet.Spec.Replicas != seaweedCR.Spec.FilerCount ||
|
||||||
|
filerStatefulSet.Spec.Template.Spec.Containers[0].Image != seaweedCR.Spec.Image {
|
||||||
filerStatefulSet.Spec.Replicas = &seaweedCR.Spec.FilerCount
|
filerStatefulSet.Spec.Replicas = &seaweedCR.Spec.FilerCount
|
||||||
|
filerStatefulSet.Spec.Template.Spec.Containers[0].Image = seaweedCR.Spec.Image
|
||||||
if err = r.Update(ctx, filerStatefulSet); err != nil {
|
if err = r.Update(ctx, filerStatefulSet); err != nil {
|
||||||
log.Error(err, "Failed to update filer statefulset", "Namespace", filerStatefulSet.Namespace, "Name", filerStatefulSet.Name)
|
log.Error(err, "Failed to update filer statefulset", "Namespace", filerStatefulSet.Namespace, "Name", filerStatefulSet.Name)
|
||||||
return ReconcileResult(err)
|
return ReconcileResult(err)
|
||||||
|
|
|
@ -42,7 +42,7 @@ func (r *SeaweedReconciler) createFilerStatefulSet(m *seaweedv1.Seaweed) *appsv1
|
||||||
EnableServiceLinks: &enableServiceLinks,
|
EnableServiceLinks: &enableServiceLinks,
|
||||||
Containers: []corev1.Container{{
|
Containers: []corev1.Container{{
|
||||||
Name: "seaweedfs",
|
Name: "seaweedfs",
|
||||||
Image: "chrislusf/seaweedfs:latest",
|
Image: m.Spec.Image,
|
||||||
ImagePullPolicy: corev1.PullIfNotPresent,
|
ImagePullPolicy: corev1.PullIfNotPresent,
|
||||||
Env: []corev1.EnvVar{
|
Env: []corev1.EnvVar{
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,7 +44,7 @@ func (r *SeaweedReconciler) ensureMasterStatefulSet(seaweedCR *seaweedv1.Seaweed
|
||||||
log.Info("Creating a new master statefulset", "Namespace", dep.Namespace, "Name", dep.Name)
|
log.Info("Creating a new master statefulset", "Namespace", dep.Namespace, "Name", dep.Name)
|
||||||
err = r.Create(ctx, dep)
|
err = r.Create(ctx, dep)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err, "Failed to create new statefulset", "Namespace", dep.Namespace, "Name", dep.Name)
|
log.Error(err, "Failed to create master statefulset", "Namespace", dep.Namespace, "Name", dep.Name)
|
||||||
return ReconcileResult(err)
|
return ReconcileResult(err)
|
||||||
}
|
}
|
||||||
// sleep 60 seconds for DNS to have pod IP addresses ready
|
// sleep 60 seconds for DNS to have pod IP addresses ready
|
||||||
|
@ -55,6 +55,18 @@ func (r *SeaweedReconciler) ensureMasterStatefulSet(seaweedCR *seaweedv1.Seaweed
|
||||||
log.Error(err, "Failed to get Deployment")
|
log.Error(err, "Failed to get Deployment")
|
||||||
return ReconcileResult(err)
|
return ReconcileResult(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Info("master version " + masterStatefulSet.Spec.Template.Spec.Containers[0].Image + " expected " + seaweedCR.Spec.Image)
|
||||||
|
if masterStatefulSet.Spec.Template.Spec.Containers[0].Image != seaweedCR.Spec.Image {
|
||||||
|
masterStatefulSet.Spec.Template.Spec.Containers[0].Image = seaweedCR.Spec.Image
|
||||||
|
if err = r.Update(ctx, masterStatefulSet); err != nil {
|
||||||
|
log.Error(err, "Failed to update master statefulset", "Namespace", masterStatefulSet.Namespace, "Name", masterStatefulSet.Name)
|
||||||
|
return ReconcileResult(err)
|
||||||
|
}
|
||||||
|
// Deployment created successfully - return and requeue
|
||||||
|
return ReconcileResult(err)
|
||||||
|
}
|
||||||
|
|
||||||
log.Info("Get master stateful set " + masterStatefulSet.Name)
|
log.Info("Get master stateful set " + masterStatefulSet.Name)
|
||||||
return ReconcileResult(err)
|
return ReconcileResult(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ func (r *SeaweedReconciler) createMasterStatefulSet(m *seaweedv1.Seaweed) *appsv
|
||||||
EnableServiceLinks: &enableServiceLinks,
|
EnableServiceLinks: &enableServiceLinks,
|
||||||
Containers: []corev1.Container{{
|
Containers: []corev1.Container{{
|
||||||
Name: "seaweedfs",
|
Name: "seaweedfs",
|
||||||
Image: "chrislusf/seaweedfs:latest",
|
Image: m.Spec.Image,
|
||||||
ImagePullPolicy: corev1.PullIfNotPresent,
|
ImagePullPolicy: corev1.PullIfNotPresent,
|
||||||
Env: []corev1.EnvVar{
|
Env: []corev1.EnvVar{
|
||||||
{
|
{
|
||||||
|
|
|
@ -49,8 +49,10 @@ func (r *SeaweedReconciler) ensureVolumeServerStatefulSet(seaweedCR *seaweedv1.S
|
||||||
return ReconcileResult(err)
|
return ReconcileResult(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if *volumeServerStatefulSet.Spec.Replicas != seaweedCR.Spec.VolumeServerCount {
|
if *volumeServerStatefulSet.Spec.Replicas != seaweedCR.Spec.VolumeServerCount ||
|
||||||
|
volumeServerStatefulSet.Spec.Template.Spec.Containers[0].Image != seaweedCR.Spec.Image {
|
||||||
volumeServerStatefulSet.Spec.Replicas = &seaweedCR.Spec.VolumeServerCount
|
volumeServerStatefulSet.Spec.Replicas = &seaweedCR.Spec.VolumeServerCount
|
||||||
|
volumeServerStatefulSet.Spec.Template.Spec.Containers[0].Image = seaweedCR.Spec.Image
|
||||||
if err = r.Update(ctx, volumeServerStatefulSet); err != nil {
|
if err = r.Update(ctx, volumeServerStatefulSet); err != nil {
|
||||||
log.Error(err, "Failed to update volume statefulset", "Namespace", volumeServerStatefulSet.Namespace, "Name", volumeServerStatefulSet.Name)
|
log.Error(err, "Failed to update volume statefulset", "Namespace", volumeServerStatefulSet.Namespace, "Name", volumeServerStatefulSet.Name)
|
||||||
return ReconcileResult(err)
|
return ReconcileResult(err)
|
||||||
|
|
|
@ -42,7 +42,7 @@ func (r *SeaweedReconciler) createVolumeServerStatefulSet(m *seaweedv1.Seaweed)
|
||||||
EnableServiceLinks: &enableServiceLinks,
|
EnableServiceLinks: &enableServiceLinks,
|
||||||
Containers: []corev1.Container{{
|
Containers: []corev1.Container{{
|
||||||
Name: "seaweedfs",
|
Name: "seaweedfs",
|
||||||
Image: "chrislusf/seaweedfs:latest",
|
Image: m.Spec.Image,
|
||||||
ImagePullPolicy: corev1.PullIfNotPresent,
|
ImagePullPolicy: corev1.PullIfNotPresent,
|
||||||
Env: []corev1.EnvVar{
|
Env: []corev1.EnvVar{
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue