2020-08-06 04:11:40 +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-10-17 20:51:07 +00:00
|
|
|
func (r *SeaweedReconciler) createFilerHeadlessService(m *seaweedv1.Seaweed) *corev1.Service {
|
2020-08-06 04:11:40 +00:00
|
|
|
labels := labelsForFiler(m.Name)
|
|
|
|
|
|
|
|
dep := &corev1.Service{
|
|
|
|
ObjectMeta: metav1.ObjectMeta{
|
2020-10-17 20:51:07 +00:00
|
|
|
Name: m.Name + "-filer-headless",
|
2020-08-06 04:11:40 +00:00
|
|
|
Namespace: m.Namespace,
|
|
|
|
Labels: labels,
|
|
|
|
Annotations: map[string]string{
|
|
|
|
"service.alpha.kubernetes.io/tolerate-unready-endpoints": "true",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Spec: corev1.ServiceSpec{
|
|
|
|
ClusterIP: "None",
|
|
|
|
PublishNotReadyAddresses: true,
|
|
|
|
Ports: []corev1.ServicePort{
|
|
|
|
{
|
2020-10-18 07:06:40 +00:00
|
|
|
Name: "swfs-filer",
|
|
|
|
Protocol: corev1.Protocol("TCP"),
|
|
|
|
Port: 8888,
|
2020-10-18 03:52:13 +00:00
|
|
|
TargetPort: intstr.FromInt(8888),
|
2020-08-06 04:11:40 +00:00
|
|
|
},
|
|
|
|
{
|
2020-10-18 07:06:40 +00:00
|
|
|
Name: "swfs-filer-grpc",
|
|
|
|
Protocol: corev1.Protocol("TCP"),
|
|
|
|
Port: 18888,
|
2020-10-18 03:52:13 +00:00
|
|
|
TargetPort: intstr.FromInt(18888),
|
2020-08-06 04:11:40 +00:00
|
|
|
},
|
2020-10-15 04:53:09 +00:00
|
|
|
{
|
2020-10-18 07:06:40 +00:00
|
|
|
Name: "swfs-s3",
|
|
|
|
Protocol: corev1.Protocol("TCP"),
|
|
|
|
Port: 8333,
|
2020-10-18 03:52:13 +00:00
|
|
|
TargetPort: intstr.FromInt(8333),
|
2020-10-15 04:53:09 +00:00
|
|
|
},
|
2020-08-06 04:11:40 +00:00
|
|
|
},
|
|
|
|
Selector: labels,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
return dep
|
|
|
|
}
|
2020-10-17 20:51:07 +00:00
|
|
|
|
|
|
|
func (r *SeaweedReconciler) createFilerNodePortService(m *seaweedv1.Seaweed) *corev1.Service {
|
|
|
|
labels := labelsForFiler(m.Name)
|
|
|
|
|
|
|
|
dep := &corev1.Service{
|
|
|
|
ObjectMeta: metav1.ObjectMeta{
|
|
|
|
Name: m.Name + "-filer",
|
|
|
|
Namespace: m.Namespace,
|
|
|
|
Labels: labels,
|
|
|
|
Annotations: map[string]string{
|
|
|
|
"service.alpha.kubernetes.io/tolerate-unready-endpoints": "true",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Spec: corev1.ServiceSpec{
|
|
|
|
Type: corev1.ServiceTypeNodePort,
|
|
|
|
PublishNotReadyAddresses: true,
|
|
|
|
Ports: []corev1.ServicePort{
|
|
|
|
{
|
2020-10-18 07:06:40 +00:00
|
|
|
Name: "swfs-filer",
|
|
|
|
Protocol: corev1.Protocol("TCP"),
|
|
|
|
Port: 8888,
|
2020-10-18 03:52:13 +00:00
|
|
|
TargetPort: intstr.FromInt(8888),
|
2020-10-18 07:06:40 +00:00
|
|
|
NodePort: 30888,
|
2020-10-17 20:51:07 +00:00
|
|
|
},
|
|
|
|
{
|
2020-10-18 07:06:40 +00:00
|
|
|
Name: "swfs-filer-grpc",
|
|
|
|
Protocol: corev1.Protocol("TCP"),
|
|
|
|
Port: 18888,
|
2020-10-18 03:52:13 +00:00
|
|
|
TargetPort: intstr.FromInt(18888),
|
2020-10-18 07:06:40 +00:00
|
|
|
NodePort: 31888,
|
2020-10-17 20:51:07 +00:00
|
|
|
},
|
|
|
|
{
|
2020-10-18 07:06:40 +00:00
|
|
|
Name: "swfs-s3",
|
|
|
|
Protocol: corev1.Protocol("TCP"),
|
|
|
|
Port: 8333,
|
2020-10-18 03:52:13 +00:00
|
|
|
TargetPort: intstr.FromInt(8333),
|
2020-10-18 07:06:40 +00:00
|
|
|
NodePort: 30833,
|
2020-10-17 20:51:07 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Selector: labels,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
return dep
|
|
|
|
}
|