Skip to content

Commit 0924bc1

Browse files
authored
Add environmetal variable to set providerID format (#635)
1 parent 3486841 commit 0924bc1

File tree

7 files changed

+37
-15
lines changed

7 files changed

+37
-15
lines changed

cloud/scope/powervs_machine.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ func (m *PowerVSMachineScope) GetZone() string {
447447
// SetProviderID will set the provider id for the machine.
448448
func (m *PowerVSMachineScope) SetProviderID(id *string) {
449449
// Based on the ProviderIDFormat version the providerID format will be decided.
450-
if options.PowerVSProviderIDFormat == options.PowerVSProviderIDFormatV2 {
450+
if options.PowerVSProviderIDFormatType(options.PowerVSProviderIDFormat) == options.PowerVSProviderIDFormatV2 {
451451
if id != nil {
452452
m.IBMPowerVSMachine.Spec.ProviderID = pointer.StringPtr(fmt.Sprintf("ibmpowervs://%s/%s/%s/%s", m.GetRegion(), m.GetZone(), m.IBMPowerVSMachine.Spec.ServiceInstanceID, *id))
453453
}

config/default/manager_auth_proxy_patch.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,3 @@ spec:
1919
ports:
2020
- containerPort: 8443
2121
name: https
22-
- name: manager
23-
args:
24-
- "--metrics-bind-addr=127.0.0.1:8080"
25-
- "--leader-elect"

config/manager/manager.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ spec:
2828
args:
2929
- "--leader-elect"
3030
- "--metrics-bind-addr=127.0.0.1:8080"
31+
- "--powervs-provider-id-fmt=${POWERVS_PROVIDER_ID_FORMAT:=v1}"
3132
image: controller:latest
3233
name: manager
3334
ports:

docs/book/src/developer/tilt.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,21 @@ Add following extra_args to log Power VS REST API Requests/Responses
5555
}
5656
}
5757
```
58+
59+
To deploy workload cluster with [Power VS cloud controller manager](/topics/powervs/external-cloud-provider.html) which is currently in experimental stage, Set `POWERVS_PROVIDER_ID_FORMAT` to `v2` under kustomize_substitutions.
60+
61+
```json
62+
{
63+
"default_registry": "gcr.io/you-project-name-here",
64+
"provider_repos": ["../cluster-api-provider-ibmcloud"],
65+
"enable_providers": ["ibmcloud", "kubeadm-bootstrap", "kubeadm-control-plane"],
66+
"kustomize_substitutions": {
67+
"IBMCLOUD_API_KEY": "XXXXXXXXXXXXXXXXXX",
68+
"POWERVS_PROVIDER_ID_FORMAT": "v2"
69+
}
70+
}
71+
```
72+
5873
**NOTE**: For information about all the fields that can be used in the `tilt-settings.json` file, check them [here](https://cluster-api.sigs.k8s.io/developer/tilt.html#tilt-settingsjson-fields).
5974

6075
## Run Tilt

docs/book/src/getting-started.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,14 @@ it into a management cluster using `clusterctl`.
4444

4545
> Note: Refer [Regions-Zones Mapping](/reference/regions-zones-mapping.html) for more information.
4646

47-
3. Initialize local bootstrap cluter as a management cluster
47+
> Note: To deploy workload cluster with [Power VS cloud controller manager](/topics/powervs/external-cloud-provider.html) which is currently in experimental stage. Set the `POWERVS_PROVIDER_ID_FORMAT` environmental variable
48+
```console
49+
export POWERVS_PROVIDER_ID_FORMAT=v2
50+
```
51+
52+
2. Initialize local bootstrap cluster as a management cluster
4853
49-
When executed for the first time, the following command accepts the infrasturcture provider as an input to install. `clusterctl init` automatically adds to the list the cluster-api core provider, and if unspecified, it also adds the kubeadm bootstrap and kubeadm control-plane providers, thereby converting it into a management cluster which will be used to provision a workload cluster in IBM Cloud.
54+
When executed for the first time, the following command accepts the infrastructure provider as an input to install. `clusterctl init` automatically adds to the list the cluster-api core provider, and if unspecified, it also adds the kubeadm bootstrap and kubeadm control-plane providers, thereby converting it into a management cluster which will be used to provision a workload cluster in IBM Cloud.
5055

5156
```console
5257
~ clusterctl init --infrastructure ibmcloud:<TAG>

main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,13 +237,13 @@ func initFlags(fs *pflag.FlagSet) {
237237
fs.StringVar(
238238
&options.PowerVSProviderIDFormat,
239239
"powervs-provider-id-fmt",
240-
options.PowerVSProviderIDFormatV1,
240+
string(options.PowerVSProviderIDFormatV1),
241241
"ProviderID format is used set the Provider ID format for Machine",
242242
)
243243
}
244244

245245
func validateFlags() error {
246-
switch options.PowerVSProviderIDFormat {
246+
switch options.PowerVSProviderIDFormatType(options.PowerVSProviderIDFormat) {
247247
case options.PowerVSProviderIDFormatV1:
248248
setupLog.Info("Using v1 version of ProviderID format")
249249
case options.PowerVSProviderIDFormatV2:

pkg/options/options.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,16 @@ limitations under the License.
1616

1717
package options
1818

19-
// PowerVSProviderIDFormat is used to identify the Provider ID format for Machine.
20-
var PowerVSProviderIDFormat string
19+
// PowerVSProviderIDFormatType enum attribute to identify Power VS ProviderID format.
20+
type PowerVSProviderIDFormatType string
21+
22+
const (
23+
// PowerVSProviderIDFormatV1 will set provider id to machine as ibmpowervs://<cluster_name>/<vm_hostname>
24+
PowerVSProviderIDFormatV1 PowerVSProviderIDFormatType = "v1"
2125

22-
// PowerVSProviderIDFormatV2 will set provider id to machine as ibmpowervs://<region>/<zone>/<service_instance_id>/<powervs_machine_id>
23-
const PowerVSProviderIDFormatV2 = "v2"
26+
// PowerVSProviderIDFormatV2 will set provider id to machine as ibmpowervs://<region>/<zone>/<service_instance_id>/<powervs_machine_id>
27+
PowerVSProviderIDFormatV2 PowerVSProviderIDFormatType = "v2"
28+
)
2429

25-
// PowerVSProviderIDFormatV1 will set provider id to machine as ibmpowervs://<cluster_name>/<vm_hostname>
26-
const PowerVSProviderIDFormatV1 = "v1"
30+
// PowerVSProviderIDFormat is used to identify the Provider ID format for Machine.
31+
var PowerVSProviderIDFormat string

0 commit comments

Comments
 (0)