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

feat: support cloud provider mode #15

Merged
merged 1 commit into from
Aug 2, 2024
Merged
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
33 changes: 30 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2024-07-09T15:22:07Z by kres 8c8b007.
# Generated on 2024-07-31T12:19:21Z by kres faf91e3.

name: default
concurrency:
Expand Down Expand Up @@ -104,11 +104,37 @@ jobs:
PUSH: "true"
run: |
make image-talemu IMAGE_TAG=latest
- name: talemu-cloud-provider
run: |
make talemu-cloud-provider
- name: Login to registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
username: ${{ github.repository_owner }}
- name: image-talemu-cloud-provider
run: |
make image-talemu-cloud-provider
- name: push-talemu-cloud-provider
if: github.event_name != 'pull_request'
env:
PUSH: "true"
run: |
make image-talemu-cloud-provider
- name: push-talemu-cloud-provider-latest
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
env:
PUSH: "true"
run: |
make image-talemu-cloud-provider IMAGE_TAG=latest
- name: Generate Checksums
if: startsWith(github.ref, 'refs/tags/')
run: |
sha256sum _out/talemu-* > _out/sha256sum.txt
sha512sum _out/talemu-* > _out/sha512sum.txt
cd _out
sha256sum talemu-* talemu-cloud-provider-* > sha256sum.txt
sha512sum talemu-* talemu-cloud-provider-* > sha512sum.txt
- name: release-notes
if: startsWith(github.ref, 'refs/tags/')
run: |
Expand All @@ -121,4 +147,5 @@ jobs:
draft: "true"
files: |-
_out/talemu-*
_out/talemu-cloud-provider-*
_out/sha*.txt
30 changes: 27 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# syntax = docker/dockerfile-upstream:1.8.1-labs
# syntax = docker/dockerfile-upstream:1.9.0-labs

# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2024-07-11T16:29:15Z by kres 8c8b007.
# Generated on 2024-07-31T12:19:21Z by kres faf91e3.

ARG TOOLCHAIN

Expand All @@ -11,7 +11,7 @@ FROM ghcr.io/siderolabs/ca-certificates:v1.7.0 AS image-ca-certificates
FROM ghcr.io/siderolabs/fhs:v1.7.0 AS image-fhs

# runs markdownlint
FROM docker.io/oven/bun:1.1.17-alpine AS lint-markdown
FROM docker.io/oven/bun:1.1.20-alpine AS lint-markdown
WORKDIR /src
RUN bun i [email protected] [email protected]
COPY .markdownlint.json .
Expand Down Expand Up @@ -120,6 +120,14 @@ COPY --from=proto-compile /api/ /api/
FROM scratch AS unit-tests
COPY --from=unit-tests-run /src/coverage.txt /coverage-unit-tests.txt

# builds talemu-cloud-provider-linux-amd64
FROM base AS talemu-cloud-provider-linux-amd64-build
COPY --from=generate / /
WORKDIR /src/cmd/talemu-cloud-provider
ARG GO_BUILDFLAGS
ARG GO_LDFLAGS
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg go build ${GO_BUILDFLAGS} -ldflags "${GO_LDFLAGS}" -o /talemu-cloud-provider-linux-amd64

# builds talemu-linux-amd64
FROM base AS talemu-linux-amd64-build
COPY --from=generate / /
Expand All @@ -128,14 +136,30 @@ ARG GO_BUILDFLAGS
ARG GO_LDFLAGS
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg go build ${GO_BUILDFLAGS} -ldflags "${GO_LDFLAGS}" -o /talemu-linux-amd64

FROM scratch AS talemu-cloud-provider-linux-amd64
COPY --from=talemu-cloud-provider-linux-amd64-build /talemu-cloud-provider-linux-amd64 /talemu-cloud-provider-linux-amd64

FROM scratch AS talemu-linux-amd64
COPY --from=talemu-linux-amd64-build /talemu-linux-amd64 /talemu-linux-amd64

FROM talemu-cloud-provider-linux-${TARGETARCH} AS talemu-cloud-provider

FROM scratch AS talemu-cloud-provider-all
COPY --from=talemu-cloud-provider-linux-amd64 / /

FROM talemu-linux-${TARGETARCH} AS talemu

FROM scratch AS talemu-all
COPY --from=talemu-linux-amd64 / /

FROM scratch AS image-talemu-cloud-provider
ARG TARGETARCH
COPY --from=talemu-cloud-provider talemu-cloud-provider-linux-${TARGETARCH} /talemu-cloud-provider
COPY --from=image-fhs / /
COPY --from=image-ca-certificates / /
LABEL org.opencontainers.image.source=https://github.com/siderolabs/talemu
ENTRYPOINT ["/talemu-cloud-provider"]

FROM scratch AS image-talemu
ARG TARGETARCH
COPY --from=talemu talemu-linux-${TARGETARCH} /talemu
Expand Down
22 changes: 18 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
#
# Generated on 2024-07-08T16:02:22Z by kres 8c8b007.
# Generated on 2024-07-31T12:19:21Z by kres faf91e3.

# common variables

Expand All @@ -21,11 +21,11 @@ PROTOBUF_GO_VERSION ?= 1.34.2
GRPC_GO_VERSION ?= 1.4.0
GRPC_GATEWAY_VERSION ?= 2.20.0
VTPROTOBUF_VERSION ?= 0.6.0
GOIMPORTS_VERSION ?= 0.22.0
GOIMPORTS_VERSION ?= 0.23.0
DEEPCOPY_VERSION ?= v0.5.6
GOLANGCILINT_VERSION ?= v1.59.1
GOFUMPT_VERSION ?= v0.6.0
GO_VERSION ?= 1.22.4
GO_VERSION ?= 1.22.5
GO_BUILDFLAGS ?=
GO_LDFLAGS ?=
CGO_ENABLED ?= 0
Expand Down Expand Up @@ -135,7 +135,7 @@ else
GO_LDFLAGS += -s
endif

all: unit-tests talemu image-talemu docker-compose-up docker-compose-down lint
all: unit-tests talemu image-talemu talemu-cloud-provider image-talemu-cloud-provider docker-compose-up docker-compose-down lint

$(ARTIFACTS): ## Creates artifacts directory.
@mkdir -p $(ARTIFACTS)
Expand Down Expand Up @@ -203,6 +203,20 @@ lint: lint-golangci-lint lint-gofumpt lint-govulncheck lint-markdown ## Run all
image-talemu: ## Builds image for talemu.
@$(MAKE) target-$@ TARGET_ARGS="--tag=$(REGISTRY)/$(USERNAME)/talemu:$(IMAGE_TAG)"

.PHONY: $(ARTIFACTS)/talemu-cloud-provider-linux-amd64
$(ARTIFACTS)/talemu-cloud-provider-linux-amd64:
@$(MAKE) local-talemu-cloud-provider-linux-amd64 DEST=$(ARTIFACTS)

.PHONY: talemu-cloud-provider-linux-amd64
talemu-cloud-provider-linux-amd64: $(ARTIFACTS)/talemu-cloud-provider-linux-amd64 ## Builds executable for talemu-cloud-provider-linux-amd64.

.PHONY: talemu-cloud-provider
talemu-cloud-provider: talemu-cloud-provider-linux-amd64 ## Builds executables for talemu-cloud-provider.

.PHONY: image-talemu-cloud-provider
image-talemu-cloud-provider: ## Builds image for talemu-cloud-provider.
@$(MAKE) target-$@ TARGET_ARGS="--tag=$(REGISTRY)/$(USERNAME)/talemu-cloud-provider:$(IMAGE_TAG)"

.PHONY: docker-compose-up
docker-compose-up:
ARTIFACTS="$(ARTIFACTS)" SHA="$(SHA)" TAG="$(TAG)" USERNAME="$(USERNAME)" REGISTRY="$(REGISTRY)" PROTOBUF_TS_VERSION="$(PROTOBUF_TS_VERSION)" NODE_BUILD_ARGS="$(NODE_BUILD_ARGS)" TOOLCHAIN="$(TOOLCHAIN)" CGO_ENABLED="$(CGO_ENABLED)" GO_BUILDFLAGS="$(GO_BUILDFLAGS)" GOLANGCILINT_VERSION="$(GOLANGCILINT_VERSION)" GOFUMPT_VERSION="$(GOFUMPT_VERSION)" GOIMPORTS_VERSION="$(GOIMPORTS_VERSION)" PROTOBUF_GO_VERSION="$(PROTOBUF_GO_VERSION)" GRPC_GO_VERSION="$(GRPC_GO_VERSION)" GRPC_GATEWAY_VERSION="$(GRPC_GATEWAY_VERSION)" VTPROTOBUF_VERSION="$(VTPROTOBUF_VERSION)" DEEPCOPY_VERSION="$(DEEPCOPY_VERSION)" TESTPKGS="$(TESTPKGS)" COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 GO_LDFLAGS="$(GO_LDFLAGS)" docker compose -p talemu --file ./hack/compose/docker-compose.yml --file ./hack/compose/docker-compose.override.yml up --build
Expand Down
36 changes: 33 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
Runs multiple fake Talos nodes at the same time.
To be used in pair with Omni.

## Running emulator
## Running Emulator Static Mode

Do `Copy Kernel Args` in the Omni UI, then paste the to `--kernel-args` flag.
Do `Copy Kernel Args` in the Omni UI.

Create `hack/compose/docker-compose.override.yml` file with the kernel args params.
Create `hack/compose/docker-compose.override.yml` and paste copied kernel args there.

Final YAML file can look like this:

Expand All @@ -24,3 +24,33 @@ services:
Run `make docker-compose-up` command.

This will spawn one hundred fake Talos nodes.

## Cloud Provider Mode

Run:

```bash
make cloud-provider
```

Then run:

```bash
sudo -E _out/talemu-cloud-provider-linux-amd64 --create-service-account --omni-api-endpoint=https://localhost:8099
```

Create a machine request using `omnictl`:

```yaml
metadata:
namespace: cloud-provider
type: MachineRequests.omni.sidero.dev
id: machine-1
labels:
omni.sidero.dev/cloud-provider-id: talemu
spec:
talosversion: v1.7.5
schematicid: 376567988ad370138ad8b2698212367b8edcb69b5fd68c80be1f2ec7d603b4ba
```

The machine should be created by the emulator and appear in Omni.
Loading