-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from whywaita/develop
Implement
- Loading branch information
Showing
25 changed files
with
3,191 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,39 @@ | ||
name: Build Docker image (sha) for Server | ||
on: | ||
push: | ||
branches: | ||
- "**" | ||
|
||
jobs: | ||
docker-build-sha: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- uses: docker/setup-qemu-action@v1 | ||
- uses: docker/setup-buildx-action@v1 | ||
- name: Cache Docker layers | ||
uses: actions/cache@v2 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx- | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- uses: docker/metadata-action@v3 | ||
id: meta | ||
with: | ||
images: ghcr.io/whywaita/shoes-lxd-multi | ||
tags: | | ||
type=sha | ||
- name: Build container image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
context: ./server |
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,59 @@ | ||
name: Release | ||
on: | ||
push: | ||
tags: | ||
- "v[0-9]+.[0-9]+.[0-9]+" | ||
|
||
jobs: | ||
goreleaser: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.16 | ||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v2 | ||
with: | ||
version: latest | ||
args: release --rm-dist | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
docker: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- uses: docker/setup-qemu-action@v1 | ||
- uses: docker/setup-buildx-action@v1 | ||
- name: Cache Docker layers | ||
uses: actions/cache@v2 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx- | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- uses: docker/metadata-action@v3 | ||
id: meta | ||
with: | ||
images: ghcr.io/whywaita/shoes-lxd-multi | ||
tags: | | ||
type=raw,value=latest | ||
type=semver,pattern={{raw}} | ||
type=sha | ||
- name: Build container image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
context: ./server |
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,48 @@ | ||
name: Test | ||
on: | ||
push: | ||
branches: | ||
- "**" | ||
pull_request: {} | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
target: | ||
- server | ||
- shoes-lxd-multi | ||
steps: | ||
- name: Setup go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.16.x | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 1 | ||
- name: lint | ||
run: | | ||
GO111MODULE=off GOBIN=$(pwd)/bin go get golang.org/x/lint/golint | ||
bin/golint -set_exit_status ./... | ||
- name: go vet | ||
run: | | ||
cd ${{ matrix.target }} | ||
go vet ./... | ||
- name: go test | ||
run: | | ||
cd ${{ matrix.target }} | ||
go test ./... | ||
docker-build-test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 1 | ||
- name: docker build | ||
run: | | ||
cd server | ||
docker build . |
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 @@ | ||
/server/server | ||
/shoes-lxd-multi/shoes-lxd-multi | ||
|
||
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,14 @@ | ||
builds: | ||
- id: "shoes-lxd-multi-shoes-provider" | ||
dir: shoes-lxd-multi | ||
binary: shoes-lxd-multi | ||
env: | ||
- CGO_ENABLED=0 | ||
- id: "shoes-lxd-multi-serevr" | ||
dir: server | ||
binary: shoes-lxd-multi-server | ||
env: | ||
- CGO_ENABLED=0 | ||
archives: | ||
- format: binary | ||
name_template: "{{ .Binary }}-{{ .Os }}-{{ .Arch }}" |
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 |
---|---|---|
@@ -1 +1,8 @@ | ||
# shoes-lxd-multi | ||
|
||
[myshoes](https://github.com/whywaita/myshoes) provider for [LXD](https://linuxcontainers.org/lxd/) in multi server. | ||
|
||
## Architecture | ||
|
||
- shoes-lxd-multi: shoes-provider | ||
- server: Server-side |
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 @@ | ||
FROM golang:1.16 AS builder | ||
|
||
WORKDIR /go/src/github.com/whywaita/shoes-lxd-multi/server | ||
|
||
ENV CGO_ENABLED=0 | ||
ENV GOOS=linux | ||
ENV GOARCH=amd64 | ||
|
||
COPY . . | ||
RUN go build . | ||
|
||
FROM alpine | ||
|
||
RUN apk update \ | ||
&& apk update | ||
RUN apk add --no-cache ca-certificates \ | ||
&& update-ca-certificates 2>/dev/null || true | ||
|
||
COPY --from=builder /go/src/github.com/whywaita/shoes-lxd-multi/server/server /app | ||
|
||
CMD ["/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,40 @@ | ||
# Server | ||
|
||
Server-side implementation for shoes-lxd-multi | ||
|
||
## Setup | ||
|
||
- `LXD_MULTI_HOSTS` | ||
|
||
```json | ||
[ | ||
{ | ||
"host": "https://192.0.2.100:8443", | ||
"client_cert": "./node1/client.crt", | ||
"client_key": "./node1/client.key" | ||
}, | ||
... | ||
] | ||
``` | ||
|
||
### Optional values | ||
- `LXD_MULTI_IMAGE_ALIAS` | ||
- set runner image alias | ||
- default: `ubuntu:bionic` | ||
- e.g.) for remote image server: `https://192.0.2.110:8443/ubuntu-custom` | ||
- `LXD_MULTI_RESOURCE_TYPE_MAPPING` | ||
- mapping `resource_type` and CPU / Memory. | ||
- need JSON format. keys is `resource_type_name`, `cpu`, `memory`. | ||
- e.g.) `[{"resource_type_name": "nano", "cpu": 1, "memory": "1GB"}, {"resource_type_name": "micro", "cpu": 2, "memory": "2GB"}]` | ||
- become no limit if not set resource_type. | ||
- `LXD_MULTI_PORT` | ||
- Port of listen gRPC Server | ||
- default: `8080` | ||
- `LXD_MULTI_OVER_COMMIT_PERCENT` | ||
- Percent of able over commit in CPU | ||
- default: `100` | ||
|
||
## Note | ||
LXD Server can't use `zfs` in storageclass if use `--privileged`. ref: https://discuss.linuxcontainers.org/t/docker-with-overlay-driver-in-lxd-cluster-not-working/9243 | ||
|
||
We recommend using `btrfs`. |
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,14 @@ | ||
module github.com/whywaita/shoes-lxd-multi/server | ||
|
||
go 1.16 | ||
|
||
require ( | ||
github.com/docker/go-units v0.4.0 | ||
github.com/lxc/lxd v0.0.0-20211202222358-a293da71aeb0 | ||
github.com/prometheus/client_golang v1.11.0 | ||
github.com/whywaita/myshoes v1.10.4 | ||
github.com/whywaita/shoes-lxd-multi/proto.go v0.0.0-20211203151606-53728ef694c2 | ||
google.golang.org/grpc v1.42.0 | ||
) | ||
|
||
//replace github.com/flosch/pongo2 => github.com/flosch/pongo2/v4 v4.0.2 |
Oops, something went wrong.