From 2025d7a7ca76c1741dafe771fea1e4fa821d22cd Mon Sep 17 00:00:00 2001 From: Peter Idah Date: Wed, 24 Jan 2018 19:22:39 +0000 Subject: [PATCH] Validate k8s versions for PSP --- pkg/api/vlabs/validate.go | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/pkg/api/vlabs/validate.go b/pkg/api/vlabs/validate.go index 91e699c66a..57b047e1b6 100644 --- a/pkg/api/vlabs/validate.go +++ b/pkg/api/vlabs/validate.go @@ -111,9 +111,28 @@ func (o *OrchestratorProfile) Validate(isUpdate bool) error { } } } - if helpers.IsTrueBoolPointer(o.KubernetesConfig.EnablePodSecurityPolicy) && - !helpers.IsTrueBoolPointer(o.KubernetesConfig.EnableRbac) { - return fmt.Errorf("enablePodSecurityPolicy requires the enableRbac feature as a prerequisite") + if helpers.IsTrueBoolPointer(o.KubernetesConfig.EnablePodSecurityPolicy) { + if !helpers.IsTrueBoolPointer(o.KubernetesConfig.EnableRbac) { + return fmt.Errorf("enablePodSecurityPolicy requires the enableRbac feature as a prerequisite") + } + if o.OrchestratorVersion == common.KubernetesVersion1Dot5Dot7 || + o.OrchestratorVersion == common.KubernetesVersion1Dot5Dot8 || + o.OrchestratorVersion == common.KubernetesVersion1Dot6Dot6 || + o.OrchestratorVersion == common.KubernetesVersion1Dot6Dot9 || + o.OrchestratorVersion == common.KubernetesVersion1Dot6Dot11 || + o.OrchestratorVersion == common.KubernetesVersion1Dot7Dot0 || + o.OrchestratorVersion == common.KubernetesVersion1Dot7Dot1 || + o.OrchestratorVersion == common.KubernetesVersion1Dot7Dot2 || + o.OrchestratorVersion == common.KubernetesVersion1Dot7Dot4 || + o.OrchestratorVersion == common.KubernetesVersion1Dot7Dot5 || + o.OrchestratorVersion == common.KubernetesVersion1Dot7Dot7 || + o.OrchestratorVersion == common.KubernetesVersion1Dot7Dot9 || + o.OrchestratorVersion == common.KubernetesVersion1Dot7Dot10 || + o.OrchestratorVersion == common.KubernetesVersion1Dot7Dot12 { + return fmt.Errorf("enablePodSecurityPolicy is only supported in acs-engine for Kubernetes version %s or greater; unable to validate for Kubernetes version %s", + "1.8.0", o.OrchestratorVersion) + } + } }