From 35cd2720565a8a6bd4992785a923d608ee6182fc Mon Sep 17 00:00:00 2001 From: Cameron Attard Date: Wed, 15 Apr 2020 18:08:03 +1000 Subject: [PATCH] [incubator/buzzfeed-sso] upgrade deprecated Kubernetes APIs (#21445) * [incubator/buzzfeed-sso] upgrade deprecated Kubernetes APIs Signed-off-by: Cameron Attard * [incubator/buzzfeed-sso] add template for apiVersion Signed-off-by: Cameron Attard --- incubator/buzzfeed-sso/Chart.yaml | 2 +- incubator/buzzfeed-sso/templates/_helpers.tpl | 22 +++++++++++++++++++ .../templates/auth-deployment.yaml | 2 +- incubator/buzzfeed-sso/templates/ingress.yaml | 2 +- .../templates/proxy-deployment.yaml | 2 +- 5 files changed, 26 insertions(+), 4 deletions(-) diff --git a/incubator/buzzfeed-sso/Chart.yaml b/incubator/buzzfeed-sso/Chart.yaml index fd6e0ff47944..e9c138684753 100644 --- a/incubator/buzzfeed-sso/Chart.yaml +++ b/incubator/buzzfeed-sso/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v1 description: Single sign-on for your Kubernetes services using Google OAuth name: buzzfeed-sso -version: 0.1.2 +version: 0.1.3 appVersion: 2.0.0 home: https://github.com/buzzfeed/sso sources: diff --git a/incubator/buzzfeed-sso/templates/_helpers.tpl b/incubator/buzzfeed-sso/templates/_helpers.tpl index 7e2fb0a6633d..92210a5fb383 100644 --- a/incubator/buzzfeed-sso/templates/_helpers.tpl +++ b/incubator/buzzfeed-sso/templates/_helpers.tpl @@ -30,3 +30,25 @@ Create chart name and version as used by the chart label. {{- define "buzzfeed-sso.chart" -}} {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} {{- end -}} + +{{/* +Return the apiVersion of deployment. +*/}} +{{- define "deployment.apiVersion" -}} +{{- if .Capabilities.APIVersions.Has "apps/v1" -}} + {{- print "apps/v1" -}} +{{- else -}} + {{- print "apps/v1beta1" -}} +{{- end -}} +{{- end -}} + +{{/* +Return the apiVersion of ingress. +*/}} +{{- define "ingress.apiVersion" -}} +{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1" -}} + {{- print "networking.k8s.io/v1beta1" -}} +{{- else -}} + {{- print "extensions/v1beta1" -}} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/incubator/buzzfeed-sso/templates/auth-deployment.yaml b/incubator/buzzfeed-sso/templates/auth-deployment.yaml index b35b562f7d2a..5a879e31c935 100644 --- a/incubator/buzzfeed-sso/templates/auth-deployment.yaml +++ b/incubator/buzzfeed-sso/templates/auth-deployment.yaml @@ -4,7 +4,7 @@ {{- $authSecret := .Values.auth.customSecret | default ($fullName) -}} {{- $name := include "buzzfeed-sso.name" . -}} {{- $authDomain := .Values.auth.domain -}} -apiVersion: apps/v1beta1 +apiVersion: {{ template "deployment.apiVersion" . }} kind: Deployment metadata: name: {{ $fullName }}-auth diff --git a/incubator/buzzfeed-sso/templates/ingress.yaml b/incubator/buzzfeed-sso/templates/ingress.yaml index 07af7a6e177b..544717647c81 100644 --- a/incubator/buzzfeed-sso/templates/ingress.yaml +++ b/incubator/buzzfeed-sso/templates/ingress.yaml @@ -2,7 +2,7 @@ {{- if ne .Values.auth.domain "" -}} {{- $fullName := include "buzzfeed-sso.fullname" . -}} {{- $authDomain := .Values.auth.domain -}} -apiVersion: extensions/v1beta1 +apiVersion: {{ template "ingress.apiVersion" . }} kind: Ingress metadata: name: {{ $fullName }} diff --git a/incubator/buzzfeed-sso/templates/proxy-deployment.yaml b/incubator/buzzfeed-sso/templates/proxy-deployment.yaml index 03873b420cfc..4f3ad28b8f14 100644 --- a/incubator/buzzfeed-sso/templates/proxy-deployment.yaml +++ b/incubator/buzzfeed-sso/templates/proxy-deployment.yaml @@ -2,7 +2,7 @@ {{- $fullName := include "buzzfeed-sso.fullname" . -}} {{- $proxySecret := .Values.proxy.customSecret | default ($fullName) -}} {{- $name := include "buzzfeed-sso.name" . -}} -apiVersion: apps/v1beta1 +apiVersion: {{ template "deployment.apiVersion" . }} kind: Deployment metadata: name: {{ $fullName }}-proxy