Skip to content

Commit

Permalink
Merge pull request #174 from lobziik/pdb2
Browse files Browse the repository at this point in the history
Bug  2051457: CCM PodDisruptionBudgets
  • Loading branch information
openshift-merge-robot committed Apr 14, 2022
2 parents 74f7916 + 7488432 commit 4fbdd53
Show file tree
Hide file tree
Showing 37 changed files with 1,103 additions and 223 deletions.
10 changes: 6 additions & 4 deletions pkg/cloud/alibaba/alibaba.go
Expand Up @@ -30,7 +30,8 @@ type imagesReference struct {
}

var templateValuesValidationMap = map[string]interface{}{
"images": "required",
"images": "required",
"cloudproviderName": "required,type(string)",
}

type alibabaAssets struct {
Expand All @@ -42,9 +43,10 @@ func (a *alibabaAssets) GetRenderedResources() []client.Object {
return a.renderedResources
}

func getTemplateValues(images *imagesReference) (common.TemplateValues, error) {
func getTemplateValues(images *imagesReference, operatorConfig config.OperatorConfig) (common.TemplateValues, error) {
values := common.TemplateValues{
"images": images,
"images": images,
"cloudproviderName": operatorConfig.GetPlatformNameString(),
}
_, err := govalidator.ValidateMap(values, templateValuesValidationMap)
if err != nil {
Expand All @@ -68,7 +70,7 @@ func NewProviderAssets(config config.OperatorConfig) (common.CloudProviderAssets
if err != nil {
return nil, err
}
templateValues, err := getTemplateValues(images)
templateValues, err := getTemplateValues(images, config)
if err != nil {
return nil, err
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/cloud/alibaba/alibaba_test.go
Expand Up @@ -5,6 +5,8 @@ import (

"github.com/stretchr/testify/assert"

configv1 "github.com/openshift/api/config/v1"

"github.com/openshift/cluster-cloud-controller-manager-operator/pkg/config"
)

Expand All @@ -25,6 +27,7 @@ func TestGetResources(t *testing.T) {
ImagesReference: config.ImagesReference{
CloudControllerManagerAlibaba: "CloudControllerManagerAlibaba",
},
PlatformStatus: &configv1.PlatformStatus{Type: configv1.AlibabaCloudPlatformType},
},
},
}
Expand Down
Expand Up @@ -2,20 +2,23 @@ kind: Deployment
apiVersion: apps/v1
metadata:
labels:
app: alibaba-cloud-controller-manager
k8s-app: alibaba-cloud-controller-manager
infrastructure.openshift.io/cloud-controller-manager: {{ .cloudproviderName }}
name: alibaba-cloud-controller-manager
namespace: openshift-cloud-controller-manager
spec:
replicas: 2
selector:
matchLabels:
app: alibaba-cloud-controller-manager
k8s-app: alibaba-cloud-controller-manager
infrastructure.openshift.io/cloud-controller-manager: {{ .cloudproviderName }}
strategy:
type: Recreate
template:
metadata:
labels:
app: alibaba-cloud-controller-manager
k8s-app: alibaba-cloud-controller-manager
infrastructure.openshift.io/cloud-controller-manager: {{ .cloudproviderName }}
spec:
hostNetwork: true
serviceAccountName: cloud-controller-manager
Expand All @@ -28,7 +31,8 @@ spec:
- topologyKey: "kubernetes.io/hostname"
labelSelector:
matchLabels:
app: alibaba-cloud-controller-manager
k8s-app: alibaba-cloud-controller-manager
infrastructure.openshift.io/cloud-controller-manager: {{ .cloudproviderName }}
tolerations:
- effect: NoSchedule
key: node-role.kubernetes.io/master
Expand Down
4 changes: 4 additions & 0 deletions pkg/cloud/aws/assets/deployment.yaml
Expand Up @@ -3,13 +3,15 @@ kind: Deployment
metadata:
labels:
k8s-app: aws-cloud-controller-manager
infrastructure.openshift.io/cloud-controller-manager: {{ .cloudproviderName }}
name: aws-cloud-controller-manager
namespace: openshift-cloud-controller-manager
spec:
replicas: 2
selector:
matchLabels:
k8s-app: aws-cloud-controller-manager
infrastructure.openshift.io/cloud-controller-manager: {{ .cloudproviderName }}
strategy:
type: Recreate
template:
Expand All @@ -18,6 +20,7 @@ spec:
target.workload.openshift.io/management: '{"effect": "PreferredDuringScheduling"}'
labels:
k8s-app: aws-cloud-controller-manager
infrastructure.openshift.io/cloud-controller-manager: {{ .cloudproviderName }}
spec:
priorityClassName: system-cluster-critical
containers:
Expand Down Expand Up @@ -68,6 +71,7 @@ spec:
labelSelector:
matchLabels:
k8s-app: aws-cloud-controller-manager
infrastructure.openshift.io/cloud-controller-manager: {{ .cloudproviderName }}
serviceAccountName: cloud-controller-manager
tolerations:
- effect: NoSchedule
Expand Down
10 changes: 6 additions & 4 deletions pkg/cloud/aws/aws.go
Expand Up @@ -28,7 +28,8 @@ type imagesReference struct {
}

var templateValuesValidationMap = map[string]interface{}{
"images": "required",
"images": "required",
"cloudproviderName": "required,type(string)",
}

type awsAssets struct {
Expand All @@ -40,9 +41,10 @@ func (a *awsAssets) GetRenderedResources() []client.Object {
return a.renderedResources
}

func getTemplateValues(images *imagesReference) (common.TemplateValues, error) {
func getTemplateValues(images *imagesReference, operatorConfig config.OperatorConfig) (common.TemplateValues, error) {
values := common.TemplateValues{
"images": images,
"images": images,
"cloudproviderName": operatorConfig.GetPlatformNameString(),
}
_, err := govalidator.ValidateMap(values, templateValuesValidationMap)
if err != nil {
Expand All @@ -66,7 +68,7 @@ func NewProviderAssets(config config.OperatorConfig) (common.CloudProviderAssets
if err != nil {
return nil, err
}
templateValues, err := getTemplateValues(images)
templateValues, err := getTemplateValues(images, config)
if err != nil {
return nil, err
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/cloud/aws/aws_test.go
Expand Up @@ -5,6 +5,8 @@ import (

"github.com/stretchr/testify/assert"

configv1 "github.com/openshift/api/config/v1"

"github.com/openshift/cluster-cloud-controller-manager-operator/pkg/config"
)

Expand All @@ -25,6 +27,7 @@ func TestResourcesRenderingSmoke(t *testing.T) {
ImagesReference: config.ImagesReference{
CloudControllerManagerAWS: "CloudControllerManagerAws",
},
PlatformStatus: &configv1.PlatformStatus{Type: configv1.AWSPlatformType},
},
},
}
Expand Down
13 changes: 9 additions & 4 deletions pkg/cloud/azure/assets/cloud-controller-manager-deployment.yaml
Expand Up @@ -4,17 +4,21 @@ metadata:
name: azure-cloud-controller-manager
namespace: openshift-cloud-controller-manager
labels:
app: azure-cloud-controller-manager
k8s-app: azure-cloud-controller-manager
infrastructure.openshift.io/cloud-controller-manager: {{ .cloudproviderName }}
spec:
replicas: 2
selector:
matchLabels:
app: azure-cloud-controller-manager
k8s-app: azure-cloud-controller-manager
infrastructure.openshift.io/cloud-controller-manager: {{ .cloudproviderName }}
strategy:
type: Recreate
template:
metadata:
labels:
app: azure-cloud-controller-manager
k8s-app: azure-cloud-controller-manager
infrastructure.openshift.io/cloud-controller-manager: {{ .cloudproviderName }}
spec:
hostNetwork: true
serviceAccountName: cloud-controller-manager
Expand All @@ -27,7 +31,8 @@ spec:
- topologyKey: "kubernetes.io/hostname"
labelSelector:
matchLabels:
app: azure-cloud-controller-manager
k8s-app: azure-cloud-controller-manager
infrastructure.openshift.io/cloud-controller-manager: {{ .cloudproviderName }}
tolerations:
- effect: NoSchedule
key: node-role.kubernetes.io/master
Expand Down
8 changes: 6 additions & 2 deletions pkg/cloud/azure/assets/cloud-node-manager-daemonset.yaml
Expand Up @@ -4,20 +4,24 @@ metadata:
name: azure-cloud-node-manager
namespace: openshift-cloud-controller-manager
labels:
k8s-app: azure-cloud-node-manager
infrastructure.openshift.io/cloud-node-manager: {{ .cloudproviderName }}
component: azure-cloud-node-manager
kubernetes.io/cluster-service: "true"
spec:
selector:
matchLabels:
app: azure-cloud-node-manager
k8s-app: azure-cloud-node-manager
infrastructure.openshift.io/cloud-node-manager: {{ .cloudproviderName }}
updateStrategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 10%
template:
metadata:
labels:
app: azure-cloud-node-manager
k8s-app: azure-cloud-node-manager
infrastructure.openshift.io/cloud-node-manager: {{ .cloudproviderName }}
annotations:
cluster-autoscaler.kubernetes.io/daemonset-pod: "true"
spec:
Expand Down
2 changes: 2 additions & 0 deletions pkg/cloud/azure/azure.go
Expand Up @@ -31,6 +31,7 @@ type imagesReference struct {
var templateValuesValidationMap = map[string]interface{}{
"images": "required",
"infrastructureName": "required,type(string)",
"cloudproviderName": "required,notnull,type(string)",
}

type azureAssets struct {
Expand All @@ -46,6 +47,7 @@ func getTemplateValues(images *imagesReference, operatorConfig config.OperatorCo
values := common.TemplateValues{
"images": images,
"infrastructureName": operatorConfig.InfrastructureName,
"cloudproviderName": operatorConfig.GetPlatformNameString(),
}
_, err := govalidator.ValidateMap(values, templateValuesValidationMap)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions pkg/cloud/azure/azure_test.go
Expand Up @@ -28,6 +28,7 @@ func TestResourcesRenderingSmoke(t *testing.T) {
CloudControllerManagerAzure: "CloudControllerManagerAzure",
CloudNodeManagerAzure: "CloudNodeManagerAzure",
},
PlatformStatus: &configv1.PlatformStatus{Type: configv1.AzurePlatformType},
},
initErrMsg: "can not construct template values for azure assets: infrastructureName: non zero value required",
}, {
Expand All @@ -38,6 +39,7 @@ func TestResourcesRenderingSmoke(t *testing.T) {
CloudControllerManagerAzure: "CloudControllerManagerAzure",
CloudNodeManagerAzure: "CloudNodeManagerAzure",
},
PlatformStatus: &configv1.PlatformStatus{Type: configv1.AzurePlatformType},
InfrastructureName: "infra",
},
}, {
Expand All @@ -48,6 +50,7 @@ func TestResourcesRenderingSmoke(t *testing.T) {
CloudControllerManagerAzure: "CloudControllerManagerAzure",
CloudNodeManagerAzure: "CloudNodeManagerAzure",
},
PlatformStatus: &configv1.PlatformStatus{Type: configv1.AlibabaCloudPlatformType},
InfrastructureName: "infra",
ClusterProxy: &configv1.Proxy{
Status: configv1.ProxyStatus{
Expand Down
Expand Up @@ -4,17 +4,21 @@ metadata:
name: azure-cloud-controller-manager
namespace: openshift-cloud-controller-manager
labels:
app: azure-cloud-controller-manager
k8s-app: azure-cloud-controller-manager
infrastructure.openshift.io/cloud-controller-manager: {{ .cloudproviderName }}
spec:
replicas: 2
selector:
matchLabels:
app: azure-cloud-controller-manager
k8s-app: azure-cloud-controller-manager
infrastructure.openshift.io/cloud-controller-manager: {{ .cloudproviderName }}
strategy:
type: Recreate
template:
metadata:
labels:
app: azure-cloud-controller-manager
k8s-app: azure-cloud-controller-manager
infrastructure.openshift.io/cloud-controller-manager: {{ .cloudproviderName }}
spec:
hostNetwork: true
serviceAccountName: cloud-controller-manager
Expand All @@ -27,7 +31,8 @@ spec:
- topologyKey: "kubernetes.io/hostname"
labelSelector:
matchLabels:
app: azure-cloud-controller-manager
k8s-app: azure-cloud-controller-manager
infrastructure.openshift.io/cloud-controller-manager: {{ .cloudproviderName }}
tolerations:
- effect: NoSchedule
key: node-role.kubernetes.io/master
Expand Down
8 changes: 6 additions & 2 deletions pkg/cloud/azurestack/assets/cloud-node-manager-daemonset.yaml
Expand Up @@ -4,20 +4,24 @@ metadata:
name: azure-cloud-node-manager
namespace: openshift-cloud-controller-manager
labels:
k8s-app: azure-cloud-node-manager
infrastructure.openshift.io/cloud-node-manager: {{ .cloudproviderName }}
component: azure-cloud-node-manager
kubernetes.io/cluster-service: "true"
spec:
selector:
matchLabels:
app: azure-cloud-node-manager
k8s-app: azure-cloud-node-manager
infrastructure.openshift.io/cloud-node-manager: {{ .cloudproviderName }}
updateStrategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 10%
template:
metadata:
labels:
app: azure-cloud-node-manager
k8s-app: azure-cloud-node-manager
infrastructure.openshift.io/cloud-node-manager: {{ .cloudproviderName }}
annotations:
cluster-autoscaler.kubernetes.io/daemonset-pod: "true"
spec:
Expand Down
2 changes: 2 additions & 0 deletions pkg/cloud/azurestack/azurestack.go
Expand Up @@ -32,6 +32,7 @@ type imagesReference struct {
var templateValuesValidationMap = map[string]interface{}{
"images": "required",
"infrastructureName": "required,type(string)",
"cloudproviderName": "required,type(string)",
}

type azurestackAssets struct {
Expand All @@ -47,6 +48,7 @@ func getTemplateValues(images imagesReference, operatorConfig config.OperatorCon
values := common.TemplateValues{
"images": images,
"infrastructureName": operatorConfig.InfrastructureName,
"cloudproviderName": operatorConfig.GetPlatformNameString(),
}
_, err := govalidator.ValidateMap(values, templateValuesValidationMap)
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions pkg/cloud/azurestack/azurestack_test.go
Expand Up @@ -3,6 +3,8 @@ package azurestack
import (
"testing"

configv1 "github.com/openshift/api/config/v1"

"github.com/stretchr/testify/assert"

"github.com/openshift/cluster-cloud-controller-manager-operator/pkg/config"
Expand All @@ -28,6 +30,7 @@ func TestResourcesRenderingSmoke(t *testing.T) {
CloudControllerManagerAzure: "CloudControllerManagerAzure",
CloudNodeManagerAzure: "CloudNodeManagerAzure",
},
PlatformStatus: &configv1.PlatformStatus{Type: configv1.AzurePlatformType},
},
initErrMsg: "can not construct template values for azurestack assets: infrastructureName: non zero value required",
}, {
Expand All @@ -38,6 +41,7 @@ func TestResourcesRenderingSmoke(t *testing.T) {
CloudControllerManagerAzure: "CloudControllerManagerAzure",
CloudNodeManagerAzure: "CloudNodeManagerAzure",
},
PlatformStatus: &configv1.PlatformStatus{Type: configv1.AzurePlatformType},
InfrastructureName: "infra",
},
},
Expand Down
6 changes: 6 additions & 0 deletions pkg/cloud/cloud.go
Expand Up @@ -76,6 +76,12 @@ func GetResources(operatorConfig config.OperatorConfig) ([]client.Object, error)
}
renderedObjects := assets.GetRenderedResources()
substitutedObjects := common.SubstituteCommonPartsFromConfig(operatorConfig, renderedObjects)
commonResources, err := common.GetCommonResources(operatorConfig)
if err != nil {
klog.Errorf("can not create common resources %v", err)
return nil, err
}
substitutedObjects = append(substitutedObjects, commonResources...)
return substitutedObjects, nil
}

Expand Down

0 comments on commit 4fbdd53

Please sign in to comment.