Skip to content

Commit

Permalink
[api] allow customizing configmap; add default (m3db#65)
Browse files Browse the repository at this point in the history
- Allows customizing of the configmap used by the cluster rather than
  hardcoding.
- Adds a default configmap embedded with the binary.
- Remove custom services from being embedded in the API.
- Default to EmptyDir if no PVC templates specified.
- Add node-level fields to pod ID sources.
- Add `1m:40d` preset.
- Always include pod name in ID (we depend on this for replaces)
  • Loading branch information
schallert authored Dec 11, 2018
1 parent 6cce1e2 commit c5d9853
Show file tree
Hide file tree
Showing 37 changed files with 1,103 additions and 569 deletions.
1 change: 1 addition & 0 deletions .excludemetalint
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
vendor/
generated/
pkg/client/
pkg/assets/
zz_generated
_mock.go
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ RUN cd /go/src/github.com/m3db/m3db-operator/ && \
FROM alpine:latest
LABEL maintainer="The m3db-operator Authors <[email protected]>"

COPY --from=builder /go/src/github.com/m3db/m3db-operator/out/m3db-operator /usr/local/bin/m3db-operator
COPY --from=builder /go/src/github.com/m3db/m3db-operator/out/m3db-operator /bin/m3db-operator

CMD ["/bin/sh", "-c", "/usr/local/bin/m3db-operator"]
ENTRYPOINT [ "/bin/m3db-operator" ]
9 changes: 9 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"github.com/golang/mock/gomock",
"github.com/golang/mock/mockgen",
"github.com/kubernetes/utils/pointer",
"github.com/rakyll/statik/fs",
]

[[constraint]]
Expand Down Expand Up @@ -99,3 +100,7 @@
[[override]]
name = "k8s.io/client-go"
branch = "release-7.0"

[[constraint]]
name = "github.com/rakyll/statik"
version = "0.1.5"
38 changes: 35 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,28 @@ include $(SELF_DIR)/.ci/common.mk

SHELL=/bin/bash -o pipefail

define LICENSE_HEADER
Copyright (c) 2017 Uber Technologies, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
endef

process_coverfile := .ci/codecov.sh
html_report := coverage.html
test := .ci/test-cover.sh
Expand Down Expand Up @@ -133,8 +155,15 @@ mock-gen-no-deps:
@echo generating mocks
PATH=$(retool_bin_path):$(PATH) PACKAGE=$(package_root) $(auto_gen) $(mocks_output_dir) $(mocks_rules_dir)

export LICENSE_HEADER
.PHONY: asset-gen
asset-gen:
@echo "--- $@"
@echo generating assets
PATH=$(retool_bin_path):$(PATH) statik -src $(SELF_DIR)/assets -dest $(SELF_DIR)/pkg/ -p assets -f -m -c "$$LICENSE_HEADER"

.PHONY: all-gen
all-gen: mock-gen kubernetes-gen license-gen
all-gen: mock-gen kubernetes-gen license-gen asset-gen

# Ensure base commit had up-to-date generated artifacts
.PHONY: test-all-gen
Expand Down Expand Up @@ -175,9 +204,12 @@ verify-gen: dep-ensure ## Ensure all codegen is up to date
@./hack/verify-generated.sh

.PHONY: build-bin
build-bin: out ## Build m3db-operator binary
build-bin: out dep-ensure build-bin-no-deps
@echo "--- $@"

.PHONY: build-bin-no-deps
build-bin-no-deps: ## Build m3db-operator binary
@echo "--- $@"
@which go > /dev/null || (echo "error: golang needs to be installed" && exit 1)
@echo "building $(PROJECT_NAME)..."
$(BUILD_SETTINGS) go build -o $(OUTPUT_DIR)/$(PROJECT_NAME) $(BUILD_PATH)

Expand Down
206 changes: 206 additions & 0 deletions assets/default-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
coordinator:
listenAddress:
type: "config"
value: "0.0.0.0:7201"
metrics:
scope:
prefix: "coordinator"
prometheus:
handlerPath: /metrics
listenAddress: 0.0.0.0:7203
sanitization: prometheus
samplingRate: 1.0
extended: none

db:
logging:
level: info

metrics:
prometheus:
handlerPath: /metrics
sanitization: prometheus
samplingRate: 1.0
extended: detailed

listenAddress: 0.0.0.0:9000
clusterListenAddress: 0.0.0.0:9001
httpNodeListenAddress: 0.0.0.0:9002
httpClusterListenAddress: 0.0.0.0:9003
debugListenAddress: 0.0.0.0:9004

hostID:
resolver: file
file:
path: /etc/m3db/pod-identity/identity
timeout: 5m

client:
writeConsistencyLevel: majority
readConsistencyLevel: unstrict_majority
writeTimeout: 10s
fetchTimeout: 15s
connectTimeout: 20s
writeRetry:
initialBackoff: 500ms
backoffFactor: 3
maxRetries: 2
jitter: true
fetchRetry:
initialBackoff: 500ms
backoffFactor: 2
maxRetries: 3
jitter: true
backgroundHealthCheckFailLimit: 4
backgroundHealthCheckFailThrottleFactor: 0.5

gcPercentage: 100

writeNewSeriesAsync: true
writeNewSeriesLimitPerSecond: 1048576
writeNewSeriesBackoffDuration: 2ms

bootstrap:
bootstrappers:
- filesystem
- commitlog
- peers
- uninitialized_topology
fs:
numProcessorsPerCPU: 0.125

commitlog:
flushMaxBytes: 524288
flushEvery: 1s
queue:
calculationType: fixed
size: 2097152
blockSize: 10m

fs:
filePathPrefix: /var/lib/m3db
writeBufferSize: 65536
dataReadBufferSize: 65536
infoReadBufferSize: 128
seekReadBufferSize: 4096
throughputLimitMbps: 100.0
throughputCheckEvery: 128

repair:
enabled: false
interval: 2h
offset: 30m
jitter: 1h
throttle: 2m
checkInterval: 1m

pooling:
blockAllocSize: 16
type: simple
seriesPool:
size: 262144
lowWatermark: 0.7
highWatermark: 1.0
blockPool:
size: 262144
lowWatermark: 0.7
highWatermark: 1.0
encoderPool:
size: 262144
lowWatermark: 0.7
highWatermark: 1.0
closersPool:
size: 104857
lowWatermark: 0.7
highWatermark: 1.0
contextPool:
size: 262144
lowWatermark: 0.7
highWatermark: 1.0
segmentReaderPool:
size: 16384
lowWatermark: 0.7
highWatermark: 1.0
iteratorPool:
size: 2048
lowWatermark: 0.7
highWatermark: 1.0
fetchBlockMetadataResultsPool:
size: 65536
capacity: 32
lowWatermark: 0.7
highWatermark: 1.0
fetchBlocksMetadataResultsPool:
size: 32
capacity: 4096
lowWatermark: 0.7
highWatermark: 1.0
hostBlockMetadataSlicePool:
size: 131072
capacity: 3
lowWatermark: 0.7
highWatermark: 1.0
blockMetadataPool:
size: 65536
lowWatermark: 0.7
highWatermark: 1.0
blockMetadataSlicePool:
size: 65536
capacity: 32
lowWatermark: 0.7
highWatermark: 1.0
blocksMetadataPool:
size: 65536
lowWatermark: 0.7
highWatermark: 1.0
blocksMetadataSlicePool:
size: 32
capacity: 4096
lowWatermark: 0.7
highWatermark: 1.0
identifierPool:
size: 262144
lowWatermark: 0.7
highWatermark: 1.0
bytesPool:
buckets:
- capacity: 16
size: 524288
lowWatermark: 0.7
highWatermark: 1.0
- capacity: 32
size: 262144
lowWatermark: 0.7
highWatermark: 1.0
- capacity: 64
size: 131072
lowWatermark: 0.7
highWatermark: 1.0
- capacity: 128
size: 65536
lowWatermark: 0.7
highWatermark: 1.0
- capacity: 256
size: 65536
lowWatermark: 0.7
highWatermark: 1.0
- capacity: 1440
size: 16384
lowWatermark: 0.7
highWatermark: 1.0
- capacity: 4096
size: 8192
lowWatermark: 0.7
highWatermark: 1.0
config:
service:
env: default_env
zone: embedded
service: m3db
cacheDir: /var/lib/m3kv
etcdClusters:
- zone: embedded
endpoints:
- http://etcd-0.etcd:2379
- http://etcd-1.etcd:2379
- http://etcd-2.etcd:2379
9 changes: 8 additions & 1 deletion cmd/m3db-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import (
"syscall"
"time"

// No-op import to register assets.
_ "github.com/m3db/m3db-operator/pkg/assets"
clientset "github.com/m3db/m3db-operator/pkg/client/clientset/versioned"
informers "github.com/m3db/m3db-operator/pkg/client/informers/externalversions"
"github.com/m3db/m3db-operator/pkg/controller"
Expand Down Expand Up @@ -108,6 +110,7 @@ func main() {
tags := map[string]string{
"environment": env,
}

r := promreporter.NewReporter(promreporter.Options{})
scope, closer := tally.NewRootScope(tally.ScopeOptions{
Prefix: _operatorName,
Expand Down Expand Up @@ -142,11 +145,15 @@ func main() {
stopCh := make(chan struct{})

kubeInformerFactory := kubeinformers.NewSharedInformerFactory(kubeClient, _informerSyncDuration)
nodeLister := kubeInformerFactory.Core().V1().Nodes().Lister()
m3dbClusterInformerFactory := informers.NewSharedInformerFactory(crdClient, _informerSyncDuration)

clusterLogger := logger.With(zap.String("controller", "m3db-cluster-controller"))
idLogger := logger.With(zap.String("component", "pod-identity-provider"))
idProvider, err := podidentity.NewProvider(podidentity.WithLogger(idLogger))
idProvider, err := podidentity.NewProvider(
podidentity.WithLogger(idLogger),
podidentity.WithNodeLister(nodeLister),
)
if err != nil {
logger.Fatal("failed to create ID provider", zap.Error(err))
}
Expand Down
Loading

0 comments on commit c5d9853

Please sign in to comment.