-
Notifications
You must be signed in to change notification settings - Fork 386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize qos initializer. #878
Conversation
🎉 Successfully Build Images. Docker RegistryOverview: https://hub.docker.com/u/gocrane
Quick Deploy - Helm helm repo add crane https://finops-helm.pkg.coding.net/gocrane/gocrane
helm install crane -n crane-system --create-namespace \
--set craned.image.repository=gocrane/craned \
--set craned.image.tag=pr-878-74132af \
--set metricAdapter.image.repository=gocrane/metric-adapter \
--set metricAdapter.image.tag=pr-878-74132af \
--set craneAgent.image.repository=gocrane/crane-agent \
--set craneAgent.image.tag=pr-878-74132af \
--set cranedDashboard.image.repository=gocrane/dashboard \
--set cranedDashboard.image.tag=pr-878-74132af crane/crane Coding RegistryOverview: https://finops.coding.net/public-artifacts/gocrane/crane/packages
Quick Deploy - Helm helm repo add crane https://finops-helm.pkg.coding.net/gocrane/gocrane
helm install crane -n crane-system --create-namespace \
--set craned.image.repository=finops-docker.pkg.coding.net/gocrane/crane/craned \
--set craned.image.tag=pr-878-74132af \
--set metricAdapter.image.repository=finops-docker.pkg.coding.net/gocrane/crane/metric-adapter \
--set metricAdapter.image.tag=pr-878-74132af \
--set craneAgent.image.repository=finops-docker.pkg.coding.net/gocrane/crane/crane-agent \
--set craneAgent.image.tag=pr-878-74132af \
--set cranedDashboard.image.repository=finops-docker.pkg.coding.net/gocrane/crane/dashboard \
--set cranedDashboard.image.tag=pr-878-74132af crane/crane Ghcr RegistryOverview: https://github.com/orgs/gocrane/packages?repo_name=crane
Quick Deploy - Helm helm repo add crane https://finops-helm.pkg.coding.net/gocrane/gocrane
helm install crane -n crane-system --create-namespace \
--set craned.image.repository=ghcr.io/gocrane/crane/craned \
--set craned.image.tag=pr-878-74132af \
--set metricAdapter.image.repository=ghcr.io/gocrane/crane/metric-adapter \
--set metricAdapter.image.tag=pr-878-74132af \
--set craneAgent.image.repository=ghcr.io/gocrane/crane/crane-agent \
--set craneAgent.image.tag=pr-878-74132af \
--set cranedDashboard.image.repository=ghcr.io/gocrane/crane/dashboard \
--set cranedDashboard.image.tag=pr-878-74132af crane/crane |
tools/initializer/resource.yaml
Outdated
matchLabels: | ||
app: nginx | ||
initContainerTemplate: | ||
name: crane-qos-initializer | ||
name: qos-initializer-container |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: name: qos-initializer is fine
image: docker.io/gocrane/qos-init:v0.1.6 | ||
imagePullPolicy: IfNotPresent | ||
args: | ||
- "while ! grep -q gocrane.io/cpu-qos /etc/podinfo/annotations; do sleep 1; done; echo cpu qos setting competed;" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if it's just a shell call, do we still need qos-init image, can it be changed to pause?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, pause does not contain those shell command, ignore this
pkg/webhooks/pod/mutating.go
Outdated
@@ -28,7 +40,7 @@ func (m *MutatingAdmission) Default(ctx context.Context, obj runtime.Object) err | |||
return fmt.Errorf("expected a Pod but got a %T", obj) | |||
} | |||
|
|||
klog.Infof("Into Pod injection %s/%s", pod.Namespace, pod.Name) | |||
klog.Infof("mutating started for pod %s/%s", pod.Namespace, pod.Name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A code standard, all logs start with Capital letters, and please check if a log level should be added and disabled the msg by default. same suggestion to all newly added logs
pkg/webhooks/pod/mutating.go
Outdated
if m.Config.QOSInitializer.InitContainerTemplate != nil { | ||
pod.Spec.InitContainers = append(pod.Spec.InitContainers, *m.Config.QOSInitializer.InitContainerTemplate) | ||
if !ls.Matches(labels.Set(pod.Labels)) { | ||
klog.Infof("injection skipped: webhook is not interested in the pod") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
injection->Injection, and this is a debug log, I suggest to add a log level and do not enable by default, and if we have label config for the webhook, this line of code should not be called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact, I don't like this logic. But in order to be compatible with the previous design, I still leave the matching here.
pkg/ensurance/analyzer/analyzer.go
Outdated
@@ -6,6 +6,8 @@ import ( | |||
"strings" | |||
"time" | |||
|
|||
"github.com/gocrane/crane/pkg/ensurance/util" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this to the crane import section
58fdc3f
to
74132af
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What type of PR is this?
Feature.
What this PR does / why we need it:
Optimize qos initializer webhook. Inject init-container and init-volume only when pod matched by offline pod qos.
Which issue(s) this PR fixes:
From #876
Special notes for your reviewer: