[WIP]
This commit is contained in:
parent
ae058f92e6
commit
d83bc3368a
@ -166,6 +166,16 @@ func (in *ServerManagerStatus) DeepCopy() *ServerManagerStatus {
|
|||||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
func (in *ServerSpec) DeepCopyInto(out *ServerSpec) {
|
func (in *ServerSpec) DeepCopyInto(out *ServerSpec) {
|
||||||
*out = *in
|
*out = *in
|
||||||
|
if in.Command != nil {
|
||||||
|
in, out := &in.Command, &out.Command
|
||||||
|
*out = make([]string, len(*in))
|
||||||
|
copy(*out, *in)
|
||||||
|
}
|
||||||
|
if in.Args != nil {
|
||||||
|
in, out := &in.Args, &out.Args
|
||||||
|
*out = make([]string, len(*in))
|
||||||
|
copy(*out, *in)
|
||||||
|
}
|
||||||
if in.Ports != nil {
|
if in.Ports != nil {
|
||||||
in, out := &in.Ports, &out.Ports
|
in, out := &in.Ports, &out.Ports
|
||||||
*out = make([]Port, len(*in))
|
*out = make([]Port, len(*in))
|
||||||
|
@ -72,8 +72,8 @@ func (r *ServerManagerReconciler) Reconcile(ctx context.Context, req ctrl.Reques
|
|||||||
}
|
}
|
||||||
|
|
||||||
pvc := r.ServerPvc(s)
|
pvc := r.ServerPvc(s)
|
||||||
found := &corev1.PersistentVolumeClaim{}
|
found_pvc := &corev1.PersistentVolumeClaim{}
|
||||||
err = r.Get(ctx, client.ObjectKey{Namespace: pvc.Namespace, Name: pvc.Name}, found)
|
err = r.Get(ctx, client.ObjectKey{Namespace: pvc.Namespace, Name: pvc.Name}, found_pvc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.IsNotFound(err) {
|
if errors.IsNotFound(err) {
|
||||||
err = r.Create(ctx, pvc)
|
err = r.Create(ctx, pvc)
|
||||||
@ -97,6 +97,7 @@ func (r *ServerManagerReconciler) Reconcile(ctx context.Context, req ctrl.Reques
|
|||||||
return ctrl.Result{}, err
|
return ctrl.Result{}, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
domain := r.Config.DefaultDomain
|
domain := r.Config.DefaultDomain
|
||||||
if r.Config.DomainLabel != "" {
|
if r.Config.DomainLabel != "" {
|
||||||
node := &corev1.Node{}
|
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))
|
logging.Error(err, fmt.Sprintf("Failed to find node %s", found.Spec.NodeName))
|
||||||
return ctrl.Result{}, err
|
return ctrl.Result{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
labelDomain, ok := node.GetLabels()[r.Config.DomainLabel]
|
labelDomain, ok := node.GetLabels()[r.Config.DomainLabel]
|
||||||
if ok {
|
if ok {
|
||||||
domain = labelDomain
|
domain = labelDomain
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if domain != s.Status.Server.Domain {
|
if domain != s.Status.Server.Domain {
|
||||||
s.Status.Server.Domain = domain
|
s.Status.Server.Domain = domain
|
||||||
err = r.Update(ctx, s)
|
err = r.Update(ctx, s)
|
||||||
return ctrl.Result{}, err
|
return ctrl.Result{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
service := r.ServerService(s)
|
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
|
return ctrl.Result{}, nil
|
||||||
}
|
}
|
||||||
@ -131,7 +145,7 @@ func (r *ServerManagerReconciler) ServerService(s *servermanagerv1alpha1.ServerM
|
|||||||
service := &corev1.Service{
|
service := &corev1.Service{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: s.Name,
|
Name: s.Name,
|
||||||
Namespce: s.Namespace,
|
Namespace: s.Namespace,
|
||||||
},
|
},
|
||||||
Spec: corev1.ServiceSpec{
|
Spec: corev1.ServiceSpec{
|
||||||
Ports: ports,
|
Ports: ports,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user