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

POC : AWS #2

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RUN echo -e "https://alpine.global.ssl.fastly.net/alpine/$ALPINE_VERSION/main\nh
apk add --no-cache ipset iptables ip6tables graphviz font-noto
COPY --from=cni bridge host-local loopback portmap /opt/cni/bin/
ADD https://raw.githubusercontent.com/kubernetes-sigs/iptables-wrappers/e139a115350974aac8a82ec4b815d2845f86997e/iptables-wrapper-installer.sh /
RUN chmod 700 /iptables-wrapper-installer.sh && /iptables-wrapper-installer.sh --no-sanity-check
RUN chmod 700 /iptables-wrapper-installer.sh && /iptables-wrapper-installer.sh --no-sanity-check && apk add --no-cache wireguard-tools
COPY bin/linux/$GOARCH/kg /opt/bin/
COPY bin/linux/$GOARCH/kgctl /opt/bin/
ENTRYPOINT ["/opt/bin/kg"]
18 changes: 18 additions & 0 deletions pkg/mesh/mesh.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,24 @@ func New(backend Backend, enc encapsulation.Encapsulator, granularity Granularit
} else {
externalIP = publicIP
}
if publicIP == nil {
// Try to discover publicIP from endpoint/force-endpoint annotations
node, err := backend.Nodes().Get(hostname)
if err != nil {
level.Debug(logger).Log("msg", "could not get local node from backend", err)
}
if node != nil {
if node.Endpoint != nil {
backendIP := node.Endpoint.IP()
if isPublic(backendIP) {
_, publicIP, err = net.ParseCIDR(backendIP.String())
if err != nil {
level.Debug(logger).Log("msg", "could not parse backend endpoint address", backendIP.String())
}
}
}
}
}
level.Debug(logger).Log("msg", fmt.Sprintf("using %s as the public IP address", publicIP.String()))
ipTables, err := iptables.New(iptables.WithRegisterer(registerer), iptables.WithLogger(log.With(logger, "component", "iptables")), iptables.WithResyncPeriod(resyncPeriod))
if err != nil {
Expand Down
Loading