Skip to content

Commit

Permalink
Merge pull request #27 from qmhu/disable-le
Browse files Browse the repository at this point in the history
Disable leader elect
  • Loading branch information
qmhu authored Oct 21, 2022
2 parents ea59b5d + 6a0ef44 commit 35e39cd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
11 changes: 7 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ ARG PKGNAME

# Build the manager binary
FROM golang:1.17.2-alpine as builder
ENV GOPROXY https://proxy.golang.org,direct
ENV GOSUMDB sum.golang.org

ARG LDFLAGS
ARG PKGNAME
Expand All @@ -10,13 +12,14 @@ WORKDIR /go/src/github.com/gocrane/fadvisor
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download

# Copy the go source
COPY pkg pkg/
COPY cmd cmd/
COPY staging staging/

# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="${LDFLAGS}" -a -o ${PKGNAME} /go/src/github.com/gocrane/fadvisor/cmd/${PKGNAME}/main.go
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ fadvisor: ## Build binary with the fadvisor.
images: image-fadvisor

.PHONY: image-fadvisor
image-fadvisor: test ## Build docker image with the fadvisor.
image-fadvisor: ## Build docker image with the fadvisor.
docker build --build-arg LDFLAGS=$(LDFLAGS) --build-arg PKGNAME=fadvisor -t ${FADVISOR_IMG} .


Expand Down
4 changes: 4 additions & 0 deletions pkg/util/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ func CreateLeaderElectionConfig(
k8sClient kubernetes.Interface,
eventRecorder events.EventRecorder,
LeaderElection componentconfig.LeaderElectionConfiguration) (*leaderelection.LeaderElectionConfig, error) {
if !LeaderElection.LeaderElect {
return nil, nil
}

hostname, err := os.Hostname()
if err != nil {
return nil, fmt.Errorf("unable to get hostname: %v", err)
Expand Down

0 comments on commit 35e39cd

Please sign in to comment.