Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tentative support for an external controlling coordinator #208

Merged
merged 3 commits into from
Apr 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ ClusterSpec defines the desired state for a M3 cluster to be converge to.
| nodeEndpointFormat | NodeEndpointFormat allows overriding of the endpoint used for a node in the M3DB placement. Defaults to \"{{ .PodName }}.{{ .M3DBService }}:{{ .Port }}\". Useful if access to the cluster from other namespaces is desired. See \"Node Endpoint\" docs for full variables available. | string | false |
| hostNetwork | HostNetwork indicates whether M3DB pods should run in the same network namespace as the node its on. This option should be used sparingly due to security concerns outlined in the linked documentation. https://kubernetes.io/docs/concepts/policy/pod-security-policy/#host-namespaces | bool | false |
| dnsPolicy | DNSPolicy allows the user to set the pod's DNSPolicy. This is often used in conjunction with HostNetwork.+optional | *corev1.DNSPolicy | false |
| externalCoordinatorSelector | Specify a \"controlling\" coordinator for the cluster It is expected that there is a separate standalone coordinator cluster It is externally managed - not managed by this operator It is expected to have a service endpoint Setup this db cluster, but do not assume a co-located coordinator Instead provide a selector here so we can point to a separate coordinator service Specify here the labels required for the selector | map[string]string | false |

[Back to TOC](#table-of-contents)

Expand Down
9 changes: 9 additions & 0 deletions pkg/apis/m3dboperator/v1alpha1/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,15 @@ type ClusterSpec struct {
// conjunction with HostNetwork.+optional
// +optional
DNSPolicy *corev1.DNSPolicy `json:"dnsPolicy,omitEmpty"`

// Specify a "controlling" coordinator for the cluster
// It is expected that there is a separate standalone coordinator cluster
// It is externally managed - not managed by this operator
// It is expected to have a service endpoint
// Setup this db cluster, but do not assume a co-located coordinator
// Instead provide a selector here so we can point to a separate coordinator service
// Specify here the labels required for the selector
ExternalCoordinatorSelector map[string]string `json:"externalCoordinatorSelector,omitempty"`
}

// NodeAffinityTerm represents a node label and a set of label values, any of
Expand Down
3 changes: 3 additions & 0 deletions pkg/k8sops/m3db/generators.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ func GenerateCoordinatorService(cluster *myspec.M3DBCluster) (*v1.Service, error

selectorLabels := labels.BaseLabels(cluster)
selectorLabels[labels.Component] = labels.ComponentM3DBNode
if len(cluster.Spec.ExternalCoordinatorSelector) > 0 {
selectorLabels = cluster.Spec.ExternalCoordinatorSelector
}

serviceLabels := labels.BaseLabels(cluster)
serviceLabels[labels.Component] = labels.ComponentCoordinator
Expand Down
6 changes: 6 additions & 0 deletions pkg/k8sops/m3db/generators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,4 +542,10 @@ func TestGenerateCoordinatorService(t *testing.T) {
}

assert.Equal(t, expSvc, svc)

cluster.Spec.ExternalCoordinatorSelector = map[string]string{"foo": "bar"}
expSvc.Spec.Selector = map[string]string{"foo": "bar"}
svc, err = GenerateCoordinatorService(cluster)
assert.NoError(t, err)
assert.Equal(t, expSvc, svc)
}