Skip to content

Commit

Permalink
feat(deployment): set deployment API to apps/v1 if k8s >= 1.9
Browse files Browse the repository at this point in the history
This is basically just manually re-applying the
reverted changes from #86
  • Loading branch information
ess authored and Cryptophobia committed Jul 30, 2019
1 parent 731fc99 commit d51f2f9
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions rootfs/scheduler/resources/deployment.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
from datetime import datetime, timedelta
import json
import time

from packaging.version import parse

from scheduler.resources import Resource
from scheduler.exceptions import KubeException, KubeHTTPException


class Deployment(Resource):
api_prefix = 'apis'
api_version = 'extensions/v1beta1'

@property
def api_version(self):
if self.version() >= parse("1.9.0"):
return 'apps/v1'

return 'extensions/v1beta1'

def get(self, namespace, name=None, **kwargs):
"""
Expand Down Expand Up @@ -43,7 +52,7 @@ def manifest(self, namespace, name, image, entrypoint, command, spec_annotations

manifest = {
'kind': 'Deployment',
'apiVersion': 'extensions/v1beta1',
'apiVersion': self.api_version,
'metadata': {
'name': name,
'labels': labels,
Expand Down

0 comments on commit d51f2f9

Please sign in to comment.