Skip to content

Commit

Permalink
Merge pull request #6 from chxk/feat-bagua
Browse files Browse the repository at this point in the history
add deploy operator
  • Loading branch information
chxk authored Jun 30, 2021
2 parents 22a6f3b + f010823 commit 60b2c78
Show file tree
Hide file tree
Showing 6 changed files with 147 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ IMAGE_TAG_BASE ?= kuaishou.com/operator
BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:v$(VERSION)

# Image URL to use all building/pushing image targets
IMG ?= controller:latest
IMG ?= baguasys/operator:latest
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true,crdVersions=v1beta1,preserveUnknownFields=true"

Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,25 @@ This repository implements a kubernetes operator for Bagua distributed training


### Installation
- Deploy operator locally
- Run the operator locally
```shell

git clone https://github.com/BaguaSys/operator.git
cd operator

# install crd
kubectl apply -f config/crd/bases/bagua.kuaishou.com_baguas.yaml

go run ./main.go
```
- Deploy the operator
```shell

git clone https://github.com/BaguaSys/operator.git
cd operator

bash deploy/deploy.sh
```


### Examples
Expand Down
69 changes: 69 additions & 0 deletions deploy/crd/bagua.kuaishou.com_baguas.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@

---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.4.1
creationTimestamp: null
name: baguas.bagua.kuaishou.com
spec:
additionalPrinterColumns:
- JSONPath: .metadata.namespace
name: Namespace
type: string
- JSONPath: .status.phase
name: Phase
type: string
- JSONPath: .metadata.creationTimestamp
name: Age
type: date
group: bagua.kuaishou.com
names:
kind: Bagua
listKind: BaguaList
plural: baguas
shortNames:
- bg
singular: bagua
scope: Namespaced
subresources:
status: {}
validation:
openAPIV3Schema:
description: Bagua is the Schema for the baguas API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: 'BaguaSpec defines the desired state
of Bagua'
properties:
enableElastic:
type: boolean
maxReplicas:
format: int32
type: integer
minReplicas:
format: int32
minimum: 1
type: integer
rdzvEndpoint:
type: string
type: object
type: object
version: v1alpha1
versions:
- name: v1alpha1
served: true
storage: true
6 changes: 6 additions & 0 deletions deploy/crd/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
kind: Namespace
metadata:
labels:
app: bagua
name: bagua
18 changes: 18 additions & 0 deletions deploy/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
DIR=$(
cd "$(dirname "$0")"
pwd
)

function install() {
for file in $(ls $DIR/crd); do
kubectl apply -f $DIR/crd/$file
done
}

function deploy() {
install
kubectl apply -f $DIR/deployment.yaml
}

deploy
43 changes: 43 additions & 0 deletions deploy/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: bagua
name: bagua-operator
spec:
replicas: 1
selector:
matchLabels:
app: bagua-operator
strategy:
type: Recreate
rollingUpdate: null
template:
metadata:
labels:
app: bagua-operator
spec:
containers:
- name: ares-operator
image: baguasys/operator:latest
imagePullPolicy: "IfNotPresent"
workingDir: /home/work
command:
- ./manager
ports:
- name: http
containerPort: 8081
protocol: TCP
readinessProbe:
httpGet:
path:
/readyz
port: http
initialDelaySeconds: 15
periodSeconds: 10
livenessProbe:
httpGet:
path:
/healthz
port: http
initialDelaySeconds: 15
periodSeconds: 10

0 comments on commit 60b2c78

Please sign in to comment.