I do not have access to the redhat repo for downloading the images. So I changed the images with other simple ones, the issue is the leader-elector container is not able to pick up the name.
Will not report event: 'Normal' '%v became leader' '$(hostname)'
I0524 08:53:43.227183 1 leaderelection.go:215] sucessfully acquired lease default/example
$(hostname) is the leader
$(hostname) is the leader
Below is the docker file:
FROM golang:1.13 as builder
ADD election /go/src/k8s.io/contrib/election
RUN cd /go/src/k8s.io/contrib/election
&& CGO_ENABLED=0 GOOS=linux GO111MODULE=off go build -a -installsuffix cgo -ldflags '-w' -o leader-elector example/main.go
FROM debian:jessie
ENV DEBIAN_FRONTEND=noninteractive
RUN
apt-get update &&
apt-get install -y ca-certificates &&
rm -rf /var/lib/apt/lists/*
COPY --from=builder /go/src/k8s.io/contrib/election/leader-elector /usr/bin/
USER 1001
ENTRYPOINT [ "leader-elector", "--id=$(hostname)" ]
LABEL
io.k8s.description="This is a component of OpenShift Container Platform and provides a leader-elector sidecar container."
com.redhat.component="leader-elector-container"
maintainer="Michal Dulko [email protected]"
name="openshift/ose-leader-elector"
summary="This image provides leader election functionality and can be used as a sidecar container."
io.k8s.display-name="leader-elector"
version="v4.0.0"
io.openshift.tags="openshift"