-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
402 additions
and
17 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
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,16 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/run-ai/fake-gpu-operator/internal/common/app" | ||
"github.com/run-ai/fake-gpu-operator/internal/common/config" | ||
"github.com/run-ai/fake-gpu-operator/internal/common/constants" | ||
status_updater "github.com/run-ai/fake-gpu-operator/internal/kwok-gpu-device-plugin" | ||
) | ||
|
||
func main() { | ||
requiredEnvVars := []string{constants.EnvTopologyCmName, constants.EnvTopologyCmNamespace, constants.EnvFakeGpuOperatorNs} | ||
config.ValidateConfig(requiredEnvVars) | ||
|
||
appRunner := app.NewAppRunner(&status_updater.StatusUpdaterApp{}) | ||
appRunner.Run() | ||
} |
26 changes: 26 additions & 0 deletions
26
deploy/fake-gpu-operator/templates/kwok-gpu-device-plugin/clusterrole.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,26 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: fake-kwok-gpu-device-plugin | ||
rules: | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- nodes | ||
- nodes/status | ||
verbs: | ||
- update | ||
- list | ||
- get | ||
- watch | ||
- patch | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- configmaps | ||
verbs: | ||
- get | ||
- update | ||
- create | ||
- list | ||
- delete |
12 changes: 12 additions & 0 deletions
12
deploy/fake-gpu-operator/templates/kwok-gpu-device-plugin/clusterrolebinding.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,12 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: fake-kwok-gpu-device-plugin | ||
roleRef: | ||
kind: ClusterRole | ||
apiGroup: rbac.authorization.k8s.io | ||
name: fake-kwok-gpu-device-plugin | ||
subjects: | ||
- kind: ServiceAccount | ||
name: kwok-gpu-device-plugin | ||
namespace: "{{ .Release.Namespace }}" |
39 changes: 39 additions & 0 deletions
39
deploy/fake-gpu-operator/templates/kwok-gpu-device-plugin/deployment.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,39 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: kwok-gpu-device-plugin | ||
annotations: | ||
checksum/topology: {{ include (print $.Template.BasePath "/topology-cm.yml") . | sha256sum }} | ||
labels: | ||
app: kwok-gpu-device-plugin | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: kwok-gpu-device-plugin | ||
component: kwok-gpu-device-plugin | ||
replicas: 1 | ||
template: | ||
metadata: | ||
annotations: | ||
checksum/topology: {{ include (print $.Template.BasePath "/topology-cm.yml") . | sha256sum }} | ||
labels: | ||
app: kwok-gpu-device-plugin | ||
component: kwok-gpu-device-plugin | ||
spec: | ||
containers: | ||
- name: kwok-gpu-device-plugin | ||
image: "{{ .Values.kwokGpuDevicePlugin.image.repository }}:{{ .Values.kwokGpuDevicePlugin.image.tag }}" | ||
imagePullPolicy: "{{ .Values.kwokGpuDevicePlugin.image.pullPolicy }}" | ||
resources: | ||
{{- toYaml .Values.kwokGpuDevicePlugin.resources | nindent 12 }} | ||
env: | ||
- name: TOPOLOGY_CM_NAME | ||
value: topology | ||
- name: TOPOLOGY_CM_NAMESPACE | ||
value: "{{ .Release.Namespace }}" | ||
- name: FAKE_GPU_OPERATOR_NAMESPACE | ||
value: "{{ .Release.Namespace }}" | ||
restartPolicy: Always | ||
serviceAccountName: kwok-gpu-device-plugin | ||
imagePullSecrets: | ||
- name: gcr-secret |
13 changes: 13 additions & 0 deletions
13
deploy/fake-gpu-operator/templates/kwok-gpu-device-plugin/role.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,13 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: Role | ||
metadata: | ||
name: plugin | ||
rules: | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- configmaps | ||
verbs: | ||
- list | ||
- get | ||
- watch |
12 changes: 12 additions & 0 deletions
12
deploy/fake-gpu-operator/templates/kwok-gpu-device-plugin/rolebinding.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,12 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
name: fake-kwok-gpu-device-plugin | ||
roleRef: | ||
kind: Role | ||
apiGroup: rbac.authorization.k8s.io | ||
name: fake-kwok-gpu-device-plugin | ||
subjects: | ||
- kind: ServiceAccount | ||
name: kwok-gpu-device-plugin | ||
namespace: "{{ .Release.Namespace }}" |
4 changes: 4 additions & 0 deletions
4
deploy/fake-gpu-operator/templates/kwok-gpu-device-plugin/serviceaccount.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,4 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: kwok-gpu-device-plugin |
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,77 @@ | ||
package kwokgdp | ||
|
||
import ( | ||
"sync" | ||
|
||
"k8s.io/client-go/dynamic" | ||
"k8s.io/client-go/kubernetes" | ||
"k8s.io/client-go/rest" | ||
|
||
"github.com/spf13/viper" | ||
ctrl "sigs.k8s.io/controller-runtime" | ||
|
||
"github.com/run-ai/fake-gpu-operator/internal/common/constants" | ||
cmcontroller "github.com/run-ai/fake-gpu-operator/internal/kwok-gpu-device-plugin/controllers/configmap" | ||
"github.com/run-ai/fake-gpu-operator/internal/status-updater/controllers" | ||
) | ||
|
||
var InClusterConfigFn = ctrl.GetConfigOrDie | ||
var KubeClientFn = func(c *rest.Config) kubernetes.Interface { | ||
return kubernetes.NewForConfigOrDie(c) | ||
} | ||
|
||
var DynamicClientFn = func(c *rest.Config) dynamic.Interface { | ||
return dynamic.NewForConfigOrDie(c) | ||
} | ||
|
||
type StatusUpdaterAppConfiguration struct { | ||
TopologyCmName string `mapstructure:"TOPOLOGY_CM_NAME" validate:"required"` | ||
TopologyCmNamespace string `mapstructure:"TOPOLOGY_CM_NAMESPACE" validate:"required"` | ||
} | ||
|
||
type StatusUpdaterApp struct { | ||
Controllers []controllers.Interface | ||
kubeClient kubernetes.Interface | ||
stopCh chan struct{} | ||
wg *sync.WaitGroup | ||
} | ||
|
||
func (app *StatusUpdaterApp) Run() { | ||
app.wg.Add(len(app.Controllers)) | ||
for _, controller := range app.Controllers { | ||
go func(controller controllers.Interface) { | ||
defer app.wg.Done() | ||
controller.Run(app.stopCh) | ||
}(controller) | ||
} | ||
|
||
app.wg.Wait() | ||
} | ||
|
||
func (app *StatusUpdaterApp) Init(stopCh chan struct{}) { | ||
app.stopCh = stopCh | ||
|
||
clusterConfig := InClusterConfigFn() | ||
clusterConfig.QPS = 100 | ||
clusterConfig.Burst = 200 | ||
|
||
app.wg = &sync.WaitGroup{} | ||
|
||
app.kubeClient = KubeClientFn(clusterConfig) | ||
|
||
app.Controllers = append( | ||
app.Controllers, cmcontroller.NewConfigMapController( | ||
app.kubeClient, viper.GetString(constants.EnvTopologyCmNamespace), | ||
), | ||
) | ||
} | ||
|
||
func (app *StatusUpdaterApp) Name() string { | ||
return "StatusUpdater" | ||
} | ||
|
||
func (app *StatusUpdaterApp) GetConfig() interface{} { | ||
var config StatusUpdaterAppConfiguration | ||
|
||
return config | ||
} |
Oops, something went wrong.