Skip to content

Commit

Permalink
Merge pull request #133 from kingdonb/fixup-deployment-scale
Browse files Browse the repository at this point in the history
fix(charts): controller needs the "patch" perm
  • Loading branch information
Cryptophobia authored Oct 6, 2020
2 parents 5b37960 + bb05432 commit 56399ff
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion charts/controller/templates/controller-clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ rules:
verbs: ["get", "list", "create", "update", "delete"]
- apiGroups: ["extensions", "apps"]
resources: ["deployments/scale", "replicasets/scale"]
verbs: ["get", "update"]
verbs: ["get", "update", "patch"]
- apiGroups: ["extensions", "autoscaling"]
resources: ["horizontalpodautoscalers"]
verbs: ["get", "list", "create", "update", "delete"]
Expand Down
14 changes: 13 additions & 1 deletion rootfs/scheduler/resources/scale.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
from scheduler.resources import Resource
from scheduler.exceptions import KubeHTTPException

from packaging.version import parse


class Scale(Resource):

@property
def scale_api_version(self):
# API locations have changed since 1.9 and deprecated in 1.16
# https://kubernetes.io/blog/2019/07/18/api-deprecations-in-1-16/
if self.version() >= parse("1.9.0"):
return 'autoscaling/v1'

return 'extensions/v1beta1'

def manifest(self, namespace, name, replicas):
manifest = {
'kind': 'Scale',
'apiVersion': self.api_version,
'apiVersion': self.scale_api_version,
'metadata': {
'namespace': namespace,
'name': name,
Expand Down

0 comments on commit 56399ff

Please sign in to comment.