Skip to content

Commit

Permalink
feat(control-plane): Implemented the core functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
isala404 committed Feb 14, 2022
1 parent 656c660 commit 55fb9fa
Show file tree
Hide file tree
Showing 9 changed files with 358 additions and 36 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/build-controller.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: controller

on:
push:
branches:
- main

env:
IMAGE_NAME: ghcr.io/mrsupiri/lazy-koala/controller
DOCKER_BUILDKIT: 1

jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
working-directory: control-plane
steps:
- uses: actions/checkout@v2
- uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- run: docker build -t $IMAGE_NAME:latest .
- run: docker tag $IMAGE_NAME:latest $IMAGE_NAME:commit-${GITHUB_SHA:0:8}
- run: docker push $IMAGE_NAME --all-tags
2 changes: 1 addition & 1 deletion control-plane/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

# Image URL to use all building/pushing image targets
IMG ?= controller:latest
IMG ?= ghcr.io/mrsupiri/lazy-koala/controller:latest
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.23

Expand Down
15 changes: 12 additions & 3 deletions control-plane/api/v1alpha1/inspector_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
Expand All @@ -35,8 +36,10 @@ type InspectorSpec struct {
// Important: Run "make" to regenerate code after modifying this file

// Foo is an example field of Inspector. Edit inspector_types.go to remove/update
Service DeploymentReference `json:"service"`
ModelURI string `json:"modelURI"`
DeploymentRef string `json:"deploymentRef"`
ServiceRef string `json:"serviceRef"`
Namespace string `json:"namespace"`
ModelURI string `json:"modelURI"`
}

type Status string
Expand All @@ -51,13 +54,19 @@ const (
type InspectorStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
Inspector DeploymentReference `json:"inspector"`
MonitoredIPs []string `json:"monitoredIPs"`
PodsSelector client.MatchingLabels `json:"podsSelector"`
// +kubebuilder:validation:Enum=Creating;Running;Error
Status Status `json:"status"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:printcolumn:JSONPath=".spec.namespace",name="Namespace",type="string"
//+kubebuilder:printcolumn:JSONPath=".spec.deploymentRef",name="Target Deployment",type="string"
//+kubebuilder:printcolumn:JSONPath=".spec.serviceRef",name="Target ClusterIP",type="string"
//+kubebuilder:printcolumn:JSONPath=".spec.modelURI",name="Model URI",type="string"
//+kubebuilder:printcolumn:JSONPath=".status.status",name="Status",type="string"

// Inspector is the Schema for the inspectors API
type Inspector struct {
Expand Down
30 changes: 29 additions & 1 deletion control-plane/api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,23 @@ spec:
singular: inspector
scope: Namespaced
versions:
- name: v1alpha1
- additionalPrinterColumns:
- jsonPath: .spec.namespace
name: Namespace
type: string
- jsonPath: .spec.deploymentRef
name: Target Deployment
type: string
- jsonPath: .spec.serviceRef
name: Target ClusterIP
type: string
- jsonPath: .spec.modelURI
name: Model URI
type: string
- jsonPath: .status.status
name: Status
type: string
name: v1alpha1
schema:
openAPIV3Schema:
description: Inspector is the Schema for the inspectors API
Expand All @@ -35,39 +51,37 @@ spec:
spec:
description: InspectorSpec defines the desired state of Inspector
properties:
modelURI:
type: string
service:
deploymentRef:
description: Foo is an example field of Inspector. Edit inspector_types.go
to remove/update
properties:
name:
type: string
namespace:
type: string
required:
- name
- namespace
type: object
type: string
modelURI:
type: string
namespace:
type: string
serviceRef:
type: string
required:
- deploymentRef
- modelURI
- service
- namespace
- serviceRef
type: object
status:
description: InspectorStatus defines the observed state of Inspector
properties:
inspector:
monitoredIPs:
description: 'INSERT ADDITIONAL STATUS FIELD - define observed state
of cluster Important: Run "make" to regenerate code after modifying
this file'
properties:
name:
type: string
namespace:
type: string
required:
- name
- namespace
items:
type: string
type: array
podsSelector:
additionalProperties:
type: string
description: MatchingLabels filters the list/delete operation on the
given set of labels.
type: object
status:
enum:
Expand All @@ -76,7 +90,8 @@ spec:
- Error
type: string
required:
- inspector
- monitoredIPs
- podsSelector
- status
type: object
type: object
Expand Down
27 changes: 27 additions & 0 deletions control-plane/config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,33 @@ metadata:
creationTimestamp: null
name: manager-role
rules:
- apiGroups:
- ""
resources:
- configmaps
verbs:
- get
- list
- patch
- update
- watch
- apiGroups:
- ""
resources:
- events
verbs:
- create
- patch
- apiGroups:
- ""
resources:
- namespaces
- pods
- services
verbs:
- get
- list
- watch
- apiGroups:
- lazykoala.lazykoala.isala.me
resources:
Expand Down
12 changes: 12 additions & 0 deletions control-plane/config/samples/helper.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Namespace
metadata:
name: lazy-koala
---
apiVersion: v1
kind: ConfigMap
metadata:
name: gazer-config
namespace: lazy-koala
data:
config.yaml: |
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ kind: Inspector
metadata:
name: inspector-sample
spec:
service:
name: order-service
namespace: default
deploymentRef: service-2-5e7b1ab0
serviceRef: service-2-5e7b1ab0
namespace: default
modelURI: path/to/checkpoint.ckpt

Loading

0 comments on commit 55fb9fa

Please sign in to comment.