Skip to content

Commit

Permalink
Merge pull request #723 from qmhu/update-resource
Browse files Browse the repository at this point in the history
feat: resource update for qos init
  • Loading branch information
qmhu authored Mar 24, 2023
2 parents f7f3bf2 + 03e997d commit ff6429a
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 34 deletions.
4 changes: 0 additions & 4 deletions initializer/Dockerfile

This file was deleted.

4 changes: 0 additions & 4 deletions initializer/podinfo

This file was deleted.

22 changes: 0 additions & 22 deletions initializer/qos-checking.sh

This file was deleted.

9 changes: 9 additions & 0 deletions pkg/webhooks/pod/mutating.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import (
"github.com/gocrane/crane/pkg/ensurance/config"
)

var (
SystemNamespaces = map[string]interface{}{"kube-system": nil, "crane-system": nil}
)

type MutatingAdmission struct {
Config *config.QOSConfig
}
Expand All @@ -23,8 +27,13 @@ func (m *MutatingAdmission) Default(ctx context.Context, obj runtime.Object) err
if !ok {
return fmt.Errorf("expected a Pod but got a %T", obj)
}

klog.Infof("Into Pod injection %s/%s", pod.Namespace, pod.Name)

if _, exist := SystemNamespaces[pod.Namespace]; exist {
return nil
}

if m.Config == nil || !m.Config.QOSInitializer.Enable {
return nil
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/webhooks/pod/mutating_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ func TestDefaultingPodQOSInitializer(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{
Name: "pod1",
Labels: map[string]string{
"app": "nginx",
"app": "nginx",
"type": "offline",
},
},
}
Expand Down
7 changes: 4 additions & 3 deletions tools/initializer/resource.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spec:
operator: Exists
containers:
- name: craned
image: docker.io/gocrane/craned:v0.9.0-67-g392a9999
image: docker.io/gocrane/craned:v0.9.0-98-gbc4b90fe
imagePullPolicy: IfNotPresent
env:
- name: TZ
Expand All @@ -32,10 +32,11 @@ spec:
fieldPath: metadata.namespace
command:
- /craned
- --prometheus-address=http://prometheus-server.crane-system.svc.cluster.local:8080
- --prometheus-address=http://kvass-thanos.kube-system:9090
- --feature-gates=Analysis=true,TimeSeriesPrediction=true,Autoscaling=true,QOSInitializer=true
- --recommendation-configuration-file=/tmp/recommendation-config/config.yaml
- --qos-config-file=/tmp/recommendation-config/qos.yaml
- --leader-elect=false
- -v=4
volumeMounts:
- mountPath: /tmp/k8s-webhook-server/serving-certs
Expand Down Expand Up @@ -104,7 +105,7 @@ data:
app: nginx
initContainerTemplate:
name: crane-qos-initializer
image: docker.io/gocrane/qos-init:v0.1.4
image: docker.io/gocrane/qos-init:v0.1.6
imagePullPolicy: IfNotPresent
command:
- sh
Expand Down

0 comments on commit ff6429a

Please sign in to comment.