Skip to content

Commit

Permalink
annotation on pods for kubernetes/autoscaler
Browse files Browse the repository at this point in the history
  • Loading branch information
henrod committed Nov 8, 2017
1 parent 665b749 commit d61701e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions models/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ metadata:
namespace: {{.Namespace}}
labels:
app: {{.Name}}
annotations:
cluster-autoscaler.kubernetes.io/safe-to-evict: "true"
spec:
terminationGracePeriodSeconds: {{.ShutdownTimeout}}
{{- if .NodeToleration }}
Expand Down Expand Up @@ -157,10 +159,12 @@ func NewPod(
return pod, err
}

//SetAffinity sets kubernetes Affinity on pod
func (p *Pod) SetAffinity(affinity string) {
p.NodeAffinity = affinity
}

//SetToleration sets kubernetes Toleration on pod
func (p *Pod) SetToleration(toleration string) {
p.NodeToleration = toleration
}
Expand Down
2 changes: 2 additions & 0 deletions models/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ var _ = Describe("Pod", func() {
}
Expect(podv1.Spec.Containers[0].Command).To(HaveLen(3))
Expect(podv1.Spec.Containers[0].Command).To(Equal(command))

Expect(podv1.GetAnnotations()).To(HaveKeyWithValue("cluster-autoscaler.kubernetes.io/safe-to-evict", "true"))
})

It("should create pod without requests and limits", func() {
Expand Down

0 comments on commit d61701e

Please sign in to comment.