-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: Add CLI tool to generate a kustomization.yaml for k3OS config files
This is going to be used over in the https://github.com/sgielen/picl-k3os-image-generator project.
- Loading branch information
1 parent
e62769e
commit 12290c2
Showing
4 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
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,32 @@ | ||
# syntax=docker/dockerfile:1-experimental | ||
|
||
FROM --platform=${BUILDPLATFORM} golang:1.15-alpine AS base | ||
|
||
WORKDIR /workspace | ||
ENV CGO_ENABLED=0 | ||
|
||
# Copy the Go Modules manifests | ||
COPY go.* . | ||
# 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 | ||
|
||
FROM base AS builder | ||
ARG TARGETOS | ||
ARG TARGETARCH | ||
|
||
# Copy the go source | ||
COPY cmd/update_k3osnodes_secret/main.go cmd/update_k3osnodes_secret/main.go | ||
|
||
# Build | ||
ENV GO111MODULE=on | ||
RUN --mount=type=cache,target=/root/.cache/go-build \ | ||
GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -mod=readonly -a -o update_k3osnodes_secret cmd/update_k3osnodes_secret/main.go | ||
|
||
# use distroless as minimal base image to package the binary | ||
FROM gcr.io/distroless/static:nonroot | ||
WORKDIR / | ||
COPY --from=builder /workspace/update_k3osnodes_secret . | ||
USER nonroot:nonroot | ||
|
||
ENTRYPOINT ["/update_k3osnodes_secret"] |
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,15 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
func main() { | ||
// 1. read all YAML files in the config directory | ||
// 2. parse them using github.com/annismckenzie/k3os-config-operator as a library | ||
// 3. extract the node name | ||
// 4. generate the secret into config/k3osconfig.yaml by using kustomize as a library | ||
// 5. build this tool in the main Dockerfile using a multistage build, then add a Makefile target to invoke it on its own | ||
|
||
fmt.Println("Successfully updated k3osconfig.yaml") | ||
} |
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