[WIP]
This commit is contained in:
@@ -72,8 +72,8 @@ func (r *ServerManagerReconciler) Reconcile(ctx context.Context, req ctrl.Reques
|
||||
}
|
||||
|
||||
pvc := r.ServerPvc(s)
|
||||
found := &corev1.PersistentVolumeClaim{}
|
||||
err = r.Get(ctx, client.ObjectKey{Namespace: pvc.Namespace, Name: pvc.Name}, found)
|
||||
found_pvc := &corev1.PersistentVolumeClaim{}
|
||||
err = r.Get(ctx, client.ObjectKey{Namespace: pvc.Namespace, Name: pvc.Name}, found_pvc)
|
||||
if err != nil {
|
||||
if errors.IsNotFound(err) {
|
||||
err = r.Create(ctx, pvc)
|
||||
@@ -97,6 +97,7 @@ func (r *ServerManagerReconciler) Reconcile(ctx context.Context, req ctrl.Reques
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
}
|
||||
|
||||
domain := r.Config.DefaultDomain
|
||||
if r.Config.DomainLabel != "" {
|
||||
node := &corev1.Node{}
|
||||
@@ -105,20 +106,33 @@ func (r *ServerManagerReconciler) Reconcile(ctx context.Context, req ctrl.Reques
|
||||
logging.Error(err, fmt.Sprintf("Failed to find node %s", found.Spec.NodeName))
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
|
||||
labelDomain, ok := node.GetLabels()[r.Config.DomainLabel]
|
||||
if ok {
|
||||
domain = labelDomain
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if domain != s.Status.Server.Domain {
|
||||
s.Status.Server.Domain = domain
|
||||
err = r.Update(ctx, s)
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
service := r.ServerService(s)
|
||||
found_service := &corev1.Service{}
|
||||
err = r.Get(ctx, client.ObjectKeyFromObject(service), found_service)
|
||||
if err != nil {
|
||||
if !errors.IsNotFound(err) {
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
err = r.Create(ctx, service)
|
||||
if err != nil {
|
||||
return ctrl.Result{}, err
|
||||
}
|
||||
}
|
||||
|
||||
return ctrl.Result{}, nil
|
||||
}
|
||||
@@ -130,8 +144,8 @@ func (r *ServerManagerReconciler) ServerService(s *servermanagerv1alpha1.ServerM
|
||||
}
|
||||
service := &corev1.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: s.Name,
|
||||
Namespce: s.Namespace,
|
||||
Name: s.Name,
|
||||
Namespace: s.Namespace,
|
||||
},
|
||||
Spec: corev1.ServiceSpec{
|
||||
Ports: ports,
|
||||
|
Reference in New Issue
Block a user