Skip to content

Commit 20506f4

Browse files
authored
Merge pull request #110 from Cryptophobia/feature/fix-deprecated-apis-1.16
Feature/fix deprecated apis 1.16
2 parents 523ef79 + 5613bc8 commit 20506f4

File tree

8 files changed

+33
-9
lines changed

8 files changed

+33
-9
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
# Deis Controller
33

4+
[![Build Status](https://travis-ci.org/teamhephy/controller.svg?branch=master)](https://travis-ci.org/teamhephy/controller)
45
[![codecov.io](https://codecov.io/github/deis/controller/coverage.svg?branch=master)](https://codecov.io/github/deis/controller?branch=master)
56
[![Docker Repository on Quay](https://quay.io/repository/deisci/controller/status "Docker Repository on Quay")](https://quay.io/repository/deisci/controller)
67

charts/controller/Chart.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
name: controller
2-
home: https://github.com/deisthree/controller
2+
home: https://github.com/teamhephy/controller
33
version: <Will be populated by the ci before publishing the chart>
4-
description: Deis Workflow Controller (API).
4+
description: Hephy Workflow Controller (API).
55
maintainers:
6-
- name: Deis Team
7-
email: engineering@deis.com
6+
- email: team@teamhephy.com

charts/controller/templates/controller-deployment.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1+
{{- if .Capabilities.APIVersions.Has "apps/v1" }}
2+
apiVersion: apps/v1
3+
{{- else if .Capabilities.APIVersions.Has "extensions/v1beta1" }}
14
apiVersion: extensions/v1beta1
5+
{{- else }}
6+
apiVersion: apps/v1
7+
{{- end }}
28
kind: Deployment
39
metadata:
410
name: deis-controller

rootfs/scheduler/mock.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ def delete_pods(pods, current, desired):
336336

337337

338338
def create_pods(url, labels, base, new_pods):
339-
# Start by fetching available pods in the Namespace that fit the profile
339+
# Start by fetching available pods in the Namespace that fit the procfile
340340
# and prune down if needed, Otherwise go into the addition logic here
341341
for _ in range(new_pods):
342342
data = base.copy()
@@ -391,6 +391,8 @@ def upsert_pods(controller, url):
391391
# turn RC / RS (which a Deployment creates) url into pods one
392392
url = url.replace(cache_key(controller['metadata']['name']), '')
393393
if '_replicasets_' in url:
394+
# Try replacing both just in case one or the other exists (api backwards compatibility)
395+
url = url.replace('_replicasets_', '_pods').replace('apis_apps_v1', 'api_v1') # noqa
394396
url = url.replace('_replicasets_', '_pods').replace('apis_extensions_v1beta1', 'api_v1') # noqa
395397
else:
396398
url = url.replace('_replicationcontrollers_', '_pods')
@@ -512,7 +514,9 @@ def manage_replicasets(deployment, url):
512514

513515
def update_deployment_status(namespaced_url, url, deployment, rs):
514516
# Fill out deployment.status for success as pods transition to running state
515-
pod_url = namespaced_url.replace('_replicasets', '_pods').replace('apis_extensions_v1beta1', 'api_v1') # noqa
517+
pod_url = namespaced_url.replace('_replicasets', '_pods').replace('apis_apps_v1', 'api_v1') # noqa
518+
# Try replacing both just in case one or the other exists (api backwards compatibility)
519+
pod_url = pod_url.replace('_replicasets', '_pods').replace('apis_extensions_v1beta1', 'api_v1') # noqa
516520
while True:
517521
# The below needs to be done to emulate Deployment handling things
518522
# always cleanup pods

rootfs/scheduler/resources/deployment.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ class Deployment(Resource):
1313

1414
@property
1515
def api_version(self):
16+
# API locations have changed since 1.9 and deprecated in 1.16
17+
# https://kubernetes.io/blog/2019/07/18/api-deprecations-in-1-16/
1618
if self.version() >= parse("1.9.0"):
17-
return 'extensions/v1beta1'
19+
return 'apps/v1'
1820

1921
return 'extensions/v1beta1'
2022

rootfs/scheduler/resources/ingress.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ def get(self, name=None, **kwargs):
2323
return response
2424

2525
def create(self, ingress, namespace, hostname):
26+
# Ingress API will be deprecated in 1.20 to use networking.k8s.io/v1beta1
27+
# https://kubernetes.io/blog/2019/07/18/api-deprecations-in-1-16/
2628
url = "/apis/extensions/v1beta1/namespaces/%s/ingresses" % namespace
2729

2830
data = {

rootfs/scheduler/resources/replicaset.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
from scheduler.exceptions import KubeHTTPException
22
from scheduler.resources import Resource
33

4+
from packaging.version import parse
5+
46

57
class ReplicaSet(Resource):
68
api_prefix = 'apis'
7-
api_version = 'extensions/v1beta1'
89
short_name = 'rs'
910

11+
@property
12+
def api_version(self):
13+
# API locations have changed since 1.9 and deprecated in 1.16
14+
# https://kubernetes.io/blog/2019/07/18/api-deprecations-in-1-16/
15+
if self.version() >= parse("1.9.0"):
16+
return 'apps/v1'
17+
18+
return 'extensions/v1beta1'
19+
1020
def get(self, namespace, name=None, **kwargs):
1121
"""
1222
Fetch a single ReplicaSet or a list

rootfs/scheduler/tests/test_deployments.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def test_deployment_api_version_1_9_and_up(self):
9696

9797
deployment = copy.copy(self.scheduler.deployment)
9898

99-
expected = 'extensions/v1beta1'
99+
expected = 'apps/v1'
100100

101101
for canonical in cases:
102102
deployment.version = mock.MagicMock(return_value=parse(canonical))

0 commit comments

Comments
 (0)