Skip to content

Commit

Permalink
Merge branch 'devel' into fedora-41
Browse files Browse the repository at this point in the history
  • Loading branch information
tpantelis authored Dec 5, 2024
2 parents 3fc491c + d9a8a5d commit f564b29
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 6 deletions.
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ bin/protoc:
unzip protoc-$(PROTOC_VERSION)-linux-x86_64.zip 'bin/*' 'include/*'
rm -f protoc-$(PROTOC_VERSION)-linux-x86_64.zip

bin/%/submariner-gateway: main.go $(shell find pkg -not \( -path 'pkg/globalnet*' -o -path 'pkg/routeagent*' \)) pkg/natdiscovery/proto/natdiscovery.pb.go
bin/%/submariner-gateway: main.go $(shell find pkg -not \( -path 'pkg/globalnet*' -o -path 'pkg/routeagent*' -o -path 'pkg/await_node_ready*' \)) pkg/natdiscovery/proto/natdiscovery.pb.go
GOARCH=$(call dockertogoarch,$(patsubst bin/linux/%/,%,$(dir $@))) ${SCRIPTS_DIR}/compile.sh $@ .

bin/%/submariner-route-agent: $(shell find pkg/routeagent_driver)
Expand All @@ -75,6 +75,8 @@ bin/%/submariner-route-agent: $(shell find pkg/routeagent_driver)
bin/%/submariner-globalnet: $(shell find pkg/globalnet)
GOARCH=$(call dockertogoarch,$(patsubst bin/linux/%/,%,$(dir $@))) ${SCRIPTS_DIR}/compile.sh $@ ./pkg/globalnet

bin/%/await-node-ready: $(shell find pkg/await_node_ready)
GOARCH=$(call dockertogoarch,$(patsubst bin/linux/%/,%,$(dir $@))) ${SCRIPTS_DIR}/compile.sh $@ ./pkg/await_node_ready

nullstring :=
space := $(nullstring) # end of the line
Expand All @@ -84,7 +86,7 @@ comma := ,
# This can be overridden to build for other supported architectures; the reference is the Go architecture,
# so "make images ARCHES=arm" will build a linux/arm/v7 image
ARCHES ?= amd64
BINARIES = submariner-gateway submariner-route-agent submariner-globalnet
BINARIES = submariner-gateway submariner-route-agent submariner-globalnet await-node-ready
ARCH_BINARIES := $(foreach arch,$(subst $(comma),$(space),$(ARCHES)),$(foreach binary,$(BINARIES),bin/linux/$(call gotodockerarch,$(arch))/$(binary)))

build: $(ARCH_BINARIES)
Expand Down
5 changes: 3 additions & 2 deletions package/Dockerfile.submariner-gateway
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ ARG TARGETPLATFORM
COPY . ${SOURCE}

RUN make -C ${SOURCE} LOCAL_BUILD=1 bin/${TARGETPLATFORM}/submariner-gateway
RUN make -C ${SOURCE} LOCAL_BUILD=1 bin/${TARGETPLATFORM}/await-node-ready

FROM --platform=${BUILDPLATFORM} fedora:${FEDORA_VERSION} AS base
ARG FEDORA_VERSION
Expand All @@ -32,7 +33,7 @@ ARG TARGETPLATFORM
WORKDIR /var/submariner

COPY --from=base /output/gateway /

COPY --from=builder ${SOURCE}/package/submariner.sh ${SOURCE}/package/pluto ${SOURCE}/bin/${TARGETPLATFORM}/submariner-gateway /usr/local/bin/
COPY --from=builder ${SOURCE}/package/submariner.sh ${SOURCE}/package/pluto ${SOURCE}/bin/${TARGETPLATFORM}/submariner-gateway \
${SOURCE}/package/await-node-ready.sh ${SOURCE}/bin/${TARGETPLATFORM}/await-node-ready /usr/local/bin/

ENTRYPOINT ["submariner.sh"]
5 changes: 3 additions & 2 deletions package/Dockerfile.submariner-route-agent
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ ARG TARGETPLATFORM
COPY . ${SOURCE}

RUN make -C ${SOURCE} LOCAL_BUILD=1 bin/${TARGETPLATFORM}/submariner-route-agent
RUN make -C ${SOURCE} LOCAL_BUILD=1 bin/${TARGETPLATFORM}/await-node-ready

FROM --platform=${BUILDPLATFORM} fedora:${FEDORA_VERSION} AS base
ARG FEDORA_VERSION
Expand All @@ -29,8 +30,8 @@ ARG TARGETPLATFORM
WORKDIR /var/submariner

COPY --from=base /output/route-agent /

COPY --from=builder ${SOURCE}/package/submariner-route-agent.sh ${SOURCE}/bin/${TARGETPLATFORM}/submariner-route-agent /usr/local/bin/
COPY --from=builder ${SOURCE}/package/submariner-route-agent.sh ${SOURCE}/bin/${TARGETPLATFORM}/submariner-route-agent \
${SOURCE}/package/await-node-ready.sh ${SOURCE}/bin/${TARGETPLATFORM}/await-node-ready /usr/local/bin/

# Wrapper scripts to choose the appropriate iptables
# https://github.com/kubernetes-sigs/iptables-wrappers
Expand Down
14 changes: 14 additions & 0 deletions package/await-node-ready.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -e -x

trap "exit 1" SIGTERM SIGINT

SUBMARINER_VERBOSITY=${SUBMARINER_VERBOSITY:-2}

if [ "${SUBMARINER_DEBUG}" == "true" ]; then
DEBUG="-v=3"
else
DEBUG="-v=${SUBMARINER_VERBOSITY}"
fi

exec await-node-ready ${DEBUG} -alsologtostderr
69 changes: 69 additions & 0 deletions pkg/await_node_ready/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
SPDX-License-Identifier: Apache-2.0
Copyright Contributors to the Submariner project.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main

import (
"flag"

"github.com/submariner-io/admiral/pkg/log"
"github.com/submariner-io/admiral/pkg/log/kzerolog"
admversion "github.com/submariner-io/admiral/pkg/version"
"github.com/submariner-io/submariner/pkg/node"
"github.com/submariner-io/submariner/pkg/versions"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/clientcmd"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/manager/signals"
)

var (
masterURL string
kubeconfig string
logger = log.Logger{Logger: logf.Log.WithName("main")}
showVersion = false
)

func main() {
kzerolog.AddFlags(nil)
flag.Parse()

admversion.Print("await-node-ready", versions.Submariner())

if showVersion {
return
}

kzerolog.InitK8sLogging()

versions.Log(&logger)

logger.Info("Initializing K8s client...")

ctx := signals.SetupSignalHandler()

cfg, err := clientcmd.BuildConfigFromFlags(masterURL, kubeconfig)
logger.FatalOnError(err, "Error building kubeconfig")

k8sClientSet, err := kubernetes.NewForConfig(cfg)
logger.FatalOnError(err, "Error building clientset")

logger.Info("Awaiting local node ready...")

node.WaitForLocalNodeReady(ctx, k8sClientSet)
}

0 comments on commit f564b29

Please sign in to comment.