2020-08-02 06:27:46 +00:00
|
|
|
package controllers
|
|
|
|
|
|
|
|
import (
|
|
|
|
corev1 "k8s.io/api/core/v1"
|
|
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
|
|
"k8s.io/apimachinery/pkg/util/intstr"
|
|
|
|
|
|
|
|
seaweedv1 "github.com/seaweedfs/seaweedfs-operator/api/v1"
|
|
|
|
)
|
|
|
|
|
2020-08-02 23:12:52 +00:00
|
|
|
func (r *SeaweedReconciler) createMasterService(m *seaweedv1.Seaweed) *corev1.Service {
|
2020-08-02 06:27:46 +00:00
|
|
|
labels := labelsForMaster(m.Name)
|
|
|
|
|
|
|
|
dep := &corev1.Service{
|
|
|
|
ObjectMeta: metav1.ObjectMeta{
|
2020-08-02 23:12:52 +00:00
|
|
|
Name: m.Name + "-master",
|
2020-08-02 06:27:46 +00:00
|
|
|
Namespace: m.Namespace,
|
2020-08-02 23:12:52 +00:00
|
|
|
Labels: labels,
|
|
|
|
Annotations: map[string]string{
|
|
|
|
"service.alpha.kubernetes.io/tolerate-unready-endpoints": "true",
|
|
|
|
},
|
2020-08-02 06:27:46 +00:00
|
|
|
},
|
|
|
|
Spec: corev1.ServiceSpec{
|
2020-08-02 23:12:52 +00:00
|
|
|
ClusterIP: "None",
|
|
|
|
PublishNotReadyAddresses: true,
|
2020-08-02 06:27:46 +00:00
|
|
|
Ports: []corev1.ServicePort{
|
|
|
|
{
|
2020-10-18 07:06:40 +00:00
|
|
|
Name: "swfs-master",
|
|
|
|
Protocol: corev1.Protocol("TCP"),
|
2020-10-28 06:57:38 +00:00
|
|
|
Port: seaweedv1.MasterHTTPPort,
|
|
|
|
TargetPort: intstr.FromInt(seaweedv1.MasterHTTPPort),
|
2020-08-02 06:27:46 +00:00
|
|
|
},
|
|
|
|
{
|
2020-10-18 07:06:40 +00:00
|
|
|
Name: "swfs-master-grpc",
|
|
|
|
Protocol: corev1.Protocol("TCP"),
|
2020-10-28 06:57:38 +00:00
|
|
|
Port: seaweedv1.MasterGRPCPort,
|
|
|
|
TargetPort: intstr.FromInt(seaweedv1.MasterGRPCPort),
|
2020-08-02 06:27:46 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Selector: labels,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
// Set master instance as the owner and controller
|
|
|
|
// ctrl.SetControllerReference(m, dep, r.Scheme)
|
|
|
|
return dep
|
|
|
|
}
|