-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
270 additions
and
50 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"os" | ||
"strconv" | ||
|
||
"github.com/sirupsen/logrus" | ||
"github.com/virtual-kubelet/azure-aci/pkg/auth" | ||
"github.com/virtual-kubelet/azure-aci/pkg/initcontainer" | ||
cli "github.com/virtual-kubelet/node-cli" | ||
"github.com/virtual-kubelet/virtual-kubelet/log" | ||
logruslogger "github.com/virtual-kubelet/virtual-kubelet/log/logrus" | ||
) | ||
|
||
func main() { | ||
logger := logrus.StandardLogger() | ||
log.L = logruslogger.FromLogrus(logrus.NewEntry(logger)) | ||
|
||
ctx := cli.ContextWithCancelOnSignal(context.Background()) | ||
|
||
vkVersion, err := strconv.ParseBool(os.Getenv("USE_VK_VERSION_2")) | ||
if err != nil { | ||
log.G(ctx).Warn("cannot get USE_VK_VERSION_2 environment variable, the provider will use VK version 1. Skipping init container checks") | ||
return | ||
} | ||
|
||
azConfig := auth.Config{} | ||
|
||
if vkVersion { | ||
//Setup config | ||
err = azConfig.SetAuthConfig() | ||
if err != nil { | ||
log.G(ctx).Fatal(err) | ||
} | ||
} | ||
// check role assignments | ||
err = initcontainer.CheckRoleAssignments(ctx, azConfig) | ||
if err != nil { | ||
log.G(ctx).Fatal(err, "role assignments needed for virtual kubelet are not set.") | ||
os.Exit(1) | ||
} | ||
|
||
err = initcontainer.CheckSubnetConfiguration(ctx, azConfig, "", "") | ||
if err != nil { | ||
log.G(ctx).Fatal(err, "virtual kubelet subnet is not configured with the user defiled route.") | ||
os.Exit(1) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
.dockerignore | ||
Dockerfile | ||
bin/ | ||
helm/ | ||
hack/ | ||
charts/ | ||
.circleci/ | ||
README.md | ||
.gitignore | ||
|
||
# binary output | ||
bin/ | ||
hack/tools/bin/ | ||
|
||
.azure | ||
|
||
.DS_Store | ||
.vscode/ | ||
.idea/ | ||
.run/ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
FROM --platform=$BUILDPLATFORM golang:1.18 as builder | ||
ARG TARGETARCH | ||
|
||
WORKDIR /workspace | ||
# 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 | ||
ENV GOCACHE=/root/gocache | ||
RUN \ | ||
--mount=type=cache,target=${GOCACHE} \ | ||
--mount=type=cache,target=/go/pkg/mod \ | ||
go mod download | ||
|
||
# Copy the go source | ||
COPY cmd/init-container/main.go main.go | ||
COPY pkg/auth pkg/auth | ||
COPY pkg/initcontainer pkg/initcontainer | ||
|
||
RUN --mount=type=cache,target=${GOCACHE} \ | ||
--mount=type=cache,id=vk-azure-aci-init,sharing=locked,target=/go/pkg/mod \ | ||
CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} GO111MODULE=on go build -o initcontainer main.go | ||
|
||
FROM gcr.io/distroless/static:nonroot | ||
WORKDIR / | ||
COPY --from=builder /workspace/initcontainer . | ||
USER 65532:65532 | ||
|
||
ENTRYPOINT [ "/initcontainer" ] |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.