-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit be23c47
Showing
42 changed files
with
3,505 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,80 @@ | ||
name: Docker Publish CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- "main" | ||
tags: | ||
- 'v*.*.*' | ||
pull_request: | ||
branches: | ||
- 'main' | ||
|
||
jobs: | ||
go-build-linux: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: '>=1.18.0' | ||
cache: true | ||
- name: Set env for Version | ||
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | ||
- run: echo "Attempting to build a linux binary" | ||
- run: GOOS=linux GOARCH=amd64 go build -ldflags="main.Version='${{ env.RELEASE_VERSION }}'" -o ./kube-server-linux ./cmd/kube-server/main.go | ||
- run: echo "Outputting Version" | ||
- run: ./kube-server-linux --version | ||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: kube-server-linux | ||
path: ./kube-server-linux | ||
docker-publish: | ||
needs: go-build-linux | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v3 | ||
- | ||
name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
# list of Docker images to use as base name for tags | ||
images: | | ||
taylorsmcclure/kube-server | ||
# generate Docker tags based on the following events/attributes | ||
tags: | | ||
type=schedule | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
type=semver,pattern={{version}} | ||
type=sha | ||
- | ||
name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- | ||
name: Login to DockerHub | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- | ||
name: Download the golang binary | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: kube-server-linux | ||
path: cmd/kube-server/bin/kube-server-linux | ||
- | ||
name: Build and push | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
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 @@ | ||
name: Go Release | ||
on: | ||
release: | ||
types: [created] | ||
|
||
jobs: | ||
releases-matrix: | ||
name: Release Go Binary | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
# build and publish in parallel: linux/amd64, darwin/amd64 | ||
goos: [linux, darwin] | ||
goarch: [amd64] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: wangyoucao577/go-release-action@v1.29 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
goos: ${{ matrix.goos }} | ||
goarch: ${{ matrix.goarch }} | ||
goversion: "1.18" | ||
project_path: "./cmd/kube-server" | ||
binary_name: "kube-server" | ||
extra_files: LICENSE.md README.md |
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,42 @@ | ||
name: Go Tests | ||
on: [push] | ||
jobs: | ||
unit-tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: '>=1.18.0' | ||
cache: true | ||
- run: go version | ||
- run: echo "Checking if gofmt finds anything" | ||
- run: if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then exit 1; fi | ||
- run: echo "Running unit tests" | ||
- run: go test -v ./... | ||
staticcheck: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- run: echo "Running staticcheck" | ||
- uses: actions/checkout@v3 | ||
- uses: dominikh/staticcheck-action@v1.2.0 | ||
with: | ||
version: "2022.1.1" | ||
build-linux: | ||
needs: [unit-tests, staticcheck] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: '>=1.18.0' | ||
cache: true | ||
- run: echo "Attempting to build a linux binary" | ||
# TODO: I read about ldflags and setting the Version var in my main.go | ||
- run: GOOS=linux GOARCH=amd64 go build -o ./kube-server-linux ./cmd/kube-server/main.go | ||
- run: echo "Outputting Version" | ||
- run: ./kube-server-linux --version | ||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: kube-server-linux | ||
path: artifacts/kube-server-linux |
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,9 @@ | ||
name: Helm Tests | ||
on: [push] | ||
jobs: | ||
helm-lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: azure/setup-helm@v3 | ||
- run: helm lint helm/kube-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,4 @@ | ||
bin/ | ||
.vscode/ | ||
certs/ | ||
.DS_Store |
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 golang:1.18 | ||
#Build args | ||
ENV PORT=8443 | ||
ENV REDIS_ADDR="redis-master.redis.svc.cluster.local:6379" | ||
|
||
# kube-server user | ||
ARG USERNAME=kube-server | ||
ARG USER_UID=1000 | ||
ARG USER_GID=$USER_UID | ||
|
||
#Adding Labels of build | ||
LABEL maintainer="Taylor McClure" | ||
LABEL repo="https://github.com/taylorsmcclure/kube-server" | ||
|
||
RUN groupadd --gid $USER_GID $USERNAME && \ | ||
useradd --uid $USER_UID --gid $USER_GID -m $USERNAME && \ | ||
mkdir /kube-server && \ | ||
chmod -R 775 /kube-server && \ | ||
chown -R $USERNAME:$USERNAME /kube-server | ||
COPY cmd/kube-server/bin/ /kube-server | ||
COPY scripts/entrypoint.sh /kube-server | ||
COPY scripts/liveness.sh /kube-server | ||
WORKDIR /kube-server | ||
|
||
EXPOSE $PORT | ||
|
||
USER $USERNAME | ||
|
||
#Execution | ||
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,32 @@ | ||
FROM golang:1.18 | ||
#Build args | ||
ENV PORT=8443 | ||
ENV REDIS_ADDR="redis-master.redis.svc.cluster.local:6379" | ||
#Adding Labels of build | ||
LABEL maintainer="Taylor McClure https://github.com/taylorsmcclure/kube-server" | ||
|
||
# kube-server user | ||
ARG USERNAME=kube-server | ||
ARG USER_UID=1000 | ||
ARG USER_GID=$USER_UID | ||
|
||
RUN groupadd --gid $USER_GID $USERNAME && \ | ||
useradd --uid $USER_UID --gid $USER_GID -m $USERNAME && \ | ||
mkdir /kube-server && \ | ||
chmod -R 775 /kube-server && \ | ||
chown -R $USERNAME:$USERNAME /kube-server | ||
COPY cmd /kube-server/cmd | ||
COPY internal /kube-server/internal | ||
COPY go.mod go.sum /kube-server/ | ||
COPY scripts/entrypoint-dev.sh /kube-server | ||
COPY scripts/liveness.sh /kube-server | ||
WORKDIR /kube-server | ||
|
||
RUN go mod download | ||
|
||
EXPOSE 8080 | ||
|
||
USER $USERNAME | ||
|
||
#Execution | ||
CMD ["./entrypoint-dev.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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Taylor McClure | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Oops, something went wrong.