Skip to content

Commit 0f0a9e9

Browse files
committed
fix: init controller
1 parent ca40bab commit 0f0a9e9

29 files changed

Lines changed: 1009 additions & 63 deletions

.github/workflows/pr-title.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: "Validate PR Title"
2+
3+
on:
4+
pull_request_target:
5+
types: [opened, edited, synchronize]
6+
7+
jobs:
8+
main:
9+
name: Validate PR title
10+
runs-on: ubuntu-latest
11+
steps:
12+
# https://github.com/amannn/action-semantic-pull-request/releases
13+
- uses: amannn/action-semantic-pull-request@v4.2.0
14+
env:
15+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16+
with:
17+
# Allowed types: https://github.com/commitizen/conventional-commit-types
18+
types: |
19+
fix
20+
feat
21+
docs
22+
style
23+
refactor
24+
perf
25+
test
26+
build
27+
ci
28+
chore
29+
revert
30+
requireScope: false
31+
subjectPattern: ^[A-Z].+$
32+
subjectPatternError: |
33+
The subject "{subject}" found in the pull request title "{title}"
34+
didn't match the configured pattern. Please ensure that the subject
35+
starts with an uppercase character.
36+
wip: true
37+
validateSingleCommit: true
38+
validateSingleCommitMatchesPrTitle: true

.github/workflows/release.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
release:
11+
name: Release
12+
runs-on: ubuntu-latest
13+
# Skip running release workflow on forks
14+
if: github.repository_owner == 'wandb'
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v2
18+
with:
19+
persist-credentials: false
20+
fetch-depth: 0
21+
22+
- name: Versioning
23+
id: version
24+
uses: cycjimmy/semantic-release-action@v3
25+
with:
26+
semantic_version: 19.0.2
27+
extra_plugins: |
28+
@semantic-release/changelog@6.0.1
29+
@semantic-release/git@10.0.1
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.WANDB_RELEASE_TOKEN }}
32+
33+
- name: Set up QEMU
34+
uses: docker/setup-qemu-action@v2
35+
- name: Set up Docker Buildx
36+
uses: docker/setup-buildx-action@v2
37+
38+
- name: Login to Docker Hub
39+
uses: docker/login-action@v2
40+
with:
41+
username: ${{ secrets.DOCKERHUB_USERNAME }}
42+
password: ${{ secrets.DOCKERHUB_TOKEN }}
43+
44+
- name: Build and Push
45+
run: |
46+
VERSION=${{ steps.release.outputs.new_release_version }}
47+
make docker-build docker-push
48+
49+
VERSION=${{ steps.release.outputs.new_release_major_version }}.${{ steps.release.outputs.new_release_minor_version }}
50+
make docker-build docker-push
51+
52+
VERSION=${{ steps.release.outputs.new_release_major_version }}
53+
make docker-build docker-push
54+
env:
55+
IMAGE_TAG_BASE: wandb/controller

Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build the manager binary
2-
FROM golang:1.19 as builder
2+
FROM golang:1.20 as builder
33
ARG TARGETOS
44
ARG TARGETARCH
55

@@ -14,14 +14,15 @@ RUN go mod download
1414
# Copy the go source
1515
COPY main.go main.go
1616
COPY api/ api/
17+
COPY pkg/ pkg/
1718
COPY controllers/ controllers/
1819

1920
# Build
2021
# the GOARCH has not a default value to allow the binary be built according to the host where the command
2122
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
2223
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
2324
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
24-
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager main.go
25+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager main.go
2526

2627
# Use distroless as minimal base image to package the manager binary
2728
# Refer to https://github.com/GoogleContainerTools/distroless for more details
@@ -30,4 +31,6 @@ WORKDIR /
3031
COPY --from=builder /workspace/manager .
3132
USER 65532:65532
3233

34+
ENV GIN_MODE=release
35+
3336
ENTRYPOINT ["/manager"]

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# To re-generate a bundle for another specific version without changing the standard setup, you can:
44
# - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2)
55
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
6-
VERSION ?= 0.0.1
6+
VERSION ?= latest
77

88
# CHANNELS define the bundle channels used in the bundle.
99
# Add a new line here if you would like to change its default config. (E.g CHANNELS = "candidate,fast,stable")
@@ -28,8 +28,8 @@ BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
2828
# This variable is used to construct full image tags for bundle and catalog images.
2929
#
3030
# For example, running 'make bundle-build bundle-push catalog-build catalog-push' will build and push both
31-
# wandb.com/operator-bundle:$VERSION and wandb.com/operator-catalog:$VERSION.
32-
IMAGE_TAG_BASE ?= wandb.com/operator
31+
# wandb/operator-bundle:$VERSION and wandb/operator-catalog:$VERSION.
32+
IMAGE_TAG_BASE ?= wandb/controller
3333

3434
# BUNDLE_IMG defines the image:tag used for the bundle.
3535
# You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=<some-registry>/<project-name-bundle>:<tag>)
@@ -47,7 +47,7 @@ ifeq ($(USE_IMAGE_DIGESTS), true)
4747
endif
4848

4949
# Image URL to use all building/pushing image targets
50-
IMG ?= controller:latest
50+
IMG ?= $(IMAGE_TAG_BASE):$(VERSION)
5151
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
5252
ENVTEST_K8S_VERSION = 1.26.0
5353

api/v1/weightsandbiases_types.go

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ limitations under the License.
1717
package v1
1818

1919
import (
20+
"encoding/json"
21+
2022
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
23+
runtime "k8s.io/apimachinery/pkg/runtime"
2124
)
2225

2326
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! NOTE: json tags are
@@ -32,9 +35,41 @@ type WeightsAndBiasesSpec struct {
3235
// The specification of Weights & Biases Chart that is used to deploy the
3336
// instance.
3437

35-
Cdk8sVersion string `json:"version,omitempty"`
36-
ReleasePath string `json:"releasePath,omitempty"`
37-
License string `json:"license,omitempty"`
38+
Version string `json:"version,omitempty"`
39+
License string `json:"license,omitempty"`
40+
Config ConfigValues `json:"config,omitempty"`
41+
}
42+
43+
// Unstructured values for rendering GitLab Chart.
44+
// +k8s:deepcopy-gen=false
45+
type ConfigValues struct {
46+
// Object is a JSON compatible map with string, float, int, bool, []interface{}, or
47+
// map[string]interface{} children.
48+
Object map[string]interface{} `json:"-"`
49+
}
50+
51+
// MarshalJSON ensures that the unstructured object produces proper
52+
// JSON when passed to Go's standard JSON library.
53+
func (u *ConfigValues) MarshalJSON() ([]byte, error) {
54+
return json.Marshal(u.Object)
55+
}
56+
57+
// UnmarshalJSON ensures that the unstructured object properly decodes
58+
// JSON when passed to Go's standard JSON library.
59+
func (u *ConfigValues) UnmarshalJSON(data []byte) error {
60+
m := make(map[string]interface{})
61+
if err := json.Unmarshal(data, &m); err != nil {
62+
return err
63+
}
64+
65+
u.Object = m
66+
67+
return nil
68+
}
69+
70+
// Declaring this here prevents it from being generated.
71+
func (u *ConfigValues) DeepCopyInto(out *ConfigValues) {
72+
out.Object = runtime.DeepCopyJSON(u.Object)
3873
}
3974

4075
// WeightsAndBiasesStatus defines the observed state of WeightsAndBiases

api/v1/zz_generated.deepcopy.go

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/chart/.helmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

config/chart/Chart.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v2
2+
name: wandb-operator
3+
description: A Helm chart for Kubernetes
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 0.1.0
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
# It is recommended to use it with quotes.
24+
appVersion: "1.16.0"

config/chart/templates/NOTES.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
1. Get the application URL by running these commands:
2+
{{- if .Values.ingress.enabled }}
3+
{{- range $host := .Values.ingress.hosts }}
4+
{{- range .paths }}
5+
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
6+
{{- end }}
7+
{{- end }}
8+
{{- else if contains "NodePort" .Values.service.type }}
9+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "wandb-operator.fullname" . }})
10+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
11+
echo http://$NODE_IP:$NODE_PORT
12+
{{- else if contains "LoadBalancer" .Values.service.type }}
13+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
14+
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "wandb-operator.fullname" . }}'
15+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "wandb-operator.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
16+
echo http://$SERVICE_IP:{{ .Values.service.port }}
17+
{{- else if contains "ClusterIP" .Values.service.type }}
18+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "wandb-operator.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
19+
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
20+
echo "Visit http://127.0.0.1:8080 to use your application"
21+
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
22+
{{- end }}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "wandb-operator.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "wandb-operator.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "wandb-operator.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "wandb-operator.labels" -}}
37+
helm.sh/chart: {{ include "wandb-operator.chart" . }}
38+
{{ include "wandb-operator.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "wandb-operator.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "wandb-operator.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "wandb-operator.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "wandb-operator.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}

0 commit comments

Comments
 (0)