File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package azure
2+
3+ import (
4+ "embed"
5+
6+ "github.com/openshift/cluster-cloud-controller-manager-operator/pkg/cloud/common"
7+ corev1 "k8s.io/api/core/v1"
8+ utilruntime "k8s.io/apimachinery/pkg/util/runtime"
9+ "sigs.k8s.io/controller-runtime/pkg/client"
10+ )
11+
12+ var (
13+ //go:embed bootstrap/*
14+ azureBootstrapFS embed.FS
15+
16+ azureBootstrapResoureces []client.Object
17+ azureBootstrapSources = []common.ObjectSource {
18+ {Object : & corev1.Pod {}, Path : "bootstrap/pod.yaml" },
19+ }
20+ )
21+
22+ func init () {
23+ var err error
24+ azureBootstrapResoureces , err = common .ReadResources (azureBootstrapFS , azureBootstrapSources )
25+ utilruntime .Must (err )
26+ }
27+
28+ // GetBootstrapResources returns a list static pods for provisioning CCM on bootstrap node for Azure
29+ func GetBootstrapResources () []client.Object {
30+ resources := make ([]client.Object , len (azureBootstrapResoureces ))
31+ for i := range azureBootstrapResoureces {
32+ resources [i ] = azureBootstrapResoureces [i ].DeepCopyObject ().(client.Object )
33+ }
34+
35+ return resources
36+ }
Original file line number Diff line number Diff line change 1+ package azure
2+
3+ import (
4+ "testing"
5+
6+ "github.com/stretchr/testify/assert"
7+ )
8+
9+ func TestGetBootstrapResources (t * testing.T ) {
10+ resources := GetBootstrapResources ()
11+ assert .Len (t , resources , 1 )
12+
13+ var names , kinds []string
14+ for _ , r := range resources {
15+ names = append (names , r .GetName ())
16+ kinds = append (kinds , r .GetObjectKind ().GroupVersionKind ().Kind )
17+ }
18+
19+ assert .Contains (t , names , "azure-cloud-controller-manager" )
20+ assert .Contains (t , kinds , "Pod" )
21+ }
Original file line number Diff line number Diff line change 1+ apiVersion : v1
2+ kind : Pod
3+ metadata :
4+ name : azure-cloud-controller-manager
5+ namespace : kube-system
6+ spec :
7+ priorityClassName : system-node-critical
8+ hostNetwork : true
9+ containers :
10+ - name : cloud-controller-manager
11+ image : mcr.microsoft.com/oss/kubernetes/azure-cloud-controller-manager:v1.0.0
12+ imagePullPolicy : IfNotPresent
13+ command : ["cloud-controller-manager"]
14+ args :
15+ - --cloud-provider=azure
16+ - --controllers=cloud-node # run cloud-node controller only for Node initialization
17+ - --kubeconfig=/etc/kubernetes/secrets/kubeconfig
18+ - --cloud-config=/etc/config/cloud.conf
19+ - --leader-elect=false
20+ - --port=10267
21+ - -v=2
22+ livenessProbe :
23+ httpGet :
24+ path : /healthz
25+ port : 10267
26+ initialDelaySeconds : 20
27+ periodSeconds : 10
28+ timeoutSeconds : 5
29+ volumeMounts :
30+ - name : secrets
31+ mountPath : /etc/kubernetes/secrets
32+ - name : config
33+ mountPath : /etc/config
34+ volumes :
35+ - name : secrets
36+ hostPath :
37+ path : /etc/kubernetes/bootstrap-secrets
38+ - name : config
39+ hostPath :
40+ path : /etc/kubernetes/bootstrap-configs
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package cloud
33import (
44 configv1 "github.com/openshift/api/config/v1"
55 "github.com/openshift/cluster-cloud-controller-manager-operator/pkg/cloud/aws"
6+ "github.com/openshift/cluster-cloud-controller-manager-operator/pkg/cloud/azure"
67 "github.com/openshift/cluster-cloud-controller-manager-operator/pkg/cloud/openstack"
78 "k8s.io/klog"
89 "sigs.k8s.io/controller-runtime/pkg/client"
@@ -37,6 +38,8 @@ func GetBootstrapResources(platform configv1.PlatformType) []client.Object {
3738 switch platform {
3839 case configv1 .AWSPlatformType :
3940 return aws .GetBootstrapResources ()
41+ case configv1 .AzurePlatformType :
42+ return azure .GetBootstrapResources ()
4043 default :
4144 klog .Warning ("No recognized cloud provider platform found in infrastructure" )
4245 return nil
Original file line number Diff line number Diff line change 55
66 configv1 "github.com/openshift/api/config/v1"
77 "github.com/openshift/cluster-cloud-controller-manager-operator/pkg/cloud/aws"
8+ "github.com/openshift/cluster-cloud-controller-manager-operator/pkg/cloud/azure"
89 "github.com/openshift/cluster-cloud-controller-manager-operator/pkg/cloud/openstack"
910 "github.com/stretchr/testify/assert"
1011 "sigs.k8s.io/controller-runtime/pkg/client"
@@ -88,8 +89,9 @@ func TestGetBootstrapResources(t *testing.T) {
8889 name : "GCP resources are empty, as the platform is not yet supported" ,
8990 platform : configv1 .GCPPlatformType ,
9091 }, {
91- name : "Azure resources are empty, as the platform is not yet supported " ,
92+ name : "Azure resources returned as expected " ,
9293 platform : configv1 .AzurePlatformType ,
94+ expected : azure .GetBootstrapResources (),
9395 }, {
9496 name : "VSphere resources are empty, as the platform is not yet supported" ,
9597 platform : configv1 .VSpherePlatformType ,
You can’t perform that action at this time.
0 commit comments