-
Notifications
You must be signed in to change notification settings - Fork 9
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 #98 from iandyh/split
Distributed mode phase 1
- Loading branch information
Showing
21 changed files
with
616 additions
and
117 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,74 @@ | ||
# This workflow will build a docker container, publish it to Google Container Registry, and deploy it to GKE when there is a push to the "master" branch. | ||
# | ||
# To configure this workflow: | ||
# | ||
# 1. Ensure that your repository contains the necessary configuration for your Google Kubernetes Engine cluster, including deployment.yml, kustomization.yml, service.yml, etc. | ||
# | ||
# 2. Create and configure a Workload Identity Provider for GitHub (https://github.com/google-github-actions/auth#setting-up-workload-identity-federation) | ||
# | ||
# 3. Change the values for the GAR_LOCATION, GKE_ZONE, GKE_CLUSTER, IMAGE, REPOSITORY and DEPLOYMENT_NAME environment variables (below). | ||
# | ||
# For more support on how to run the workflow, please visit https://github.com/google-github-actions/setup-gcloud/tree/master/example-workflows/gke-kustomize | ||
|
||
name: Build and Deploy to GCP registry | ||
|
||
on: | ||
push: | ||
branches: [ "split", "master" ] | ||
|
||
env: | ||
GAR_LOCATION: asia-northeast1 # TODO: update region of the Artifact Registry | ||
IMAGE: shibuya | ||
|
||
jobs: | ||
setup-build-publish-deploy: | ||
name: Setup, Build, Publish | ||
runs-on: ubuntu-20.04 | ||
environment: production | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.17' | ||
|
||
- id: 'auth' | ||
uses: 'google-github-actions/auth@v1' | ||
with: | ||
credentials_json: '${{ secrets.GCP_CREDENTIALS }}' | ||
token_format: 'access_token' | ||
|
||
- name: Docker configuration | ||
run: |- | ||
echo '${{ steps.auth.outputs.access_token }}' | docker login -u oauth2accesstoken --password-stdin https://$GAR_LOCATION-docker.pkg.dev | ||
# Build the Docker image | ||
- name: Build api | ||
run: |- | ||
cd shibuya && make api_image component=api | ||
- name: Build controller | ||
run: |- | ||
cd shibuya && make controller_image component=controller | ||
- name: Configure Git | ||
run: | | ||
git config user.name "$GITHUB_ACTOR" | ||
git config user.email "$GITHUB_ACTOR@users.noreply.github.com" | ||
- name: Install Helm | ||
uses: azure/setup-helm@v3 | ||
with: | ||
version: "v3.13.3" | ||
|
||
- name: Run chart-releaser | ||
uses: helm/chart-releaser-action@v1.5.0 | ||
with: | ||
charts_dir: shibuya/install | ||
env: | ||
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" |
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 was deleted.
Oops, something went wrong.
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,2 @@ | ||
*.tgz | ||
shibuya-install/* |
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,41 +1,18 @@ | ||
FROM gcr.io/shibuya-214807/golang:1.17-stretch AS builder | ||
FROM ubuntu:18.04 | ||
|
||
RUN apt-get update && apt-get install -y curl | ||
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl \ | ||
&& chmod +x ./kubectl \ | ||
&& mv ./kubectl /usr/local/bin/kubectl | ||
|
||
WORKDIR /go/src/shibuya | ||
|
||
ENV GO111MODULE on | ||
ADD go.mod . | ||
ADD go.sum . | ||
RUN go mod download | ||
|
||
COPY . /go/src/shibuya | ||
|
||
RUN GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o /go/bin/shibuya | ||
|
||
# Use only binaries from above image for running the app | ||
FROM gcr.io/shibuya-214807/ubuntu:18.04 | ||
|
||
COPY --from=builder /go/bin/shibuya /usr/local/bin/shibuya | ||
COPY --from=builder /usr/local/bin/kubectl /usr/local/bin/kubectl | ||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt | ||
|
||
RUN mkdir /auth | ||
ADD ./shibuya-gcp.json /auth/shibuya-gcp.json | ||
ARG binary_name=shibuya | ||
ADD ./build/${binary_name} /usr/local/bin/${binary_name} | ||
|
||
ENV GOOGLE_APPLICATION_CREDENTIALS /auth/shibuya-gcp.json | ||
|
||
ARG env=local | ||
ENV env ${env} | ||
ARG lab_image="" | ||
ENV lab_image ${lab_image} | ||
ARG proxy="" | ||
ENV http_proxy ${proxy} | ||
ENV https_proxy ${proxy} | ||
|
||
COPY config/kube_configs /root/.kube | ||
COPY config.json /config.json | ||
COPY ./ui/ / | ||
CMD ["shibuya"] | ||
ENV binary=${binary_name} | ||
CMD ${binary} |
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,27 @@ | ||
registry=$(GAR_LOCATION)-docker.pkg.dev/$(GCP_PROJECT) | ||
repository = shibuya | ||
tag=$(GITHUB_SHA) | ||
img=$(registry)/$(repository)/$(component):$(tag) | ||
|
||
.PHONY: api_build | ||
api_build: | ||
sh build.sh | ||
|
||
.PHONY: api_image | ||
api_image: api_build | ||
docker build -t $(img) -f Dockerfile . | ||
docker push $(img) | ||
|
||
.PHONY: controller_build | ||
controller_build: | ||
sh build.sh controller | ||
|
||
.PHONY: controller_image | ||
controller_image: controller_build | ||
docker build -t $(img) -f Dockerfile --build-arg="binary_name=shibuya-controller" . | ||
docker push $(img) | ||
|
||
.PHONY: helm_charts | ||
helm_charts: | ||
helm create shibuya-install | ||
helm package shibuya-install/ |
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
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,14 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/rakutentech/shibuya/shibuya/controller" | ||
log "github.com/sirupsen/logrus" | ||
) | ||
|
||
// This func keep tracks of all the running engines. They should just rely on the data in the db | ||
// and make necessary queries to the scheduler. | ||
func main() { | ||
log.Info("Controller is running in distributed mode") | ||
controller := controller.NewController() | ||
controller.IsolateBackgroundTasks() | ||
} |
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
Oops, something went wrong.