-
Notifications
You must be signed in to change notification settings - Fork 402
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 akanso/design-1b
Operator with Design 1B
- Loading branch information
Showing
68 changed files
with
14,514 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,54 @@ | ||
name: Go-build-and-test | ||
|
||
on: | ||
push: | ||
branches: | ||
- design-1b | ||
- master | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
|
||
build: | ||
env: | ||
working-directory: ./msft-operator/ray-operator | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- name: Set up Go 1.x | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: ^1.13 | ||
|
||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: design-1b | ||
|
||
- name: list directories | ||
working-directory: ${{env.working-directory}} | ||
run: ls -R | ||
|
||
- name: install kubebuilder | ||
run: | | ||
wget https://github.com/kubernetes-sigs/kubebuilder/releases/download/v2.0.0-alpha.1/kubebuilder_2.0.0-alpha.1_linux_amd64.tar.gz | ||
tar -zxvf kubebuilder_2.0.0-alpha.1_linux_amd64.tar.gz | ||
sudo mv kubebuilder_2.0.0-alpha.1_linux_amd64 /usr/local/kubebuilder | ||
- name: Get dependencies | ||
working-directory: ${{env.working-directory}} | ||
run: | | ||
go get -v -t -d ./... | ||
if [ -f Gopkg.toml ]; then | ||
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh | ||
dep ensure | ||
fi | ||
- name: Build | ||
run: go build -v ./... | ||
working-directory: ${{env.working-directory}} | ||
|
||
- name: Test | ||
run: go test -v ./... -cover | ||
working-directory: ${{env.working-directory}} |
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 @@ | ||
# Ignore backup files. | ||
*~ | ||
# Ignore Vim swap files. | ||
.*.swp | ||
# Ignore files generated by IDEs. | ||
/.classpath | ||
/.factorypath | ||
/.idea/ | ||
/.ijwb/ | ||
/.project | ||
/.settings | ||
/.vscode/ | ||
/bazel.iml | ||
# Ignore all bazel-* symlinks. There is no full list since this can change | ||
# based on the name of the directory bazel is cloned into. | ||
/bazel-* | ||
# Ignore outputs generated during Bazel bootstrapping. | ||
/output/ | ||
# Ignore jekyll build output. | ||
/production | ||
/.sass-cache | ||
# Bazelisk version file | ||
.bazelversion | ||
# User-specific .bazelrc | ||
user.bazelrc | ||
|
||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
bin/ | ||
# Dependency directories (remove the comment below to include it) | ||
vendor/ | ||
|
||
# Project related ignores | ||
/ray-operator | ||
|
||
config/manager/my-kustomization.yaml | ||
config/manager/my-manager.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,28 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") | ||
load("@bazel_gazelle//:def.bzl", "gazelle") | ||
|
||
# gazelle:prefix ray-operator | ||
# gazelle:build_file_name BUILD.bazel | ||
gazelle(name = "gazelle") | ||
|
||
go_library( | ||
name = "go_default_library", | ||
srcs = ["main.go"], | ||
importpath = "ray-operator", | ||
visibility = ["//visibility:private"], | ||
deps = [ | ||
"//api/v1alpha1:go_default_library", | ||
"//controllers:go_default_library", | ||
"@io_k8s_apimachinery//pkg/runtime:go_default_library", | ||
"@io_k8s_client_go//kubernetes/scheme:go_default_library", | ||
"@io_k8s_client_go//plugin/pkg/client/auth/gcp:go_default_library", | ||
"@io_k8s_sigs_controller_runtime//:go_default_library", | ||
"@io_k8s_sigs_controller_runtime//pkg/log/zap:go_default_library", | ||
], | ||
) | ||
|
||
go_binary( | ||
name = "ray-operator", | ||
embed = [":go_default_library"], | ||
visibility = ["//visibility:public"], | ||
) |
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 @@ | ||
# Build the manager binary | ||
FROM golang:1.12.5 as builder | ||
|
||
WORKDIR /workspace | ||
# Copy the Go Modules manifests | ||
COPY go.mod go.mod | ||
COPY go.sum go.sum | ||
# cache deps before building and copying source so that we don't need to re-download as much | ||
# and so that source changes don't invalidate our downloaded layer | ||
RUN go mod download | ||
|
||
# Copy the go source | ||
COPY main.go main.go | ||
COPY api/ api/ | ||
COPY controllers/ controllers/ | ||
|
||
# Build | ||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go | ||
|
||
# Use distroless as minimal base image to package the manager binary | ||
# Refer to https://github.com/GoogleContainerTools/distroless for more details | ||
FROM gcr.io/distroless/static:nonroot | ||
WORKDIR / | ||
COPY --from=builder /workspace/manager . | ||
USER nonroot:nonroot | ||
|
||
ENTRYPOINT ["/manager"] |
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,76 @@ | ||
|
||
# Image URL to use all building/pushing image targets | ||
IMG ?= ray-controller:latest | ||
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion) | ||
CRD_OPTIONS ?= "crd:trivialVersions=true" | ||
|
||
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) | ||
ifeq (,$(shell go env GOBIN)) | ||
GOBIN=$(shell go env GOPATH)/bin | ||
else | ||
GOBIN=$(shell go env GOBIN) | ||
endif | ||
|
||
all: manager | ||
|
||
# Run tests | ||
test: generate fmt vet manifests | ||
go test ./... -coverprofile cover.out | ||
|
||
# Build manager binary | ||
manager: generate fmt vet | ||
go build -o bin/manager main.go | ||
|
||
# Run against the configured Kubernetes cluster in ~/.kube/config | ||
run: generate fmt vet manifests | ||
go run ./main.go | ||
|
||
# Install CRDs into a cluster | ||
install: manifests | ||
kustomize build config/crd | kubectl apply -f - | ||
|
||
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config | ||
deploy: manifests | ||
cd config/manager && kustomize edit set image controller=${IMG} | ||
kustomize build config/default | kubectl apply -f - | ||
|
||
# Generate manifests e.g. CRD, RBAC etc. | ||
manifests: controller-gen | ||
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases | ||
|
||
# Run go fmt against code | ||
fmt: | ||
go fmt ./... | ||
|
||
# Run go vet against code | ||
vet: | ||
go vet ./... | ||
|
||
# Generate code | ||
generate: controller-gen | ||
$(CONTROLLER_GEN) object:headerFile=./hack/boilerplate.go.txt paths="./..." | ||
|
||
# Build the docker image | ||
docker-build: test | ||
docker build . -t ${IMG} | ||
|
||
# Push the docker image | ||
docker-push: | ||
docker push ${IMG} | ||
|
||
# find or download controller-gen | ||
# download controller-gen if necessary | ||
controller-gen: | ||
ifeq (, $(shell which controller-gen)) | ||
@{ \ | ||
set -e ;\ | ||
CONTROLLER_GEN_TMP_DIR="$$(mktemp -d)" ;\ | ||
cd "$$CONTROLLER_GEN_TMP_DIR" ;\ | ||
go mod init tmp ;\ | ||
go get sigs.k8s.io/controller-tools/cmd/[email protected] ;\ | ||
rm -rf "$$CONTROLLER_GEN_TMP_DIR" ;\ | ||
} | ||
CONTROLLER_GEN=$(GOBIN)/controller-gen | ||
else | ||
CONTROLLER_GEN=$(shell which controller-gen) | ||
endif |
Oops, something went wrong.