-
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.
Showing
28 changed files
with
1,263 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[Makefile] | ||
indent_size = 4 | ||
|
||
[*.{bash,sh}] | ||
indent_size = 4 | ||
|
||
[*.json] | ||
|
||
[*.go] | ||
indent_style = tab | ||
indent_size = 4 |
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,52 @@ | ||
--- | ||
name: release | ||
|
||
on: | ||
push: | ||
tags: | ||
- "*" | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Login to container registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ${{ secrets.REGISTRY_URL }} | ||
username: ${{ secrets.REGISTRY_USERNAME }} | ||
password: ${{ secrets.REGISTRY_PASSWORD }} | ||
|
||
- name: Extract metadata for image | ||
id: meta | ||
uses: docker/metadata-action@v3 | ||
with: | ||
images: ${{ secrets.REGISTRY_URL }}/futuretea/harvester-netboot | ||
tags: type=ref,event=tag | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: Dockerfile | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
|
||
- name: Generate release info | ||
id: info | ||
run: | | ||
version=$(echo $GITHUB_REF | cut -d / -f 3) | ||
echo "${{ secrets.REGISTRY_URL }}/futuretea/harvester-netboot:${version}" > release.txt | ||
- name: Release | ||
uses: softprops/action-gh-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
body_path: release.txt |
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,12 @@ | ||
.dapper | ||
.idea | ||
.vscode | ||
harvester-netboot | ||
vendor | ||
bin | ||
config.yaml | ||
.terraform.lock.hcl | ||
.terraform | ||
terraform.tfstate | ||
terraform.tfstate.backup | ||
terraform.tfvars |
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,25 @@ | ||
--- | ||
run: | ||
deadline: 5m | ||
linters: | ||
enable: | ||
- vet | ||
- staticcheck | ||
- errcheck | ||
- gofmt | ||
- goimports | ||
- whitespace | ||
- unused | ||
- ineffassign | ||
- prealloc | ||
- stylecheck | ||
- goconst | ||
- gosimple | ||
- misspell | ||
# - gosec | ||
enable-all: false | ||
disable-all: true | ||
fast: false | ||
linters-settings: | ||
goimports: | ||
local-prefixes: github.com/futuretea/harvester-netboot |
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,31 @@ | ||
--- | ||
# This is an example .goreleaser.yml file with some sensible defaults. | ||
# Make sure to check the documentation at https://goreleaser.com | ||
before: | ||
hooks: | ||
# You may remove this if you don't use go modules. | ||
- go mod tidy | ||
builds: | ||
- env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
- windows | ||
- darwin | ||
archives: | ||
- replacements: | ||
darwin: Darwin | ||
linux: Linux | ||
windows: Windows | ||
386: i386 | ||
amd64: x86_64 | ||
checksum: | ||
name_template: "checksums.txt" | ||
snapshot: | ||
name_template: "{{ incpatch .Version }}-next" | ||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- "^docs:" | ||
- "^test:" |
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 @@ | ||
--- | ||
fail_fast: false | ||
repos: | ||
- repo: https://github.com/adrienverge/yamllint | ||
rev: v1.30.0 | ||
hooks: | ||
- id: yamllint | ||
args: | ||
- --config-file | ||
- .yamllint.yaml | ||
- repo: https://github.com/gruntwork-io/pre-commit | ||
rev: v0.1.21 | ||
hooks: | ||
- id: gofmt | ||
- id: golangci-lint |
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,53 @@ | ||
--- | ||
version: "3" | ||
|
||
env: | ||
DOCKER_IMAGE: futuretea/harvester-netboot | ||
DOCKER_TAG: latest | ||
|
||
tasks: | ||
build: | ||
desc: "build the docker image" | ||
cmds: | ||
- docker build -t ${DOCKER_IMAGE}:${DOCKER_TAG} . | ||
|
||
push: | ||
desc: "push the docker image" | ||
cmds: | ||
- docker push ${DOCKER_IMAGE}:${DOCKER_TAG} | ||
|
||
pull: | ||
desc: "pull the docker image" | ||
cmds: | ||
- docker pull ${DOCKER_IMAGE}:${DOCKER_TAG} | ||
|
||
build-push: | ||
desc: "build and push the docker image" | ||
cmds: | ||
- task: build | ||
- task: push | ||
|
||
up: | ||
desc: "start the service" | ||
cmds: | ||
- docker-compose up -d | ||
|
||
down: | ||
desc: "stop the service" | ||
cmds: | ||
- docker-compose down | ||
|
||
logs: | ||
desc: "show the service logs" | ||
cmds: | ||
- docker-compose logs -f | ||
|
||
update: | ||
desc: "update the service" | ||
cmds: | ||
- git pull | ||
- task: build | ||
- task: push | ||
- task: down | ||
- task: up | ||
- task: logs |
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,25 @@ | ||
--- | ||
version: "3" | ||
|
||
tasks: | ||
build: | ||
desc: "build the compiled binary" | ||
cmds: | ||
- mkdir -p ./bin | ||
- CGO_ENABLED=0 go build -o ./bin/harvester-netboot | ||
|
||
test: | ||
desc: "run all unit tests" | ||
cmds: | ||
- CGO_ENABLED=0 go test -v ./... | ||
|
||
mod: | ||
desc: "clean and update vendor" | ||
cmds: | ||
- go mod tidy -v | ||
- go mod vendor -v | ||
|
||
lint: | ||
desc: "lint the code" | ||
cmds: | ||
- CGO_ENABLED=0 golangci-lint run |
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,18 @@ | ||
--- | ||
version: "3" | ||
|
||
tasks: | ||
init: | ||
desc: Initialize pre-commit hooks | ||
cmds: | ||
- pre-commit install --install-hooks | ||
|
||
run: | ||
desc: Run pre-commit | ||
cmds: | ||
- pre-commit run --all-files | ||
|
||
update: | ||
desc: Update pre-commit hooks | ||
cmds: | ||
- pre-commit autoupdate |
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,17 @@ | ||
--- | ||
ignore: | | ||
*.sops.* | ||
extends: default | ||
rules: | ||
truthy: | ||
allowed-values: ["true", "false", "on"] | ||
comments: | ||
min-spaces-from-content: 1 | ||
line-length: disable | ||
braces: | ||
min-spaces-inside: 0 | ||
max-spaces-inside: 1 | ||
brackets: | ||
min-spaces-inside: 0 | ||
max-spaces-inside: 0 | ||
indentation: enable |
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,17 @@ | ||
FROM golang:1.18.7 as builder | ||
COPY . /src | ||
WORKDIR /src | ||
|
||
RUN CGO_ENABLED=0 go build -o /app . | ||
|
||
FROM registry.suse.com/bci/bci-base:15.4 | ||
RUN zypper -n rm container-suseconnect && \ | ||
zypper -n install curl && \ | ||
zypper -n clean -a && rm -rf /tmp/* /var/tmp/* /usr/share/doc/packages/* | ||
|
||
RUN curl -sLf https://github.com/krallin/tini/releases/download/v0.19.0/tini > /usr/bin/tini && chmod +x /usr/bin/tini | ||
|
||
COPY --from=builder /app /usr/bin/ | ||
COPY entrypoint.sh /usr/bin/entrypoint.sh | ||
RUN chmod +x /usr/bin/entrypoint.sh | ||
ENTRYPOINT ["entrypoint.sh"] |
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,26 @@ | ||
# harvester-netboot | ||
|
||
Declarative definition of multi-cluster Harvester network boot server. | ||
|
||
## Features | ||
- [x] Declarative definition | ||
- [x] Multi-cluster support | ||
- [ ] Webhook support | ||
- [ ] EFI support | ||
|
||
## How to use | ||
|
||
1. Prepare a clean Linux server with docker and docker-compose installed. | ||
2. Clone this repo | ||
3. Copy the example config file. | ||
```bash | ||
cp config.example.yaml config.yaml | ||
``` | ||
4. Edit the config file for your environment. | ||
```bash | ||
vim config.yaml | ||
``` | ||
5. Run the docker-compose file. | ||
```bash | ||
docker-compose up -d | ||
``` |
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,7 @@ | ||
--- | ||
version: "3" | ||
|
||
includes: | ||
precommit: .taskfiles/PrecommitTasks.yml | ||
go: .taskfiles/GoTasks.yml | ||
docker: .taskfiles/DockerTasks.yml |
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,34 @@ | ||
--- | ||
# recommended to change the base_url to a local mirror | ||
base_url: https://releases.rancher.com/harvester | ||
clusters: | ||
- name: harv-foo | ||
version: v1.1.1 | ||
vip: 192.168.5.60 | ||
nodes: | ||
- hostname: harv-foo | ||
mode: create | ||
ip: 192.168.5.61 | ||
mac: "xx:xx:xx:xx:xx:xx" | ||
nic: eth0 | ||
device: /dev/sda | ||
- name: harv-bar | ||
version: master | ||
vip: 192.168.5.62 | ||
nodes: | ||
- hostname: harv-bar | ||
mode: create | ||
ip: 192.168.5.63 | ||
mac: "xx:xx:xx:xx:xx:xx" | ||
nic: eth0 | ||
device: /dev/sda | ||
os: | ||
token: token | ||
password: p@ssword | ||
gateway: 192.168.5.1 | ||
subnet_mask: 255.255.255.0 | ||
ntp_servers: | ||
- ntp.aliyun.com | ||
dns_nameservers: | ||
- 192.168.5.1 | ||
- 8.8.8.8 |
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,18 @@ | ||
--- | ||
version: "3.7" | ||
services: | ||
pixiecore: | ||
network_mode: host | ||
container_name: pixiecore | ||
image: quay.io/pixiecore/pixiecore | ||
restart: unless-stopped | ||
command: | ||
- api | ||
- http://127.0.0.1:8080 | ||
harvester-netboot: | ||
container_name: harvester-netboot | ||
image: futuretea/harvester-netboot | ||
ports: | ||
- "8080:8080" | ||
volumes: | ||
- "./config.yaml:/etc/harvester-netboot/config.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
exec tini -- app "${@}" |
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,5 @@ | ||
GOMODULE=github.com/futuretea/harvester-netboot | ||
GOVERSION=1.18.7 | ||
USEGOMOD=true | ||
USEPROXY=gomod | ||
NOPROXY=git,sh |
Oops, something went wrong.